Skip to content

Commit a3cef3a

Browse files
fix: separate helper method from test file
1 parent 6452530 commit a3cef3a

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

test/end-to-end/accountlinking.test.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
setupST,
4444
backendHook,
4545
screenshotOnFailure,
46+
tryPasswordlessSignInUp,
4647
} from "../helpers";
4748
import { TEST_CLIENT_BASE_URL, RESET_PASSWORD_API } from "../constants";
4849

@@ -831,26 +832,6 @@ async function tryEmailPasswordSignUp(page, email) {
831832
await new Promise((res) => setTimeout(res, 250));
832833
}
833834

834-
export async function tryPasswordlessSignInUp(page, email) {
835-
await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo"));
836-
await Promise.all([
837-
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=passwordless`),
838-
page.waitForNavigation({ waitUntil: "networkidle0" }),
839-
]);
840-
841-
await setInputValues(page, [{ name: "email", value: email }]);
842-
await submitForm(page);
843-
844-
await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]");
845-
846-
const loginAttemptInfo = JSON.parse(
847-
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
848-
);
849-
const device = await getPasswordlessDevice(loginAttemptInfo);
850-
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]);
851-
await submitForm(page);
852-
}
853-
854835
async function tryThirdPartySignInUp(page, email, isVerified = true, userId = email) {
855836
await Promise.all([
856837
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=thirdparty`),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
openRecoveryWithToken,
3232
tryWebauthnSignIn,
3333
} from "./webauthn.helpers";
34-
import { tryPasswordlessSignInUp } from "./accountlinking.test";
34+
import { tryPasswordlessSignInUp } from "../helpers";
3535
import assert from "assert";
3636

3737
/*

test/helpers.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,3 +1345,23 @@ export async function getOAuth2TokenData(page) {
13451345
const tokenData = await element.evaluate((el) => el.textContent);
13461346
return JSON.parse(tokenData);
13471347
}
1348+
1349+
export async function tryPasswordlessSignInUp(page, email) {
1350+
await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo"));
1351+
await Promise.all([
1352+
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=passwordless`),
1353+
page.waitForNavigation({ waitUntil: "networkidle0" }),
1354+
]);
1355+
1356+
await setInputValues(page, [{ name: "email", value: email }]);
1357+
await submitForm(page);
1358+
1359+
await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]");
1360+
1361+
const loginAttemptInfo = JSON.parse(
1362+
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
1363+
);
1364+
const device = await getPasswordlessDevice(loginAttemptInfo);
1365+
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]);
1366+
await submitForm(page);
1367+
}

0 commit comments

Comments
 (0)