similarIssuesDrawer.spec.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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, waitFor} 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. MockApiClient.addMockResponse({
  31. url: `/projects/${organization.slug}/${project.slug}/`,
  32. body: {features: []},
  33. });
  34. });
  35. it('renders the content as expected', async function () {
  36. render(<SimilarIssuesDrawer group={group} project={project} />, {
  37. organization,
  38. router,
  39. });
  40. expect(
  41. await screen.findByRole('heading', {name: 'Similar Issues'})
  42. ).toBeInTheDocument();
  43. expect(screen.getByText('Issues with a similar stack trace')).toBeInTheDocument();
  44. await waitFor(() => {
  45. expect(mockSimilarIssues).toHaveBeenCalled();
  46. });
  47. expect(screen.getByRole('button', {name: 'Close Drawer'})).toBeInTheDocument();
  48. });
  49. });