Skip to content

fix: separate helper method from test file #900

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
Jun 19, 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
21 changes: 1 addition & 20 deletions test/end-to-end/accountlinking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
setupST,
backendHook,
screenshotOnFailure,
tryPasswordlessSignInUp,
} from "../helpers";
import { TEST_CLIENT_BASE_URL, RESET_PASSWORD_API } from "../constants";

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

export async function tryPasswordlessSignInUp(page, email) {
await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo"));
await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=passwordless`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

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

await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]");

const loginAttemptInfo = JSON.parse(
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
);
const device = await getPasswordlessDevice(loginAttemptInfo);
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]);
await submitForm(page);
}

async function tryThirdPartySignInUp(page, email, isVerified = true, userId = email) {
await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=thirdparty`),
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/webauthn.accountlinking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
openRecoveryWithToken,
tryWebauthnSignIn,
} from "./webauthn.helpers";
import { tryPasswordlessSignInUp } from "./accountlinking.test";
import { tryPasswordlessSignInUp } from "../helpers";
import assert from "assert";

/*
Expand Down
20 changes: 20 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,3 +1345,23 @@ export async function getOAuth2TokenData(page) {
const tokenData = await element.evaluate((el) => el.textContent);
return JSON.parse(tokenData);
}

export async function tryPasswordlessSignInUp(page, email) {
await page.evaluate(() => localStorage.removeItem("supertokens-passwordless-loginAttemptInfo"));
await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}/auth/?authRecipe=passwordless`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

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

await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]");

const loginAttemptInfo = JSON.parse(
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
);
const device = await getPasswordlessDevice(loginAttemptInfo);
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]);
await submitForm(page);
}
Loading