similarIssuesDrawer.spec.tsx 1.8 KB

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