Skip to content

Commit 3c6d3c2

Browse files
Add fixes to make all webauthn tests pass after changes
1 parent 47b1add commit 3c6d3c2

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

examples/for-tests-react-16/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ function getWebauthnConfigs({
10611061
return implementation.recoverAccount(...args);
10621062
},
10631063
doesBrowserSupportWebAuthn(...args) {
1064-
if (overrideWebauthnSupport === undefined) {
1064+
if (overrideWebauthnSupport === undefined || overrideWebauthnSupport === null) {
10651065
return implementation.doesBrowserSupportWebAuthn(...args);
10661066
}
10671067

examples/for-tests/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ function getWebauthnConfigs({
13231323
return implementation.recoverAccount(...args);
13241324
},
13251325
doesBrowserSupportWebAuthn(...args) {
1326-
if (overrideWebauthnSupport === undefined) {
1326+
if (overrideWebauthnSupport === undefined || overrideWebauthnSupport === null) {
13271327
return implementation.doesBrowserSupportWebAuthn(...args);
13281328
}
13291329

lib/build/webauthn-shared.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/webauthn/functionOverrides.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,7 @@ export const getFunctionOverrides =
7575
registerCredentialWithRecoverAccount: async function (input) {
7676
return await originalImp.registerCredentialWithRecoverAccount(input);
7777
},
78+
doesBrowserSupportWebAuthn: async function (input) {
79+
return await originalImp.doesBrowserSupportWebAuthn(input);
80+
},
7881
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL } from "../constants";
2-
import { toggleSignInSignUp, setInputValues, submitForm, waitForSTElement } from "../helpers";
2+
import { toggleSignInSignUp, setInputValues, submitFormUnsafe, waitForSTElement } from "../helpers";
33

44
export async function openWebauthnSignUp(page) {
55
await Promise.all([
@@ -15,7 +15,7 @@ export async function tryWebauthnSignUp(page, email) {
1515

1616
await setInputValues(page, [{ name: "email", value: email }]);
1717

18-
await submitForm(page);
18+
await submitFormUnsafe(page);
1919
await new Promise((res) => setTimeout(res, 1000));
2020
}
2121

@@ -25,7 +25,7 @@ export async function tryWebauthnSignIn(page) {
2525
page.waitForNavigation({ waitUntil: "networkidle0" }),
2626
]);
2727

28-
await submitForm(page);
28+
await submitFormUnsafe(page);
2929
await new Promise((res) => setTimeout(res, 1000));
3030
}
3131

@@ -46,15 +46,15 @@ export async function openRecoveryAccountPage(page, email = null, shouldSubmit =
4646
}
4747

4848
await setInputValues(page, [{ name: "email", value: email }]);
49-
await submitForm(page);
49+
await submitFormUnsafe(page);
5050
await new Promise((res) => setTimeout(res, 1000));
5151
}
5252

5353
export async function signUpAndLogout(page, email) {
5454
await tryWebauthnSignUp(page, email);
5555

5656
// We should be in the confirmation page now.
57-
await submitForm(page);
57+
await submitFormUnsafe(page);
5858
await new Promise((res) => setTimeout(res, 2000));
5959

6060
// Find the div with classname logoutButton and click it using normal

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
clearBrowserCookiesWithoutAffectingConsole,
88
getTestEmail,
99
waitForSTElement,
10-
submitForm,
10+
submitFormUnsafe,
1111
} from "../helpers";
1212
import { openRecoveryWithToken, signUpAndSendRecoveryEmail, getTokenFromEmail } from "./webauthn.helpers";
1313
import assert from "assert";
@@ -115,7 +115,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
115115
await openRecoveryWithToken(page, token);
116116

117117
// We should be in the recovery page now, click the continue button
118-
await submitForm(page);
118+
await submitFormUnsafe(page);
119119

120120
await new Promise((res) => setTimeout(res, 2000));
121121

@@ -126,7 +126,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
126126
assert.deepStrictEqual(headerText, "Account recovered successfully!");
127127

128128
// Click on the continue button
129-
await submitForm(page);
129+
await submitFormUnsafe(page);
130130

131131
await new Promise((res) => setTimeout(res, 2000));
132132

@@ -241,7 +241,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
241241
assert.strictEqual(token.length, 128);
242242
await openRecoveryWithToken(page, token);
243243

244-
await submitForm(page);
244+
await submitFormUnsafe(page);
245245

246246
const errorTextContainer = await waitForSTElement(
247247
page,
@@ -267,7 +267,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
267267
assert.strictEqual(token.length, 128);
268268
await openRecoveryWithToken(page, token);
269269

270-
await submitForm(page);
270+
await submitFormUnsafe(page);
271271

272272
const errorTextContainer = await waitForSTElement(
273273
page,
@@ -296,7 +296,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
296296
assert.strictEqual(token.length, 128);
297297
await openRecoveryWithToken(page, token);
298298

299-
await submitForm(page);
299+
await submitFormUnsafe(page);
300300

301301
const errorTextContainer = await waitForSTElement(
302302
page,
@@ -322,7 +322,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
322322
assert.strictEqual(token.length, 128);
323323
await openRecoveryWithToken(page, token);
324324

325-
await submitForm(page);
325+
await submitFormUnsafe(page);
326326

327327
const errorTextContainer = await waitForSTElement(
328328
page,
@@ -348,7 +348,7 @@ describe("SuperTokens Webauthn Recover Account", () => {
348348
await openRecoveryWithToken(page, token);
349349

350350
// We should be in the recovery page now, click the continue button
351-
await submitForm(page);
351+
await submitFormUnsafe(page);
352352
await new Promise((res) => setTimeout(res, 1000));
353353

354354
const errorTextContainer = await waitForSTElement(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
toggleSignInSignUp,
99
setEnabledRecipes,
1010
waitForSTElement,
11-
submitForm,
11+
submitFormUnsafe,
1212
} from "../helpers";
1313
import { tryWebauthnSignIn } from "./webauthn.helpers";
1414
import assert from "assert";
@@ -96,7 +96,7 @@ describe("SuperTokens Webauthn SignIn", () => {
9696
localStorage.removeItem("webauthnErrorStatus");
9797
});
9898

99-
await submitForm(page);
99+
await submitFormUnsafe(page);
100100
assert.deepStrictEqual(consoleLogs, [
101101
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
102102
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
toggleSignInSignUp,
99
getTestEmail,
1010
waitForSTElement,
11-
submitForm,
11+
submitFormUnsafe,
1212
setEnabledRecipes,
1313
setInputValues,
1414
} from "../helpers";
@@ -76,7 +76,7 @@ describe("SuperTokens Webauthn SignUp", () => {
7676
// Should not show the back button after the form is submitted as well.
7777
const email = await getTestEmail();
7878
await setInputValues(page, [{ name: "email", value: email }]);
79-
await submitForm(page);
79+
await submitFormUnsafe(page);
8080
await new Promise((res) => setTimeout(res, 1000));
8181

8282
const backBtnAfterSubmit = await page.$("[data-supertokens~='backButton']");
@@ -107,7 +107,7 @@ describe("SuperTokens Webauthn SignUp", () => {
107107
await tryWebauthnSignUp(page, email);
108108

109109
// We should be in the confirmation page now.
110-
await submitForm(page);
110+
await submitFormUnsafe(page);
111111
await page.waitForTimeout(2000);
112112

113113
assert.deepStrictEqual(consoleLogs, [
@@ -127,7 +127,7 @@ describe("SuperTokens Webauthn SignUp", () => {
127127
const email = await getTestEmail();
128128
await tryWebauthnSignUp(page, email);
129129

130-
await submitForm(page);
130+
await submitFormUnsafe(page);
131131
await page.waitForTimeout(2000);
132132

133133
assert.deepStrictEqual(consoleLogs, [
@@ -150,7 +150,7 @@ describe("SuperTokens Webauthn SignUp", () => {
150150
await tryWebauthnSignUp(page, email);
151151

152152
// We should be in the confirmation page now.
153-
await submitForm(page);
153+
await submitFormUnsafe(page);
154154
await page.waitForTimeout(1000);
155155

156156
const errorTextContainer = await waitForSTElement(
@@ -183,7 +183,7 @@ describe("SuperTokens Webauthn SignUp", () => {
183183
});
184184
it("should show the email input not populated error", async () => {
185185
await tryWebauthnSignUp(page, "");
186-
await submitForm(page);
186+
await submitFormUnsafe(page);
187187
const errorTextContainer = await waitForSTElement(page, "[data-supertokens~='generalError']");
188188
const errorText = await errorTextContainer.evaluate((el) => el.textContent);
189189
assert.strictEqual(errorText, "Please enter your email to continue.");
@@ -198,7 +198,7 @@ describe("SuperTokens Webauthn SignUp", () => {
198198
await tryWebauthnSignUp(page, email);
199199

200200
// We should be in the confirmation page now.
201-
await submitForm(page);
201+
await submitFormUnsafe(page);
202202

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

@@ -207,7 +207,7 @@ describe("SuperTokens Webauthn SignUp", () => {
207207
localStorage.removeItem("webauthnErrorStatus");
208208
});
209209

210-
await submitForm(page);
210+
await submitFormUnsafe(page);
211211
assert.deepStrictEqual(consoleLogs, [
212212
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH",
213213
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS",
@@ -225,7 +225,7 @@ describe("SuperTokens Webauthn SignUp", () => {
225225
await tryWebauthnSignUp(page, email);
226226

227227
// We should be in the confirmation page now.
228-
await submitForm(page);
228+
await submitFormUnsafe(page);
229229

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

@@ -243,7 +243,7 @@ describe("SuperTokens Webauthn SignUp", () => {
243243
await tryWebauthnSignUp(page, email);
244244

245245
// We should be in the confirmation page now.
246-
await submitForm(page);
246+
await submitFormUnsafe(page);
247247

248248
const errorTextContainer = await waitForSTElement(
249249
page,
@@ -269,7 +269,7 @@ describe("SuperTokens Webauthn SignUp", () => {
269269
await tryWebauthnSignUp(page, email);
270270

271271
// We should be in the confirmation page now.
272-
await submitForm(page);
272+
await submitFormUnsafe(page);
273273

274274
await waitForSTElement(page, "[data-supertokens~='somethingWentWrongContainer']");
275275

@@ -287,7 +287,7 @@ describe("SuperTokens Webauthn SignUp", () => {
287287
await tryWebauthnSignUp(page, email);
288288

289289
// We should be in the confirmation page now.
290-
await submitForm(page);
290+
await submitFormUnsafe(page);
291291

292292
await waitForSTElement(page, "[data-supertokens~='somethingWentWrongContainer']");
293293
const goBackBtn = await waitForSTElement(page, "[data-supertokens~='errorGoBackLabel']");

test/helpers.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ export async function getSubmitFormButtonLabelWithoutShadowDom(page) {
178178
}
179179

180180
export async function getSubmitFormButton(page) {
181+
return waitForSTElement(page, "[data-supertokens='button']");
182+
}
183+
184+
export async function getSubmitFormButtonUnsafe(page) {
181185
return waitForSTElement(page, "[data-supertokens~='button']");
182186
}
183187

@@ -190,6 +194,11 @@ export async function submitForm(page) {
190194
await submitButton.click();
191195
}
192196

197+
export async function submitFormUnsafe(page) {
198+
const submitButton = await getSubmitFormButtonUnsafe(page);
199+
await submitButton.click();
200+
}
201+
193202
export async function clickOnPasswordlessResendButton(page) {
194203
const resendButton = await waitForSTElement(page, "[data-supertokens='link linkButton resendCodeBtn']");
195204
resendButton.click();

0 commit comments

Comments
 (0)