Skip to content

Commit

Permalink
ref: Convert AddCodeOwnersModal to FC (#83690)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan953 authored Jan 29, 2025
1 parent a9689fd commit 46c06e1
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('AddCodeOwnerModal', function () {
});
});

it('renders', function () {
it('renders', async function () {
render(
<AddCodeOwnerModal
Body={ModalBody}
Expand All @@ -59,8 +59,9 @@ describe('AddCodeOwnerModal', function () {
project={project}
/>
);

expect(screen.getByRole('button', {name: 'Add File'})).toBeDisabled();
await waitFor(() =>
expect(screen.getByRole('button', {name: 'Add File'})).toBeDisabled()
);
});

it('renders codeowner file', async function () {
Expand All @@ -82,11 +83,12 @@ describe('AddCodeOwnerModal', function () {
/>
);

await selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
await waitFor(() =>
selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
)
);

expect(screen.getByTestId('icon-check-mark')).toBeInTheDocument();

expect(screen.getByRole('button', {name: 'Preview File'})).toHaveAttribute(
Expand All @@ -99,7 +101,7 @@ describe('AddCodeOwnerModal', function () {
MockApiClient.addMockResponse({
url: `/organizations/${org.slug}/code-mappings/${codeMapping.id}/codeowners/`,
method: 'GET',
statusCode: 404,
statusCode: 200,
});

render(
Expand All @@ -114,9 +116,11 @@ describe('AddCodeOwnerModal', function () {
/>
);

await selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
await waitFor(() =>
selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
)
);

expect(screen.getByText('No codeowner file found.')).toBeInTheDocument();
Expand Down Expand Up @@ -148,10 +152,11 @@ describe('AddCodeOwnerModal', function () {
project={project}
/>
);

await selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
await waitFor(() =>
selectEvent.select(
screen.getByText('--'),
`Repo Name: ${codeMapping.repoName}, Stack Trace Root: ${codeMapping.stackRoot}, Source Code Root: ${codeMapping.sourceRoot}`
)
);

await userEvent.click(screen.getByRole('button', {name: 'Add File'}));
Expand Down
Loading

0 comments on commit 46c06e1

Please sign in to comment.