Skip to content

fix: Webauthn test updates due to changes #882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/build/webauthnprebuiltui.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/ts/recipe/webauthn/components/features/signIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const SignInFeatureInner: React.FC<
props.clearError,
props.resetFactorList,
props.onSignInUpSwitcherClick,
isPasskeySupported,
props.showBackButton
props.showBackButton,
isPasskeySupported
)!;

return (
Expand Down
35 changes: 7 additions & 28 deletions test/end-to-end/webauthn.recover_account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
// Use the token to recover the account
await openRecoveryWithToken(page, "test");

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand Down Expand Up @@ -215,10 +212,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
// Use the token to recover the account
await openRecoveryWithToken(page, "test");

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Something went wrong, please refresh the page or reach out to support.");

Expand All @@ -240,10 +234,7 @@ describe("SuperTokens Webauthn Recover Account", () => {

await submitFormUnsafe(page);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Failed to recover account, please try again.");

Expand All @@ -265,10 +256,7 @@ describe("SuperTokens Webauthn Recover Account", () => {

await submitFormUnsafe(page);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand All @@ -293,10 +281,7 @@ describe("SuperTokens Webauthn Recover Account", () => {

await submitFormUnsafe(page);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Failed to recover account, please try again.");

Expand All @@ -318,10 +303,7 @@ describe("SuperTokens Webauthn Recover Account", () => {

await submitFormUnsafe(page);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Invalid authenticator, please try again.");

Expand All @@ -344,10 +326,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
await submitFormUnsafe(page);
await new Promise((res) => setTimeout(res, 1000));

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand Down
10 changes: 2 additions & 8 deletions test/end-to-end/webauthn.recovery_email.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ describe("SuperTokens Webauthn Recovery Email", () => {
const email = await getTestEmail();
await openRecoveryAccountPage(page, email, true);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Account Recovery is not allowed, please contact support.");

Expand All @@ -157,10 +154,7 @@ describe("SuperTokens Webauthn Recovery Email", () => {
});
const email = await getTestEmail();
await openRecoveryAccountPage(page, email, true);
const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand Down
22 changes: 11 additions & 11 deletions test/end-to-end/webauthn.signin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ describe("SuperTokens Webauthn SignIn", () => {

describe("SignIn test", () => {
it("signup with passkey", async () => {
// Override to enable webauthn support
await page.evaluateOnNewDocument(() => {
localStorage.setItem("overrideWebauthnSupport", "true");
});

await tryWebauthnSignIn(page);
await page.waitForTimeout(3000);

// Most of the sign-in mock is defined in the override for the web
// test server.
Expand Down Expand Up @@ -91,7 +97,7 @@ describe("SuperTokens Webauthn SignIn", () => {
localStorage.setItem("webauthnErrorStatus", "FAILED_TO_AUTHENTICATE_USER");
});
await tryWebauthnSignIn(page);
await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
await waitForSTElement(page, "[data-supertokens~='generalError']");

// Remove the error and retry
await page.evaluateOnNewDocument(() => {
Expand All @@ -112,7 +118,7 @@ describe("SuperTokens Webauthn SignIn", () => {
localStorage.setItem("webauthnErrorStatus", "FAILED_TO_AUTHENTICATE_USER");
});
await tryWebauthnSignIn(page);
await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
await waitForSTElement(page, "[data-supertokens~='generalError']");

await page.evaluateOnNewDocument(() => {
localStorage.removeItem("webauthnErrorStatus");
Expand All @@ -124,10 +130,7 @@ describe("SuperTokens Webauthn SignIn", () => {
localStorage.setItem("webauthnErrorStatus", "WEBAUTHN_NOT_SUPPORTED");
});
await tryWebauthnSignIn(page);
const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand All @@ -144,10 +147,7 @@ describe("SuperTokens Webauthn SignIn", () => {
localStorage.setItem("webauthnErrorStatus", "INVALID_OPTIONS_ERROR");
});
await tryWebauthnSignIn(page);
const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand All @@ -164,7 +164,7 @@ describe("SuperTokens Webauthn SignIn", () => {
localStorage.setItem("throwWebauthnError", "true");
});
await tryWebauthnSignIn(page);
await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
await waitForSTElement(page, "[data-supertokens~='generalError']");

await page.evaluateOnNewDocument(() => {
localStorage.removeItem("throwWebauthnError");
Expand Down
14 changes: 4 additions & 10 deletions test/end-to-end/webauthn.signup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ describe("SuperTokens Webauthn SignUp", () => {
await submitFormUnsafe(page);
await page.waitForTimeout(1000);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(errorText, "Email already exists, please sign in instead.");

Expand Down Expand Up @@ -200,7 +197,7 @@ describe("SuperTokens Webauthn SignUp", () => {
// We should be in the confirmation page now.
await submitFormUnsafe(page);

await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
await waitForSTElement(page, "[data-supertokens~='generalError']");

// Remove the error and retry
await page.evaluateOnNewDocument(() => {
Expand All @@ -227,7 +224,7 @@ describe("SuperTokens Webauthn SignUp", () => {
// We should be in the confirmation page now.
await submitFormUnsafe(page);

await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
await waitForSTElement(page, "[data-supertokens~='generalError']");

await page.evaluateOnNewDocument(() => {
localStorage.removeItem("webauthnErrorStatus");
Expand All @@ -245,10 +242,7 @@ describe("SuperTokens Webauthn SignUp", () => {
// We should be in the confirmation page now.
await submitFormUnsafe(page);

const errorTextContainer = await waitForSTElement(
page,
"[data-supertokens~='passkeyRecoverableErrorContainer']"
);
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
assert.strictEqual(
errorText,
Expand Down
Loading