header.spec.tsx 6.3 KB

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