index.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixture';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import ProjectIssueGrouping from 'sentry/views/settings/projectIssueGrouping';
  5. describe('projectIssueGrouping', () => {
  6. const {organization, projects} = initializeOrg();
  7. const project = projects[0];
  8. it('renders successfully', async () => {
  9. const request = MockApiClient.addMockResponse({
  10. url: `/projects/${organization.slug}/${project.slug}/grouping-configs/`,
  11. body: [],
  12. });
  13. render(
  14. <ProjectIssueGrouping
  15. organization={organization}
  16. project={project}
  17. {...RouteComponentPropsFixture()}
  18. />
  19. );
  20. expect(request).toHaveBeenCalled();
  21. expect(await screen.findByText('Issue Grouping')).toBeInTheDocument();
  22. });
  23. it('renders error', async () => {
  24. const request = MockApiClient.addMockResponse({
  25. url: `/projects/${organization.slug}/${project.slug}/grouping-configs/`,
  26. body: {
  27. detail: 'Internal Error',
  28. },
  29. statusCode: 500,
  30. });
  31. render(
  32. <ProjectIssueGrouping
  33. organization={organization}
  34. project={project}
  35. {...RouteComponentPropsFixture()}
  36. />
  37. );
  38. expect(request).toHaveBeenCalled();
  39. expect(
  40. await screen.findByText('Failed to load grouping configs')
  41. ).toBeInTheDocument();
  42. });
  43. });