sidebar.spec.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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,
  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. MockApiClient.addMockResponse({
  56. url: `/issues/${group.id}/autofix/`,
  57. body: {
  58. steps: [],
  59. },
  60. });
  61. mockFirstLastRelease = MockApiClient.addMockResponse({
  62. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  63. method: 'GET',
  64. });
  65. MockApiClient.addMockResponse({
  66. url: `/organizations/${organization.slug}/issues/1/external-issues/`,
  67. body: [],
  68. });
  69. mockExternalIssues = MockApiClient.addMockResponse({
  70. url: `/organizations/${organization.slug}/issues/${group.id}/integrations/`,
  71. body: [
  72. GitHubIntegrationFixture({
  73. status: 'active',
  74. externalIssues: [
  75. {
  76. id: '321',
  77. key: issueTrackingKey,
  78. url: 'https://github.com/Test-Sentry/github-test/issues/13',
  79. title: 'SyntaxError: XYZ',
  80. description: 'something else, sorry',
  81. displayName: '',
  82. },
  83. ],
  84. }),
  85. ],
  86. });
  87. });
  88. it('renders all the sections as expected', async function () {
  89. render(<StreamlinedSidebar group={group} project={project} event={event} />, {
  90. organization,
  91. });
  92. expect(await screen.findByText('Solutions Hub')).toBeInTheDocument();
  93. expect(await screen.findByText('First seen')).toBeInTheDocument();
  94. expect(screen.getByText('Last seen')).toBeInTheDocument();
  95. expect(mockFirstLastRelease).toHaveBeenCalled();
  96. expect(await screen.findByText('Issue Tracking')).toBeInTheDocument();
  97. expect(
  98. await screen.findByRole('button', {name: issueTrackingKey})
  99. ).toBeInTheDocument();
  100. expect(mockExternalIssues).toHaveBeenCalled();
  101. expect(screen.getByRole('heading', {name: 'Activity'})).toBeInTheDocument();
  102. expect(screen.getByRole('textbox', {name: /Add a comment/})).toBeInTheDocument();
  103. expect(screen.getByText(activityContent)).toBeInTheDocument();
  104. expect(screen.getByRole('heading', {name: 'Similar Issues'})).toBeInTheDocument();
  105. expect(screen.getByRole('button', {name: 'View Similar Issues'})).toBeInTheDocument();
  106. expect(screen.getByRole('heading', {name: 'Merged Issues'})).toBeInTheDocument();
  107. expect(screen.getByRole('button', {name: 'View Merged Issues'})).toBeInTheDocument();
  108. });
  109. });