issueContent.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {GroupFixture} from 'sentry-fixture/group';
  3. import {OrganizationFixture} from 'sentry-fixture/organization';
  4. import {ProjectFixture} from 'sentry-fixture/project';
  5. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  6. import {IssueContent} from 'sentry/views/issueDetails/streamline/issueContent';
  7. describe('IssueContent', () => {
  8. const organization = OrganizationFixture();
  9. const project = ProjectFixture({features: ['similarity-view']});
  10. const group = GroupFixture();
  11. const event = EventFixture();
  12. let mockMergedIssues: jest.Mock;
  13. let mockSimilarIssues: jest.Mock;
  14. beforeEach(() => {
  15. MockApiClient.clearMockResponses();
  16. mockMergedIssues = MockApiClient.addMockResponse({
  17. url: `/organizations/${organization.slug}/issues/${group.id}/hashes/?limit=50&query=`,
  18. body: [
  19. {
  20. latestEvent: event,
  21. state: 'unlocked',
  22. id: '2c4887696f708c476a81ce4e834c4b02',
  23. },
  24. ],
  25. method: 'GET',
  26. });
  27. mockSimilarIssues = MockApiClient.addMockResponse({
  28. url: `/organizations/${organization.id}/issues/${group.id}/similar/?limit=50`,
  29. body: [[group, {'exception:stacktrace:pairs': 0.375}]],
  30. method: 'GET',
  31. });
  32. });
  33. it('displays the extra data sections as closed by default', async function () {
  34. render(<IssueContent group={group} project={project} />, {organization});
  35. const mergedIssues = await screen.findByText('Merged Issues');
  36. expect(mergedIssues).toBeInTheDocument();
  37. expect(
  38. screen.queryByText('Fingerprints included in this issue')
  39. ).not.toBeInTheDocument();
  40. await userEvent.click(mergedIssues);
  41. expect(screen.getByText('Fingerprints included in this issue')).toBeInTheDocument();
  42. expect(mockMergedIssues).toHaveBeenCalled();
  43. const similarIssues = await screen.findByText('Similar Issues');
  44. expect(similarIssues).toBeInTheDocument();
  45. expect(
  46. screen.queryByText('Issues with a similar stack trace')
  47. ).not.toBeInTheDocument();
  48. await userEvent.click(similarIssues);
  49. expect(screen.getByText('Issues with a similar stack trace')).toBeInTheDocument();
  50. expect(mockSimilarIssues).toHaveBeenCalled();
  51. });
  52. });