From 862724d7645acc46ed3575c28611f8fb732746a0 Mon Sep 17 00:00:00 2001 From: MagentaManifold <17zhaomingyuan@gmail.com> Date: Wed, 11 Feb 2026 15:00:27 -0500 Subject: [PATCH] polish(settings): fix broken storybooks Because: * jest breaks storybook This commit: * fallback to non-jest mock when jest does not exist --- packages/fxa-settings/src/models/mocks.tsx | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/fxa-settings/src/models/mocks.tsx b/packages/fxa-settings/src/models/mocks.tsx index 4ceca897cd5..fcccb39e8a2 100644 --- a/packages/fxa-settings/src/models/mocks.tsx +++ b/packages/fxa-settings/src/models/mocks.tsx @@ -124,20 +124,27 @@ export function mockSession( } export function mockAuthClient() { + const mockSessionStatus = { + state: 'verified', + details: { + verified: true, + accountEmailVerified: true, + sessionVerified: true, + sessionVerificationMeetsMinimumAAL: true, + sessionVerificationMethod: 'email', + }, + }; // There are plenty more methods to mock here, but this is these are the ones // that get commonly used. - return { - sessionStatus: jest.fn().mockReturnValue({ - state: 'verified', - details: { - verified: true, - accountEmailVerified: true, - sessionVerified: true, - sessionVerificationMeetsMinimumAAL: true, - sessionVerificationMethod: 'email', - }, - }), - } as unknown as AuthClient; + if (typeof jest !== 'undefined') { + return { + sessionStatus: jest.fn().mockResolvedValue(mockSessionStatus), + } as unknown as AuthClient; + } else { + return { + sessionStatus: () => Promise.resolve(mockSessionStatus), + } as unknown as AuthClient; + } } export function mockSensitiveDataClient() {