header.spec.tsx 5.9 KB

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