Skip to content

Commit 7d427ac

Browse files
committed
test: Fix test errors
1 parent b5c68a4 commit 7d427ac

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

test/end-to-end/mfa.default_reqs.test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import {
4141
completeTOTP,
4242
goToFactorChooser,
4343
addToRequiredSecondaryFactorsForUser,
44+
setupWebauthn,
45+
completeWebauthn,
4446
} from "./mfa.helpers";
4547

4648
/*
@@ -135,7 +137,7 @@ describe("SuperTokens SignIn w/ MFA", function () {
135137
await goToFactorChooser(page);
136138
const list = await getFactorChooserOptions(page);
137139

138-
assert.deepStrictEqual(new Set(list), new Set(["otp-email", "otp-phone", "totp"]));
140+
assert.deepStrictEqual(new Set(list), new Set(["otp-email", "otp-phone", "totp", "webauthn"]));
139141
});
140142

141143
it("should require 2fa to sign in after setting up a factor - totp", async () => {
@@ -183,5 +185,21 @@ describe("SuperTokens SignIn w/ MFA", function () {
183185
await completeOTP(page, "PHONE");
184186
await waitForDashboard(page);
185187
});
188+
189+
it("should require 2fa to sign in after setting up a factor - webauthn", async () => {
190+
await tryEmailPasswordSignIn(page, email);
191+
await waitForDashboard(page);
192+
await setupWebauthn(page);
193+
await logout(page);
194+
195+
await tryEmailPasswordSignIn(page, email);
196+
await waitForDashboard(page);
197+
await addToRequiredSecondaryFactorsForUser(page, "webauthn");
198+
await logout(page);
199+
200+
await tryEmailPasswordSignIn(page, email);
201+
await completeWebauthn(page);
202+
await waitForDashboard(page);
203+
});
186204
});
187205
});

test/end-to-end/mfa.helpers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,15 @@ export async function tryWebauthnSignIn(page) {
228228
await submitFormUnsafe(page);
229229
await new Promise((res) => setTimeout(res, 1000));
230230
}
231+
232+
export async function setupWebauthn(page) {
233+
await goToFactorChooser(page);
234+
await chooseFactor(page, "webauthn");
235+
await waitForSTElement(page, "[data-supertokens~=passkeyConfirmationContainer]");
236+
await submitFormUnsafe(page);
237+
}
238+
239+
export async function completeWebauthn(page) {
240+
await waitForSTElement(page, "[data-supertokens~=webauthn-mfa]");
241+
await submitFormUnsafe(page);
242+
}

test/unit/componentOverrides.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ import { PasskeyFeatureBlock } from "../../lib/ts/recipe/webauthn/components/the
7171
import { ContinueWithoutPasskey } from "../../lib/ts/recipe/webauthn/components/themes/signUp/continueWithoutPasskey";
7272
import { SignUpFormInner } from "../../lib/ts/recipe/webauthn/components/themes/signUp/signUpForm";
7373
import { SignUpSomethingWentWrong } from "../../lib/ts/recipe/webauthn/components/themes/signUp/somethingWentWrong";
74+
import { WebauthnMFASignIn } from "../../lib/ts/recipe/webauthn/components/themes/mfa/signIn";
75+
import { WebauthnMFALoadingScreen } from "../../lib/ts/recipe/webauthn/components/themes/mfa/loadingScreen";
76+
import { WebauthnMFASignUp } from "../../lib/ts/recipe/webauthn/components/themes/mfa/signUp";
77+
import { WebauthnMFASignUpConfirmation } from "../../lib/ts/recipe/webauthn/components/themes/mfa/signUpConfirmation";
7478

7579
type AllComponentsOverrideMap = AuthRecipeOverrideMap &
7680
EmailPasswordOverrideMap &
@@ -159,6 +163,10 @@ describe("Theme component overrides", () => {
159163
WebauthnContinueWithoutPasskey_Override: ContinueWithoutPasskey,
160164
WebauthnPasskeySignUpForm_Override: SignUpFormInner,
161165
WebauthnPasskeySignUpSomethingWentWrong_Override: SignUpSomethingWentWrong,
166+
WebauthnMFASignIn_Override: WebauthnMFASignIn,
167+
WebauthnMFALoadingScreen_Override: WebauthnMFALoadingScreen,
168+
WebauthnMFASignUp_Override: WebauthnMFASignUp,
169+
WebauthnMFASignUpConfirmation_Override: WebauthnMFASignUpConfirmation,
162170
};
163171

164172
Object.entries(overrides).forEach(([key, comp]) => {

0 commit comments

Comments
 (0)