sidebar.spec.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {GitHubIntegrationFixture} from 'sentry-fixture/githubIntegration';
  3. import {GroupFixture} from 'sentry-fixture/group';
  4. import {OrganizationFixture} from 'sentry-fixture/organization';
  5. import {ProjectFixture} from 'sentry-fixture/project';
  6. import {UserFixture} from 'sentry-fixture/user';
  7. import {render, screen} from 'sentry-test/reactTestingLibrary';
  8. import ConfigStore from 'sentry/stores/configStore';
  9. import GroupStore from 'sentry/stores/groupStore';
  10. import ProjectsStore from 'sentry/stores/projectsStore';
  11. import {GroupActivityType} from 'sentry/types/group';
  12. import StreamlinedSidebar from 'sentry/views/issueDetails/streamline/sidebar/sidebar';
  13. describe('StreamlinedSidebar', function () {
  14. const user = UserFixture();
  15. user.options.prefersIssueDetailsStreamlinedUI = true;
  16. ConfigStore.set('user', user);
  17. const activityContent = 'test-note';
  18. const issueTrackingKey = 'issue-key';
  19. const organization = OrganizationFixture({
  20. features: ['gen-ai-features'],
  21. });
  22. const project = ProjectFixture();
  23. const group = GroupFixture({
  24. activity: [
  25. {
  26. type: GroupActivityType.NOTE,
  27. id: 'note-1',
  28. data: {text: activityContent},
  29. dateCreated: '2020-01-01T00:00:00',
  30. user: user,
  31. project,
  32. },
  33. ],
  34. });
  35. const event = EventFixture({group});
  36. let mockFirstLastRelease: jest.Mock;
  37. let mockExternalIssues: jest.Mock;
  38. beforeEach(function () {
  39. ProjectsStore.loadInitialData([project]);
  40. GroupStore.init();
  41. MockApiClient.clearMockResponses();
  42. MockApiClient.addMockResponse({
  43. url: `/organizations/${organization.slug}/issues/${group.id}/`,
  44. method: 'GET',
  45. body: group,
  46. });
  47. MockApiClient.addMockResponse({
  48. url: '/issues/1/autofix/setup/',
  49. body: {
  50. genAIConsent: {ok: false},
  51. integration: {ok: true},
  52. githubWriteIntegration: {ok: true},
  53. },
  54. });
  55. mockFirstLastRelease = MockApiClient.addMockResponse({
  56. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  57. method: 'GET',
  58. });
  59. MockApiClient.addMockResponse({
  60. url: `/organizations/${organization.slug}/issues/1/external-issues/`,
  61. body: [],
  62. });
  63. mockExternalIssues = MockApiClient.addMockResponse({
  64. url: `/organizations/${organization.slug}/issues/${group.id}/integrations/`,
  65. body: [
  66. GitHubIntegrationFixture({
  67. status: 'active',
  68. externalIssues: [
  69. {
  70. id: '321',
  71. key: issueTrackingKey,
  72. url: 'https://github.com/Test-Sentry/github-test/issues/13',
  73. title: 'SyntaxError: XYZ',
  74. description: 'something else, sorry',
  75. displayName: '',
  76. },
  77. ],
  78. }),
  79. ],
  80. });
  81. });
  82. it('renders all the sections as expected', async function () {
  83. render(<StreamlinedSidebar group={group} project={project} event={event} />, {
  84. organization,
  85. });
  86. expect(await screen.findByText('Solutions Hub')).toBeInTheDocument();
  87. expect(await screen.findByText('First seen')).toBeInTheDocument();
  88. expect(screen.getByText('Last seen')).toBeInTheDocument();
  89. expect(mockFirstLastRelease).toHaveBeenCalled();
  90. expect(screen.getByRole('heading', {name: 'Issue Tracking'})).toBeInTheDocument();
  91. expect(
  92. await screen.findByRole('button', {name: issueTrackingKey})
  93. ).toBeInTheDocument();
  94. expect(mockExternalIssues).toHaveBeenCalled();
  95. expect(screen.getByRole('heading', {name: 'Activity'})).toBeInTheDocument();
  96. expect(screen.getByRole('textbox', {name: /Add a comment/})).toBeInTheDocument();
  97. expect(screen.getByText(activityContent)).toBeInTheDocument();
  98. expect(screen.getByRole('heading', {name: 'Similar Issues'})).toBeInTheDocument();
  99. expect(screen.getByRole('button', {name: 'View Similar Issues'})).toBeInTheDocument();
  100. expect(screen.getByRole('heading', {name: 'Merged Issues'})).toBeInTheDocument();
  101. expect(screen.getByRole('button', {name: 'View Merged Issues'})).toBeInTheDocument();
  102. });
  103. });