Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Dec 11, 2024
1 parent 656b718 commit 428e745
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 13 additions & 7 deletions web/packages/teleport/src/Account/Account.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ test('loading state', async () => {
expect(
within(screen.getByTestId('mfa-list')).getByTestId('indicator-wrapper')
).toBeVisible();
expect(screen.getByText(/add a passkey/i)).toBeDisabled();
expect(screen.getByText(/add mfa/i)).toBeDisabled();
expect(screen.getByText(/add a passkey/i)).toBeVisible();
expect(screen.getByText(/add mfa/i)).toBeVisible();
expect(
screen.queryByTestId('passwordless-state-pill')
).not.toBeInTheDocument();
Expand Down Expand Up @@ -272,11 +272,15 @@ test('adding an MFA device', async () => {
await renderComponent(ctx);
await user.click(screen.getByRole('button', { name: 'Add MFA' }));
await waitFor(async () => {
user.click(screen.getByRole('button', { name: 'Verify my identity' }));
await user.click(
screen.getByRole('button', { name: 'Verify my identity' })
);
});
await waitFor(async () => {
await user.click(
screen.getByRole('button', { name: 'Create an MFA method' })
);
});
await user.click(
screen.getByRole('button', { name: 'Create an MFA method' })
);
await user.type(screen.getByLabelText('MFA Method Name'), 'new-mfa');

// The final assertion can be accidentally made irrelevant if the button name
Expand Down Expand Up @@ -321,7 +325,9 @@ test('adding a passkey', async () => {
await renderComponent(ctx);
await user.click(screen.getByRole('button', { name: 'Add a Passkey' }));
await waitFor(async () => {
user.click(screen.getByRole('button', { name: 'Verify my identity' }));
await user.click(
screen.getByRole('button', { name: 'Verify my identity' })
);
});
await user.click(screen.getByRole('button', { name: 'Create a passkey' }));
await user.type(screen.getByLabelText('Passkey Nickname'), 'new-passkey');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function TestWizard(props: Partial<AddAuthDeviceWizardStepProps> = {}) {
describe('flow without reauthentication', () => {
beforeEach(() => {
jest.spyOn(auth, 'getMfaChallenge').mockResolvedValueOnce({});
jest
.spyOn(auth, 'createPrivilegeToken')
.mockResolvedValueOnce('privilege-token');
});

test('adds a passkey', async () => {
Expand Down

0 comments on commit 428e745

Please sign in to comment.