From 428e7452e95387177943fade106f2a31f9be7551 Mon Sep 17 00:00:00 2001 From: joerger Date: Tue, 10 Dec 2024 18:40:36 -0800 Subject: [PATCH] Fix tests. --- .../teleport/src/Account/Account.test.tsx | 20 ++++++++++++------- .../wizards/AddAuthDeviceWizard.test.tsx | 3 +++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/packages/teleport/src/Account/Account.test.tsx b/web/packages/teleport/src/Account/Account.test.tsx index bd7d565de022b..4154fd98bfbee 100644 --- a/web/packages/teleport/src/Account/Account.test.tsx +++ b/web/packages/teleport/src/Account/Account.test.tsx @@ -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(); @@ -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 @@ -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'); diff --git a/web/packages/teleport/src/Account/ManageDevices/wizards/AddAuthDeviceWizard.test.tsx b/web/packages/teleport/src/Account/ManageDevices/wizards/AddAuthDeviceWizard.test.tsx index f54bd8ee22e90..25750a77ef4b1 100644 --- a/web/packages/teleport/src/Account/ManageDevices/wizards/AddAuthDeviceWizard.test.tsx +++ b/web/packages/teleport/src/Account/ManageDevices/wizards/AddAuthDeviceWizard.test.tsx @@ -75,6 +75,9 @@ function TestWizard(props: Partial = {}) { describe('flow without reauthentication', () => { beforeEach(() => { jest.spyOn(auth, 'getMfaChallenge').mockResolvedValueOnce({}); + jest + .spyOn(auth, 'createPrivilegeToken') + .mockResolvedValueOnce('privilege-token'); }); test('adds a passkey', async () => {