codeownerErrors.spec.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {CodeOwnerFixture} from 'sentry-fixture/codeOwner';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import {CodeOwnerErrors} from './codeownerErrors';
  6. describe('CodeownerErrors', () => {
  7. const project = ProjectFixture();
  8. const org = OrganizationFixture();
  9. it('should render errors', async () => {
  10. const codeowner = CodeOwnerFixture({
  11. errors: {
  12. missing_user_emails: ['santry@example.com'],
  13. missing_external_users: [],
  14. missing_external_teams: ['@getsentry/something'],
  15. teams_without_access: ['#snuba'],
  16. users_without_access: [],
  17. },
  18. });
  19. render(
  20. <CodeOwnerErrors
  21. codeowners={[codeowner]}
  22. projectSlug={project.slug}
  23. orgSlug={org.slug}
  24. />
  25. );
  26. await userEvent.click(
  27. screen.getByText(
  28. 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
  29. )
  30. );
  31. expect(
  32. screen.getByText(`There’s a problem linking teams and members from an integration`)
  33. ).toBeInTheDocument();
  34. expect(screen.getByText('@getsentry/something')).toBeInTheDocument();
  35. });
  36. it('should deduplicate errors', () => {
  37. const codeowner = CodeOwnerFixture({
  38. errors: {
  39. missing_user_emails: ['santry@example.com'],
  40. missing_external_users: [],
  41. missing_external_teams: ['@getsentry/something'],
  42. teams_without_access: ['#snuba'],
  43. users_without_access: [],
  44. },
  45. });
  46. render(
  47. <CodeOwnerErrors
  48. codeowners={[codeowner, {...codeowner, id: '123'}]}
  49. projectSlug={project.slug}
  50. orgSlug={org.slug}
  51. />
  52. );
  53. expect(
  54. screen.getByText(
  55. 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
  56. )
  57. ).toBeInTheDocument();
  58. });
  59. });