header.spec.tsx 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {TeamFixture} from 'sentry-fixture/team';
  5. import {initializeOrg} from 'sentry-test/initializeOrg';
  6. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  7. import {IssueCategory, PriorityLevel} from 'sentry/types/group';
  8. import GroupHeader from 'sentry/views/issueDetails/header';
  9. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  10. describe('GroupHeader', () => {
  11. const baseUrl = 'BASE_URL/';
  12. const organization = OrganizationFixture();
  13. const {router} = initializeOrg();
  14. const project = ProjectFixture({
  15. teams: [TeamFixture()],
  16. });
  17. describe('issue category: error, js project', () => {
  18. const defaultProps = {
  19. organization,
  20. baseUrl,
  21. group: GroupFixture({issueCategory: IssueCategory.ERROR}),
  22. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  23. project,
  24. event: null,
  25. };
  26. it('displays the correct tabs with all features enabled', async () => {
  27. const orgWithFeatures = OrganizationFixture({
  28. features: ['similarity-view', 'event-attachments', 'session-replay'],
  29. });
  30. const jsProjectWithSimilarityView = ProjectFixture({
  31. features: ['similarity-view'],
  32. platform: 'javascript',
  33. });
  34. const MOCK_GROUP = GroupFixture();
  35. MockApiClient.addMockResponse({
  36. url: `/organizations/${organization.slug}/replay-count/`,
  37. method: 'GET',
  38. body: {
  39. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  40. },
  41. });
  42. render(
  43. <GroupHeader
  44. {...defaultProps}
  45. organization={orgWithFeatures}
  46. project={jsProjectWithSimilarityView}
  47. />,
  48. {organization: orgWithFeatures, router}
  49. );
  50. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  51. expect(router.push).toHaveBeenLastCalledWith(
  52. expect.objectContaining({pathname: 'BASE_URL/'})
  53. );
  54. await userEvent.click(screen.getByRole('tab', {name: /activity/i}));
  55. expect(router.push).toHaveBeenCalledWith({
  56. pathname: 'BASE_URL/activity/',
  57. query: {},
  58. });
  59. await userEvent.click(screen.getByRole('tab', {name: /user feedback/i}));
  60. expect(router.push).toHaveBeenCalledWith({
  61. pathname: 'BASE_URL/feedback/',
  62. query: {},
  63. });
  64. await userEvent.click(screen.getByRole('tab', {name: /attachments/i}));
  65. expect(router.push).toHaveBeenCalledWith({
  66. pathname: 'BASE_URL/attachments/',
  67. query: {},
  68. });
  69. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  70. expect(router.push).toHaveBeenCalledWith({
  71. pathname: 'BASE_URL/tags/',
  72. query: {},
  73. });
  74. await userEvent.click(screen.getByRole('tab', {name: /all events/i}));
  75. expect(router.push).toHaveBeenCalledWith({
  76. pathname: 'BASE_URL/events/',
  77. query: {},
  78. });
  79. await userEvent.click(screen.getByRole('tab', {name: /merged issues/i}));
  80. expect(router.push).toHaveBeenCalledWith({
  81. pathname: 'BASE_URL/merged/',
  82. query: {},
  83. });
  84. await userEvent.click(screen.getByRole('tab', {name: /replays/i}));
  85. expect(router.push).toHaveBeenCalledWith({
  86. pathname: 'BASE_URL/replays/',
  87. query: {},
  88. });
  89. expect(screen.queryByRole('tab', {name: /replays/i})).toBeInTheDocument();
  90. });
  91. });
  92. describe('issue category: error, mobile project', () => {
  93. const defaultProps = {
  94. organization,
  95. baseUrl,
  96. group: GroupFixture({issueCategory: IssueCategory.ERROR}),
  97. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  98. project,
  99. event: null,
  100. };
  101. it('displays the correct tabs with all features enabled', async () => {
  102. const orgWithFeatures = OrganizationFixture({
  103. features: ['similarity-view', 'event-attachments', 'session-replay'],
  104. });
  105. const mobileProjectWithSimilarityView = ProjectFixture({
  106. features: ['similarity-view'],
  107. platform: 'unity',
  108. });
  109. const MOCK_GROUP = GroupFixture();
  110. MockApiClient.addMockResponse({
  111. url: `/organizations/${organization.slug}/replay-count/`,
  112. method: 'GET',
  113. body: {
  114. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  115. },
  116. });
  117. render(
  118. <GroupHeader
  119. {...defaultProps}
  120. organization={orgWithFeatures}
  121. project={mobileProjectWithSimilarityView}
  122. />,
  123. {organization: orgWithFeatures, router}
  124. );
  125. await userEvent.click(screen.getByRole('tab', {name: /similar issues/i}));
  126. expect(router.push).toHaveBeenCalledWith({
  127. pathname: 'BASE_URL/similar/',
  128. query: {},
  129. });
  130. expect(screen.queryByRole('tab', {name: /replays/i})).not.toBeInTheDocument();
  131. });
  132. });
  133. describe('issue category: performance', () => {
  134. const defaultProps = {
  135. organization,
  136. baseUrl,
  137. group: GroupFixture({issueCategory: IssueCategory.PERFORMANCE}),
  138. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  139. project,
  140. event: null,
  141. };
  142. it('displays the correct tabs with all features enabled', async () => {
  143. const orgWithFeatures = OrganizationFixture({
  144. features: ['similarity-view', 'event-attachments', 'session-replay'],
  145. });
  146. const projectWithSimilarityView = ProjectFixture({
  147. features: ['similarity-view'],
  148. });
  149. const MOCK_GROUP = GroupFixture({issueCategory: IssueCategory.PERFORMANCE});
  150. MockApiClient.addMockResponse({
  151. url: `/organizations/${organization.slug}/replay-count/`,
  152. method: 'GET',
  153. body: {
  154. [MOCK_GROUP.id]: ['replay42', 'replay256'],
  155. },
  156. });
  157. render(
  158. <GroupHeader
  159. {...defaultProps}
  160. organization={orgWithFeatures}
  161. project={projectWithSimilarityView}
  162. />,
  163. {organization: orgWithFeatures, router}
  164. );
  165. await userEvent.click(screen.getByRole('tab', {name: /details/i}));
  166. expect(router.push).toHaveBeenLastCalledWith(
  167. expect.objectContaining({pathname: 'BASE_URL/'})
  168. );
  169. await userEvent.click(screen.getByRole('tab', {name: /tags/i}));
  170. expect(router.push).toHaveBeenCalledWith({
  171. pathname: 'BASE_URL/tags/',
  172. query: {},
  173. });
  174. await userEvent.click(screen.getByRole('tab', {name: /sampled events/i}));
  175. expect(router.push).toHaveBeenCalledWith({
  176. pathname: 'BASE_URL/events/',
  177. query: {},
  178. });
  179. expect(screen.queryByRole('tab', {name: /user feedback/i})).not.toBeInTheDocument();
  180. expect(screen.queryByRole('tab', {name: /attachments/i})).not.toBeInTheDocument();
  181. expect(screen.queryByRole('tab', {name: /merged issues/i})).not.toBeInTheDocument();
  182. expect(
  183. screen.queryByRole('tab', {name: /similar issues/i})
  184. ).not.toBeInTheDocument();
  185. expect(screen.queryByRole('tab', {name: /replays/i})).not.toBeInTheDocument();
  186. });
  187. });
  188. describe('priority', () => {
  189. beforeEach(() => {
  190. MockApiClient.addMockResponse({
  191. url: '/organizations/org-slug/prompts-activity/',
  192. body: {data: {dismissed_ts: null}},
  193. });
  194. MockApiClient.addMockResponse({
  195. url: '/organizations/org-slug/replay-count/',
  196. body: {},
  197. });
  198. });
  199. it('shows priority even if stats is off', async () => {
  200. render(
  201. <GroupHeader
  202. baseUrl=""
  203. organization={OrganizationFixture()}
  204. group={GroupFixture({
  205. priority: PriorityLevel.HIGH,
  206. // Setting an issue category where stats are turned off
  207. issueCategory: IssueCategory.UPTIME,
  208. })}
  209. project={ProjectFixture()}
  210. groupReprocessingStatus={ReprocessingStatus.NO_STATUS}
  211. event={null}
  212. />
  213. );
  214. expect(await screen.findByText('Priority')).toBeInTheDocument();
  215. expect(await screen.findByText('High')).toBeInTheDocument();
  216. });
  217. it('can change priority', async () => {
  218. const mockModifyIssue = MockApiClient.addMockResponse({
  219. url: `/organizations/org-slug/issues/`,
  220. method: 'PUT',
  221. body: {},
  222. });
  223. render(
  224. <GroupHeader
  225. baseUrl=""
  226. organization={OrganizationFixture()}
  227. group={GroupFixture({priority: PriorityLevel.MEDIUM})}
  228. project={ProjectFixture()}
  229. groupReprocessingStatus={ReprocessingStatus.NO_STATUS}
  230. event={null}
  231. />
  232. );
  233. await userEvent.click(screen.getByRole('button', {name: 'Modify issue priority'}));
  234. await userEvent.click(screen.getByRole('menuitemradio', {name: 'High'}));
  235. expect(mockModifyIssue).toHaveBeenCalledWith(
  236. expect.anything(),
  237. expect.objectContaining({
  238. data: {priority: PriorityLevel.HIGH},
  239. })
  240. );
  241. });
  242. });
  243. });