1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import {CodeOwnerFixture} from 'sentry-fixture/codeOwner';
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {ProjectFixture} from 'sentry-fixture/project';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import {CodeOwnerErrors} from './codeownerErrors';
- describe('CodeownerErrors', () => {
- const project = ProjectFixture();
- const org = OrganizationFixture();
- it('should render error', async () => {
- const codeowner = CodeOwnerFixture({
- errors: {
- missing_user_emails: [],
- missing_external_users: [],
- missing_external_teams: ['@getsentry/something'],
- teams_without_access: [],
- users_without_access: [],
- },
- });
- render(
- <CodeOwnerErrors
- codeowners={[codeowner]}
- projectSlug={project.slug}
- orgSlug={org.slug}
- />
- );
- await userEvent.click(
- screen.getByText(
- 'There was 1 ownership issue within Sentry on the latest sync with the CODEOWNERS file'
- )
- );
- expect(
- screen.getByText(`There’s a problem linking teams and members from an integration`)
- ).toBeInTheDocument();
- expect(screen.getByText('@getsentry/something')).toBeInTheDocument();
- });
- it('should render errors', async () => {
- const codeowner = CodeOwnerFixture({
- errors: {
- missing_user_emails: ['santry@example.com'],
- missing_external_users: [],
- missing_external_teams: ['@getsentry/something'],
- teams_without_access: ['#snuba'],
- users_without_access: [],
- },
- });
- render(
- <CodeOwnerErrors
- codeowners={[codeowner]}
- projectSlug={project.slug}
- orgSlug={org.slug}
- />
- );
- await userEvent.click(
- screen.getByText(
- 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
- )
- );
- expect(
- screen.getByText(`There’s a problem linking teams and members from an integration`)
- ).toBeInTheDocument();
- expect(screen.getByText('@getsentry/something')).toBeInTheDocument();
- });
- it('should deduplicate errors', () => {
- const codeowner = CodeOwnerFixture({
- errors: {
- missing_user_emails: ['santry@example.com'],
- missing_external_users: [],
- missing_external_teams: ['@getsentry/something'],
- teams_without_access: ['#snuba'],
- users_without_access: [],
- },
- });
- render(
- <CodeOwnerErrors
- codeowners={[codeowner, {...codeowner, id: '123'}]}
- projectSlug={project.slug}
- orgSlug={org.slug}
- />
- );
- expect(
- screen.getByText(
- 'There were 3 ownership issues within Sentry on the latest sync with the CODEOWNERS file'
- )
- ).toBeInTheDocument();
- });
- });
|