header.spec.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import {browserHistory} from 'react-router';
  2. import {Organization} from 'sentry-fixture/organization';
  3. import {Project as ProjectFixture} from 'sentry-fixture/project';
  4. import {Team} from 'sentry-fixture/team';
  5. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  6. import {IssueCategory} from 'sentry/types';
  7. import GroupHeader from 'sentry/views/issueDetails/header';
  8. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  9. describe('groupDetails', () => {
  10. const baseUrl = 'BASE_URL/';
  11. const organization = Organization();
  12. const project = ProjectFixture({
  13. teams: [Team()],
  14. });
  15. describe('issue category: error, js project', () => {
  16. const defaultProps = {
  17. organization,
  18. baseUrl,
  19. group: TestStubs.Group({issueCategory: IssueCategory.ERROR}),
  20. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  21. project,
  22. };
  23. it('displays the correct tabs with all features enabled', async () => {
  24. const orgWithFeatures = Organization({
  25. features: ['similarity-view', 'event-attachments', 'session-replay'],
  26. });
  27. const jsProjectWithSimilarityView = ProjectFixture({
  28. features: ['similarity-view'],
  29. platform: 'javascript',
  30. });
  31. const MOCK_GROUP = TestStubs.Group();
  32. MockApiClient.addMockResponse({
  33. url: `/organizations/${organization.slug}/replay-count/`,
  34. method: 'GET',
  35. body: {
  36. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  37. },
  38. });
  39. render(
  40. <GroupHeader
  41. {...defaultProps}
  42. organization={orgWithFeatures}
  43. project={jsProjectWithSimilarityView}
  44. />,
  45. {organization: orgWithFeatures}
  46. );
  47. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  48. expect(browserHistory.push).toHaveBeenLastCalledWith('BASE_URL/');
  49. await userEvent.click(screen.getByRole('tab', {name: /activity/i}));
  50. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/activity/');
  51. await userEvent.click(screen.getByRole('tab', {name: /user feedback/i}));
  52. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/feedback/');
  53. await userEvent.click(screen.getByRole('tab', {name: /attachments/i}));
  54. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/attachments/');
  55. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  56. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/tags/');
  57. await userEvent.click(screen.getByRole('tab', {name: /all events/i}));
  58. expect(browserHistory.push).toHaveBeenCalledWith({
  59. pathname: 'BASE_URL/events/',
  60. query: {},
  61. });
  62. await userEvent.click(screen.getByRole('tab', {name: /merged issues/i}));
  63. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/merged/');
  64. await userEvent.click(screen.getByRole('tab', {name: /replays/i}));
  65. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/replays/');
  66. expect(screen.queryByRole('tab', {name: /replays/i})).toBeInTheDocument();
  67. });
  68. });
  69. describe('issue category: error, mobile project', () => {
  70. const defaultProps = {
  71. organization,
  72. baseUrl,
  73. group: TestStubs.Group({issueCategory: IssueCategory.ERROR}),
  74. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  75. project,
  76. };
  77. it('displays the correct tabs with all features enabled', async () => {
  78. const orgWithFeatures = Organization({
  79. features: ['similarity-view', 'event-attachments', 'session-replay'],
  80. });
  81. const mobileProjectWithSimilarityView = ProjectFixture({
  82. features: ['similarity-view'],
  83. platform: 'apple-ios',
  84. });
  85. const MOCK_GROUP = TestStubs.Group();
  86. MockApiClient.addMockResponse({
  87. url: `/organizations/${organization.slug}/replay-count/`,
  88. method: 'GET',
  89. body: {
  90. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  91. },
  92. });
  93. render(
  94. <GroupHeader
  95. {...defaultProps}
  96. organization={orgWithFeatures}
  97. project={mobileProjectWithSimilarityView}
  98. />,
  99. {organization: orgWithFeatures}
  100. );
  101. await userEvent.click(screen.getByRole('tab', {name: /similar issues/i}));
  102. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/similar/');
  103. expect(screen.queryByRole('tab', {name: /replays/i})).not.toBeInTheDocument();
  104. });
  105. });
  106. describe('issue category: performance', () => {
  107. const defaultProps = {
  108. organization,
  109. baseUrl,
  110. group: TestStubs.Group({issueCategory: IssueCategory.PERFORMANCE}),
  111. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  112. project,
  113. };
  114. it('displays the correct tabs with all features enabled', async () => {
  115. const orgWithFeatures = Organization({
  116. features: ['similarity-view', 'event-attachments', 'session-replay'],
  117. });
  118. const projectWithSimilarityView = ProjectFixture({
  119. features: ['similarity-view'],
  120. });
  121. const MOCK_GROUP = TestStubs.Group({issueCategory: IssueCategory.PERFORMANCE});
  122. MockApiClient.addMockResponse({
  123. url: `/organizations/${organization.slug}/replay-count/`,
  124. method: 'GET',
  125. body: {
  126. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  127. },
  128. });
  129. render(
  130. <GroupHeader
  131. {...defaultProps}
  132. organization={orgWithFeatures}
  133. project={projectWithSimilarityView}
  134. />,
  135. {organization: orgWithFeatures}
  136. );
  137. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  138. expect(browserHistory.push).toHaveBeenLastCalledWith('BASE_URL/');
  139. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  140. expect(browserHistory.push).toHaveBeenCalledWith('BASE_URL/tags/');
  141. await userEvent.click(screen.getByRole('tab', {name: /sampled events/i}));
  142. expect(browserHistory.push).toHaveBeenCalledWith({
  143. pathname: 'BASE_URL/events/',
  144. query: {},
  145. });
  146. expect(screen.queryByRole('tab', {name: /user feedback/i})).not.toBeInTheDocument();
  147. expect(screen.queryByRole('tab', {name: /attachments/i})).not.toBeInTheDocument();
  148. expect(screen.queryByRole('tab', {name: /merged issues/i})).not.toBeInTheDocument();
  149. expect(
  150. screen.queryByRole('tab', {name: /similar issues/i})
  151. ).not.toBeInTheDocument();
  152. expect(screen.queryByRole('tab', {name: /replays/i})).not.toBeInTheDocument();
  153. });
  154. });
  155. });