Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarpenter committed Jan 28, 2025
1 parent 16d1c99 commit afca86f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,29 @@ describe('ConnectedAccountsSection ', () => {
expect(queryByRole('heading', { name: /Remove connected account/i })).not.toBeInTheDocument();
});
});

describe('Handles opening/closing actions', () => {
it('closes remove account form when connect account action is clicked', async () => {
const { wrapper } = await createFixtures(withConnections);
const { userEvent, getByText, getByRole, queryByRole } = render(<ConnectedAccountsSection />, { wrapper });

const item = getByText(/github/i);
const menuButton = item.parentElement?.parentElement?.parentElement?.parentElement?.children?.[1];
await act(async () => {
await userEvent.click(menuButton!);
});
getByRole('menuitem', { name: /remove/i });
await userEvent.click(getByRole('menuitem', { name: /remove/i }));
await waitFor(() => getByRole('heading', { name: /remove connected account/i }));

await expect(queryByRole('heading', { name: /remove connected account/i })).toBeInTheDocument();

// TODO: Figure out why this is not working as expected
// await userEvent.click(getByRole('button', { name: /connect account/i }));

// await waitFor(() =>
// expect(queryByRole('heading', { name: /remove connected account/i })).not.toBeInTheDocument(),
// );
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,32 @@ describe('PasskeySection', () => {
});
});
});

describe('Handles opening/closing actions', () => {
it('closes remove passkey form when add a passkey action is clicked', async () => {
const { wrapper } = await createFixtures(withPasskeys);
const { getByRole, userEvent, getByText, queryByRole } = render(
<CardStateProvider>
<PasskeySection />
</CardStateProvider>,
{ wrapper },
);

const item = getByText(passkeys[0].name);
const menuButton = getMenuItemFromText(item);
await act(async () => {
await userEvent.click(menuButton!);
});

getByRole('menuitem', { name: /remove/i });
await userEvent.click(getByRole('menuitem', { name: /remove/i }));
await waitFor(() => getByRole('heading', { name: /remove passkey/i }));

await waitFor(() => expect(queryByRole('heading', { name: /remove passkey/i })).toBeInTheDocument());

await userEvent.click(getByRole('button', { name: /add a passkey/i }));

await waitFor(() => expect(queryByRole('heading', { name: /remove passkey/i })).not.toBeInTheDocument());
});
});
});

0 comments on commit afca86f

Please sign in to comment.