header.spec.tsx 6.3 KB

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