codeownerErrors.spec.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 error', async () => {
  10. const codeowner = CodeOwnerFixture({
  11. errors: {
  12. missing_user_emails: [],
  13. missing_external_users: [],
  14. missing_external_teams: ['@getsentry/something'],
  15. teams_without_access: [],
  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 was 1 ownership issue 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 render errors', async () => {
  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]}
  49. projectSlug={project.slug}
  50. orgSlug={org.slug}
  51. />
  52. );
  53. await userEvent.click(
  54. screen.getByText(
  55. 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
  56. )
  57. );
  58. expect(
  59. screen.getByText(`There’s a problem linking teams and members from an integration`)
  60. ).toBeInTheDocument();
  61. expect(screen.getByText('@getsentry/something')).toBeInTheDocument();
  62. });
  63. it('should deduplicate errors', () => {
  64. const codeowner = CodeOwnerFixture({
  65. errors: {
  66. missing_user_emails: ['santry@example.com'],
  67. missing_external_users: [],
  68. missing_external_teams: ['@getsentry/something'],
  69. teams_without_access: ['#snuba'],
  70. users_without_access: [],
  71. },
  72. });
  73. render(
  74. <CodeOwnerErrors
  75. codeowners={[codeowner, {...codeowner, id: '123'}]}
  76. projectSlug={project.slug}
  77. orgSlug={org.slug}
  78. />
  79. );
  80. expect(
  81. screen.getByText(
  82. 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
  83. )
  84. ).toBeInTheDocument();
  85. });
  86. });