streamlinedHeader.spec.tsx 4.4 KB

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