header.spec.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {LocationFixture} from 'sentry-fixture/locationFixture';
  3. import {OrganizationFixture} from 'sentry-fixture/organization';
  4. import {ProjectFixture} from 'sentry-fixture/project';
  5. import {ReleaseFixture} from 'sentry-fixture/release';
  6. import {TeamFixture} from 'sentry-fixture/team';
  7. import {UserFixture} from 'sentry-fixture/user';
  8. import {render, screen} from 'sentry-test/reactTestingLibrary';
  9. import {textWithMarkupMatcher} from 'sentry-test/utils';
  10. import type {TeamParticipant, UserParticipant} from 'sentry/types/group';
  11. import {IssueCategory} from 'sentry/types/group';
  12. import StreamlinedGroupHeader from 'sentry/views/issueDetails/streamline/header';
  13. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  14. describe('UpdatedGroupHeader', () => {
  15. const baseUrl = 'BASE_URL/';
  16. const organization = OrganizationFixture();
  17. const project = ProjectFixture({
  18. platform: 'javascript',
  19. teams: [TeamFixture()],
  20. });
  21. const group = GroupFixture({issueCategory: IssueCategory.ERROR, isUnhandled: true});
  22. const location = LocationFixture({query: {streamline: '1'}});
  23. describe('JS Project Error Issue', () => {
  24. const defaultProps = {
  25. organization,
  26. baseUrl,
  27. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  28. project,
  29. };
  30. const firstRelease = ReleaseFixture({id: '1'});
  31. const lastRelease = ReleaseFixture({id: '2'});
  32. beforeEach(() => {
  33. MockApiClient.addMockResponse({
  34. url: '/organizations/org-slug/replay-count/',
  35. body: {},
  36. });
  37. MockApiClient.addMockResponse({
  38. url: `/organizations/org-slug/repos/`,
  39. body: {},
  40. });
  41. MockApiClient.addMockResponse({
  42. url: `/projects/org-slug/project-slug/releases/${encodeURIComponent(firstRelease.version)}/`,
  43. body: {},
  44. });
  45. MockApiClient.addMockResponse({
  46. url: `/organizations/org-slug/releases/${encodeURIComponent(firstRelease.version)}/deploys/`,
  47. body: {},
  48. });
  49. });
  50. it('shows all elements of header', async () => {
  51. MockApiClient.addMockResponse({
  52. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  53. method: 'GET',
  54. body: {firstRelease, lastRelease},
  55. });
  56. const teams: TeamParticipant[] = [{...TeamFixture(), type: 'team'}];
  57. const users: UserParticipant[] = [
  58. {
  59. ...UserFixture({
  60. id: '2',
  61. name: 'John Smith',
  62. email: 'johnsmith@example.com',
  63. }),
  64. type: 'user',
  65. },
  66. {
  67. ...UserFixture({
  68. id: '3',
  69. name: 'Sohn Jmith',
  70. email: 'sohnjmith@example.com',
  71. }),
  72. type: 'user',
  73. },
  74. ];
  75. const participantGroup = {
  76. ...group,
  77. participants: [...teams, ...users],
  78. seenBy: users,
  79. };
  80. render(
  81. <StreamlinedGroupHeader
  82. {...defaultProps}
  83. group={participantGroup}
  84. project={project}
  85. />,
  86. {
  87. organization,
  88. router: {location},
  89. }
  90. );
  91. expect(screen.getByText('RequestError')).toBeInTheDocument();
  92. expect(screen.getByText('Warning')).toBeInTheDocument();
  93. expect(screen.getByText('Unhandled')).toBeInTheDocument();
  94. expect(
  95. await screen.findByText(textWithMarkupMatcher('Releases'))
  96. ).toBeInTheDocument();
  97. expect(
  98. screen.getByRole('button', {name: 'Modify issue priority'})
  99. ).toBeInTheDocument();
  100. expect(
  101. screen.getByRole('button', {name: 'Modify issue assignee'})
  102. ).toBeInTheDocument();
  103. expect(screen.getByText('Participants')).toBeInTheDocument();
  104. expect(screen.getByText('Viewers')).toBeInTheDocument();
  105. expect(
  106. screen.queryByRole('button', {name: 'Switch to the old issue experience'})
  107. ).not.toBeInTheDocument();
  108. expect(screen.getByRole('button', {name: 'Resolve'})).toBeInTheDocument();
  109. expect(screen.getByRole('button', {name: 'Archive'})).toBeInTheDocument();
  110. });
  111. it('only shows one release if possible', async function () {
  112. MockApiClient.addMockResponse({
  113. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  114. method: 'GET',
  115. // First and last release match
  116. body: {firstRelease, lastRelease: firstRelease},
  117. });
  118. render(
  119. <StreamlinedGroupHeader {...defaultProps} group={group} project={project} />,
  120. {
  121. organization,
  122. router: {location},
  123. }
  124. );
  125. expect(
  126. await screen.findByText(textWithMarkupMatcher('Release'))
  127. ).toBeInTheDocument();
  128. });
  129. it('displays new experience button if flag is set', async () => {
  130. MockApiClient.addMockResponse({
  131. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  132. method: 'GET',
  133. body: {firstRelease, lastRelease},
  134. });
  135. const flaggedOrganization = OrganizationFixture({
  136. features: ['issue-details-streamline'],
  137. });
  138. render(
  139. <StreamlinedGroupHeader {...defaultProps} group={group} project={project} />,
  140. {
  141. organization: flaggedOrganization,
  142. router: {location},
  143. }
  144. );
  145. expect(
  146. await screen.findByRole('button', {name: 'Switch to the old issue experience'})
  147. ).toBeInTheDocument();
  148. });
  149. });
  150. });