Skip to content

Commit e83124b

Browse files
Add more signup tests for webauthn
1 parent e9694cc commit e83124b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/end-to-end/webauthn.signup.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,33 @@ describe("SuperTokens Webauthn SignUp", () => {
8383
"ST_LOGS SUPERTOKENS GET_REDIRECTION_URL TO_AUTH",
8484
]);
8585
});
86+
it("should recover successfully from a recoverable error", async () => {
87+
// Set the error to be thrown
88+
await page.evaluateOnNewDocument(() => {
89+
localStorage.setItem("webauthnErrorStatus", "FAILED_TO_REGISTER_USER");
90+
});
91+
92+
const email = await getTestEmail();
93+
await tryWebauthnSignUp(page, email);
94+
95+
// We should be in the confirmation page now.
96+
await submitForm(page);
97+
98+
await waitForSTElement(page, "[data-supertokens~='passkeyRecoverableErrorContainer']");
99+
100+
// Remove the error and retry
101+
await page.evaluateOnNewDocument(() => {
102+
localStorage.removeItem("webauthnErrorStatus");
103+
});
104+
105+
await submitForm(page);
106+
assert.deepStrictEqual(consoleLogs, [
107+
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
108+
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
109+
"ST_LOGS WEBAUTHN OVERRIDE GET REGISTER OPTIONS WITH SIGN UP",
110+
"ST_LOGS WEBAUTHN OVERRIDE GET REGISTER OPTIONS WITH SIGN UP",
111+
]);
112+
});
86113
it("should show recoverable error in the same view", async () => {
87114
// Set the error to be thrown
88115
await page.evaluateOnNewDocument(() => {
@@ -111,5 +138,27 @@ describe("SuperTokens Webauthn SignUp", () => {
111138

112139
await waitForSTElement(page, "[data-supertokens~='somethingWentWrongContainer']");
113140
});
141+
it("should go back to home when go back is clicked in something went wrong", async () => {
142+
// Set the error to be thrown
143+
await page.evaluateOnNewDocument(() => {
144+
localStorage.setItem("throwWebauthnError", "true");
145+
});
146+
147+
const email = await getTestEmail();
148+
await tryWebauthnSignUp(page, email);
149+
150+
// We should be in the confirmation page now.
151+
await submitForm(page);
152+
153+
await waitForSTElement(page, "[data-supertokens~='somethingWentWrongContainer']");
154+
const goBackBtn = await waitForSTElement(page, "[data-supertokens~='errorGoBackLabel']");
155+
await goBackBtn.click();
156+
157+
await waitForSTElement(page, "[data-supertokens~='signUpFormInnerContainer']");
158+
159+
await page.evaluateOnNewDocument(() => {
160+
localStorage.removeItem("throwWebauthnError");
161+
});
162+
});
114163
});
115164
});

0 commit comments

Comments
 (0)