codeownerErrors.spec.tsx 1.8 KB

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