index.spec.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {DiscoverLanding} from 'app/views/eventsV2/landing';
  3. describe('EventsV2 > Landing', function () {
  4. const eventTitle = 'Oh no something bad';
  5. const features = ['discover-basic', 'discover-query'];
  6. beforeEach(function () {
  7. MockApiClient.addMockResponse({
  8. url: '/organizations/org-slug/projects/',
  9. body: [],
  10. });
  11. MockApiClient.addMockResponse({
  12. url: '/organizations/org-slug/eventsv2/',
  13. body: {
  14. meta: {
  15. id: 'string',
  16. title: 'string',
  17. 'project.name': 'string',
  18. timestamp: 'date',
  19. 'user.id': 'string',
  20. },
  21. data: [
  22. {
  23. id: 'deadbeef',
  24. 'user.id': 'alberto leal',
  25. title: eventTitle,
  26. 'project.name': 'project-slug',
  27. timestamp: '2019-05-23T22:12:48+00:00',
  28. },
  29. ],
  30. },
  31. });
  32. MockApiClient.addMockResponse({
  33. url: '/organizations/org-slug/events/project-slug:deadbeef/',
  34. method: 'GET',
  35. body: {
  36. id: '1234',
  37. size: 1200,
  38. eventID: 'deadbeef',
  39. title: 'Oh no something bad',
  40. message: 'It was not good',
  41. dateCreated: '2019-05-23T22:12:48+00:00',
  42. entries: [
  43. {
  44. type: 'message',
  45. message: 'bad stuff',
  46. data: {},
  47. },
  48. ],
  49. tags: [{key: 'browser', value: 'Firefox'}],
  50. },
  51. });
  52. MockApiClient.addMockResponse({
  53. url: '/organizations/org-slug/discover/saved/',
  54. method: 'GET',
  55. body: [],
  56. });
  57. });
  58. it('handles no projects', function () {
  59. const wrapper = mountWithTheme(
  60. <DiscoverLanding
  61. organization={TestStubs.Organization({features})}
  62. location={{query: {}}}
  63. router={{}}
  64. />,
  65. TestStubs.routerContext()
  66. );
  67. const content = wrapper.find('SentryDocumentTitle');
  68. expect(content.text()).toContain('You need at least one project to use this view');
  69. });
  70. it('denies access on missing feature', function () {
  71. const wrapper = mountWithTheme(
  72. <DiscoverLanding
  73. organization={TestStubs.Organization()}
  74. location={{query: {}}}
  75. router={{}}
  76. />,
  77. TestStubs.routerContext()
  78. );
  79. const content = wrapper.find('PageContent');
  80. expect(content.text()).toContain("You don't have access to this feature");
  81. });
  82. });