codeownerErrors.spec.tsx 1.8 KB

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