Skip to content

Commit 5b6fe29

Browse files
committed
test: Add e2e tests
1 parent 9ecb812 commit 5b6fe29

File tree

10 files changed

+482
-8
lines changed

10 files changed

+482
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
- Add `webauthn` as a secondary factor in MFA
11+
1012
## [0.49.1] - 2025-03-27
1113

1214
- Fixed a type issue making the WebauthnPreBuitlUI not produce a type error when added to the prebuiltUIList

lib/ts/recipe/webauthn/components/features/mfa/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,16 @@ function useOnLoad(
343343
accessDenied: true,
344344
error: "SOMETHING_WENT_WRONG_ERROR_RELOAD",
345345
});
346+
return;
346347
}
347348
}
348349

350+
const alreadySetup = mfaInfo.factors.alreadySetup.includes(FactorIds.WEBAUTHN);
351+
if (alreadySetup) {
352+
dispatch({ type: "setError", accessDenied: true, error: "SOMETHING_WENT_WRONG_ERROR_RELOAD" });
353+
return;
354+
}
355+
349356
// If the next array only has a single option, it means the we were redirected here
350357
// automatically during the sign in process. In that case, anywhere the back button
351358
// could go would redirect back here, making it useless.
@@ -357,16 +364,19 @@ function useOnLoad(
357364
const mfaInfoEmails = mfaInfo.emails[FactorIds.WEBAUTHN];
358365
const email = mfaInfoEmails ? mfaInfoEmails[0] : undefined;
359366

360-
const browserSupportsWebauthn = await props.recipe.webJSRecipe.doesBrowserSupportWebAuthn({
367+
const browserSupportsWebauthnResponse = await props.recipe.webJSRecipe.doesBrowserSupportWebAuthn({
361368
userContext: userContext,
362369
});
370+
const browserSupportsWebauthn =
371+
browserSupportsWebauthnResponse.status === "OK" &&
372+
browserSupportsWebauthnResponse?.browserSupportsWebauthn;
363373

364374
dispatch({
365375
type: "load",
366376
error,
367377
showBackButton,
368378
email,
369-
deviceSupported: browserSupportsWebauthn.status === "OK",
379+
deviceSupported: browserSupportsWebauthn,
370380
});
371381
},
372382
[dispatch, recipeImplementation, props.recipe, userContext]

lib/ts/recipe/webauthn/components/themes/mfa/loadingScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ export const WebauthnMFALoadingScreen = withOverride("WebauthnMFALoadingScreen",
1212
</div>
1313
);
1414
});
15-

lib/ts/recipe/webauthn/components/themes/mfa/signIn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const WebauthnMFASignIn = withOverride(
3939
</span>
4040
</div>
4141
) : (
42-
<div data-supertokens="headerTitle ebauthn-mfa">{t("WEBAUTHN_MFA_SIGN_IN_HEADER_TITLE")}</div>
42+
<div data-supertokens="headerTitle webauthn-mfa">{t("WEBAUTHN_MFA_SIGN_IN_HEADER_TITLE")}</div>
4343
)}
4444
<div data-supertokens="headerSubtitle secondaryText">{t("WEBAUTHN_MFA_SIGN_IN_HEADER_SUBTITLE")}</div>
4545
<Button
@@ -67,4 +67,4 @@ export const WebauthnMFASignIn = withOverride(
6767
</Fragment>
6868
);
6969
}
70-
);
70+
);

lib/ts/recipe/webauthn/components/themes/mfa/signUp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ export const WebauthnMFASignUp = withOverride(
9999
</Fragment>
100100
);
101101
}
102-
);
102+
);

lib/ts/recipe/webauthn/components/themes/mfa/signUpConfirmation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ export const WebauthnMFASignUpConfirmation = withOverride(
5757
</Fragment>
5858
);
5959
}
60-
);
60+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"peerDependencies": {
102102
"react": ">=16.8.0",
103103
"react-dom": ">=16.8.0",
104-
"supertokens-web-js": "github:supertokens/supertokens-web-js#feat/webauthn-mfa"
104+
"supertokens-web-js": "^0.15"
105105
},
106106
"scripts": {
107107
"init": "bash ./init.sh",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
screenshotOnFailure,
2525
getFactorChooserOptions,
2626
isMFASupported,
27+
isWebauthnSupported,
2728
expectErrorThrown,
2829
setupBrowser,
2930
backendHook,

0 commit comments

Comments
 (0)