header.spec.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.findByText('Events')).toBeInTheDocument();
  64. expect(screen.getByText(formatAbbreviatedNumber(group.count))).toBeInTheDocument();
  65. expect(await screen.findByRole('link', {name: 'Users'})).toBeInTheDocument();
  66. expect(
  67. screen.getByText(formatAbbreviatedNumber(group.userCount))
  68. ).toBeInTheDocument();
  69. expect(
  70. screen.getByRole('button', {name: 'Modify issue priority'})
  71. ).toBeInTheDocument();
  72. expect(
  73. screen.getByRole('button', {name: 'Modify issue assignee'})
  74. ).toBeInTheDocument();
  75. expect(
  76. screen.queryByRole('button', {name: 'Switch to the old issue experience'})
  77. ).not.toBeInTheDocument();
  78. expect(screen.getByRole('button', {name: 'Resolve'})).toBeInTheDocument();
  79. expect(screen.getByRole('button', {name: 'Archive'})).toBeInTheDocument();
  80. });
  81. it('displays new experience button if flag is set', async () => {
  82. const flaggedOrganization = OrganizationFixture({
  83. features: ['issue-details-streamline'],
  84. });
  85. render(
  86. <StreamlinedGroupHeader
  87. {...defaultProps}
  88. group={group}
  89. project={project}
  90. event={null}
  91. />,
  92. {
  93. organization: flaggedOrganization,
  94. router,
  95. }
  96. );
  97. expect(
  98. await screen.findByRole('button', {name: 'Switch to the old issue experience'})
  99. ).toBeInTheDocument();
  100. });
  101. });
  102. });