sidebar.spec.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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';
  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. const project = ProjectFixture();
  21. const group = GroupFixture({
  22. activity: [
  23. {
  24. type: GroupActivityType.NOTE,
  25. id: 'note-1',
  26. data: {text: activityContent},
  27. dateCreated: '2020-01-01T00:00:00',
  28. user: user,
  29. project,
  30. },
  31. ],
  32. });
  33. const event = EventFixture({group});
  34. let mockFirstLastRelease: jest.Mock;
  35. let mockExternalIssues: jest.Mock;
  36. beforeEach(function () {
  37. ProjectsStore.loadInitialData([project]);
  38. GroupStore.init();
  39. MockApiClient.clearMockResponses();
  40. MockApiClient.addMockResponse({
  41. url: `/organizations/${organization.slug}/issues/${group.id}/`,
  42. method: 'GET',
  43. body: group,
  44. });
  45. MockApiClient.addMockResponse({
  46. url: '/issues/1/autofix/setup/',
  47. body: {
  48. genAIConsent: {ok: false},
  49. integration: {ok: true},
  50. githubWriteIntegration: {ok: true},
  51. },
  52. });
  53. mockFirstLastRelease = MockApiClient.addMockResponse({
  54. url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
  55. method: 'GET',
  56. });
  57. MockApiClient.addMockResponse({
  58. url: `/organizations/${organization.slug}/issues/1/external-issues/`,
  59. body: [],
  60. });
  61. mockExternalIssues = MockApiClient.addMockResponse({
  62. url: `/organizations/${organization.slug}/issues/${group.id}/integrations/`,
  63. body: [
  64. GitHubIntegrationFixture({
  65. status: 'active',
  66. externalIssues: [
  67. {
  68. id: '321',
  69. key: issueTrackingKey,
  70. url: 'https://github.com/Test-Sentry/github-test/issues/13',
  71. title: 'SyntaxError: XYZ',
  72. description: 'something else, sorry',
  73. displayName: '',
  74. },
  75. ],
  76. }),
  77. ],
  78. });
  79. });
  80. it('renders all the sections as expected', async function () {
  81. render(<StreamlinedSidebar group={group} project={project} event={event} />, {
  82. organization,
  83. });
  84. expect(await screen.findByText('Solutions & Resources')).toBeInTheDocument();
  85. expect(screen.getByRole('button', {name: 'See More'})).toBeInTheDocument();
  86. expect(await screen.findByText('First seen')).toBeInTheDocument();
  87. expect(screen.getByText('Last seen')).toBeInTheDocument();
  88. expect(mockFirstLastRelease).toHaveBeenCalled();
  89. expect(screen.getByRole('heading', {name: 'Issue Tracking'})).toBeInTheDocument();
  90. expect(
  91. await screen.findByRole('button', {name: issueTrackingKey})
  92. ).toBeInTheDocument();
  93. expect(mockExternalIssues).toHaveBeenCalled();
  94. expect(screen.getByRole('heading', {name: 'Activity'})).toBeInTheDocument();
  95. expect(screen.getByPlaceholderText('Add a comment...')).toBeInTheDocument();
  96. expect(screen.getByText(activityContent)).toBeInTheDocument();
  97. expect(screen.getByRole('heading', {name: 'Similar Issues'})).toBeInTheDocument();
  98. expect(screen.getByRole('button', {name: 'View Similar Issues'})).toBeInTheDocument();
  99. expect(screen.getByRole('heading', {name: 'Merged Issues'})).toBeInTheDocument();
  100. expect(screen.getByRole('button', {name: 'View Merged Issues'})).toBeInTheDocument();
  101. });
  102. });