similarIssuesDrawer.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import GroupStore from 'sentry/stores/groupStore';
  6. import ProjectsStore from 'sentry/stores/projectsStore';
  7. import {SimilarIssuesDrawer} from 'sentry/views/issueDetails/groupSimilarIssues/similarIssuesDrawer';
  8. describe('SimilarIssuesDrawer', function () {
  9. const organization = OrganizationFixture();
  10. const project = ProjectFixture({features: ['similarity-view']});
  11. const group = GroupFixture();
  12. let mockSimilarIssues: jest.Mock;
  13. beforeEach(function () {
  14. MockApiClient.clearMockResponses();
  15. ProjectsStore.loadInitialData([project]);
  16. GroupStore.init();
  17. mockSimilarIssues = MockApiClient.addMockResponse({
  18. url: `/organizations/${organization.id}/issues/${group.id}/similar/?limit=50`,
  19. body: [[group, {'exception:stacktrace:pairs': 0.375}]],
  20. method: 'GET',
  21. });
  22. });
  23. it('renders the content as expected', async function () {
  24. render(<SimilarIssuesDrawer group={group} project={project} />, {organization});
  25. expect(
  26. await screen.findByRole('heading', {name: 'Similar Issues'})
  27. ).toBeInTheDocument();
  28. expect(screen.getByText('Issues with a similar stack trace')).toBeInTheDocument();
  29. expect(mockSimilarIssues).toHaveBeenCalled();
  30. expect(screen.getByRole('button', {name: 'Close Drawer'})).toBeInTheDocument();
  31. });
  32. });