header.spec.tsx 4.1 KB

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