header.spec.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 {RouterFixture} from 'sentry-fixture/routerFixture';
  6. import {TagsFixture} from 'sentry-fixture/tags';
  7. import {TeamFixture} from 'sentry-fixture/team';
  8. import {render, screen} from 'sentry-test/reactTestingLibrary';
  9. import {IssueCategory} from 'sentry/types/group';
  10. import {formatAbbreviatedNumber} from 'sentry/utils/formatters';
  11. import StreamlinedGroupHeader from 'sentry/views/issueDetails/streamline/header/header';
  12. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  13. describe('StreamlinedGroupHeader', () => {
  14. const baseUrl = 'BASE_URL/';
  15. const organization = OrganizationFixture();
  16. const project = ProjectFixture({
  17. platform: 'javascript',
  18. teams: [TeamFixture()],
  19. });
  20. const group = GroupFixture({issueCategory: IssueCategory.ERROR, isUnhandled: true});
  21. const router = RouterFixture({
  22. location: LocationFixture({query: {streamline: '1'}}),
  23. });
  24. describe('JS Project Error Issue', () => {
  25. const defaultProps = {
  26. organization,
  27. baseUrl,
  28. groupReprocessingStatus: ReprocessingStatus.NO_STATUS,
  29. project,
  30. };
  31. beforeEach(() => {
  32. MockApiClient.addMockResponse({
  33. url: '/organizations/org-slug/replay-count/',
  34. body: {},
  35. });
  36. MockApiClient.addMockResponse({
  37. url: `/organizations/org-slug/repos/`,
  38. body: {},
  39. });
  40. MockApiClient.addMockResponse({
  41. url: `/organizations/${organization.slug}/issues/${group.id}/attachments/`,
  42. body: [],
  43. });
  44. MockApiClient.addMockResponse({
  45. url: `/organizations/${organization.slug}/users/`,
  46. body: [],
  47. });
  48. MockApiClient.addMockResponse({
  49. url: `/organizations/${organization.slug}/issues/${group.id}/tags/`,
  50. body: TagsFixture(),
  51. method: 'GET',
  52. });
  53. });
  54. it('shows all elements of header', async () => {
  55. render(
  56. <StreamlinedGroupHeader
  57. {...defaultProps}
  58. group={group}
  59. project={project}
  60. event={null}
  61. />,
  62. {
  63. organization,
  64. router,
  65. }
  66. );
  67. expect(screen.getByText('RequestError')).toBeInTheDocument();
  68. expect(screen.getByText('Unhandled')).toBeInTheDocument();
  69. expect(await screen.findByRole('link', {name: 'View events'})).toBeInTheDocument();
  70. expect(screen.getByText(formatAbbreviatedNumber(group.count))).toBeInTheDocument();
  71. expect(
  72. await screen.findByRole('link', {name: 'View affected users'})
  73. ).toBeInTheDocument();
  74. expect(
  75. screen.getByText(formatAbbreviatedNumber(group.userCount))
  76. ).toBeInTheDocument();
  77. expect(
  78. screen.getByRole('button', {name: 'Modify issue priority'})
  79. ).toBeInTheDocument();
  80. expect(
  81. screen.getByRole('button', {name: 'Modify issue assignee'})
  82. ).toBeInTheDocument();
  83. expect(
  84. screen.queryByRole('button', {name: 'Switch to the old issue experience'})
  85. ).not.toBeInTheDocument();
  86. expect(screen.getByRole('button', {name: 'Resolve'})).toBeInTheDocument();
  87. expect(screen.getByRole('button', {name: 'Archive'})).toBeInTheDocument();
  88. });
  89. it('displays new experience button if flag is set', async () => {
  90. const flaggedOrganization = OrganizationFixture({
  91. features: ['issue-details-streamline'],
  92. });
  93. render(
  94. <StreamlinedGroupHeader
  95. {...defaultProps}
  96. group={group}
  97. project={project}
  98. event={null}
  99. />,
  100. {
  101. organization: flaggedOrganization,
  102. router,
  103. }
  104. );
  105. expect(
  106. await screen.findByRole('button', {name: 'Switch to the old issue experience'})
  107. ).toBeInTheDocument();
  108. });
  109. it('displays share icon if issue has been shared', async () => {
  110. render(
  111. <StreamlinedGroupHeader
  112. {...defaultProps}
  113. group={{...group, isPublic: true, shareId: 'abc123'}}
  114. project={project}
  115. event={null}
  116. />,
  117. {
  118. organization,
  119. router,
  120. }
  121. );
  122. expect(
  123. await screen.findByRole('button', {name: 'View issue share settings'})
  124. ).toBeInTheDocument();
  125. });
  126. });
  127. });