diff --git a/client/src/pages/NativeHandoffPage.test.tsx b/client/src/pages/NativeHandoffPage.test.tsx index 9bf582e76..bfeb70855 100644 --- a/client/src/pages/NativeHandoffPage.test.tsx +++ b/client/src/pages/NativeHandoffPage.test.tsx @@ -1,4 +1,4 @@ -// FE-NATIVE-HANDOFF-PAGE-001 to FE-NATIVE-HANDOFF-PAGE-004 +// FE-NATIVE-HANDOFF-PAGE-001 to FE-NATIVE-HANDOFF-PAGE-005 import { beforeEach, describe, expect, it, vi } from 'vitest'; import { fireEvent, render, screen } from '../../tests/helpers/render'; import NativeHandoffPage from './NativeHandoffPage'; @@ -8,6 +8,9 @@ vi.mock('./nativeHandoff/useNativeHandoff', () => ({ useNativeHandoff: vi.fn() } const base = { valid: true, + passkeyStep: false, + continueWithPasskey: vi.fn(), + otherSignIn: vi.fn(), ready: true, userName: 'maria', status: 'idle' as const, @@ -52,4 +55,14 @@ describe('NativeHandoffPage', () => { render(); expect(screen.getByText('Signing in did not work. Please try again.')).toBeInTheDocument(); }); + + it('FE-NATIVE-HANDOFF-PAGE-005: asks for the passkey itself when the app started a passkey sign-in', () => { + vi.mocked(useNativeHandoff).mockReturnValue({ ...base, passkeyStep: true, ready: false }); + render(); + const buttons = screen.getAllByRole('button'); + fireEvent.click(buttons[0]); + expect(base.continueWithPasskey).toHaveBeenCalled(); + fireEvent.click(buttons[1]); + expect(base.otherSignIn).toHaveBeenCalled(); + }); }); diff --git a/client/src/pages/nativeHandoff/useNativeHandoff.test.tsx b/client/src/pages/nativeHandoff/useNativeHandoff.test.tsx index db5002e69..c05a95b7b 100644 --- a/client/src/pages/nativeHandoff/useNativeHandoff.test.tsx +++ b/client/src/pages/nativeHandoff/useNativeHandoff.test.tsx @@ -22,9 +22,13 @@ vi.mock('../../native/browserSignIn', () => ({ })); vi.mock('@simplewebauthn/browser', () => ({ startAuthentication: vi.fn() })); -vi.mock('../../api/client', () => ({ - authApi: { passkey: { loginOptions: vi.fn(), loginVerify: vi.fn() } }, -})); +vi.mock('../../api/client', async () => { + const actual = await vi.importActual('../../api/client'); + return { + ...actual, + authApi: { ...actual.authApi, passkey: { ...actual.authApi.passkey, loginOptions: vi.fn(), loginVerify: vi.fn() } }, + }; +}); const challenge = 'ab'.repeat(32); const realLocation = window.location;