Skip to content

Commit 9d15cab

Browse files
fix: separate helper method from test file (#900)
## Summary of change This PR removes a util method from the accountlinking test file and moves it to the helper file since it is used in 2 test files (accountlinking and webauthn) and the while running the webauthn tests, the accountlinking ones were also getting triggered because the helper was being imported from that file. ## Related issues ## Test Plan All accountlinking and webauthn accountlinking tests should pass ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) ## Checklist for important updates - [ ] Changelog has been updated - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - In `package.json` - In `package-lock.json` - In `lib/ts/version.ts` - [x] Had run `npm run build-pretty` - [x] Had installed and ran the pre-commit hook - [x] Issue this PR against the latest non released version branch. - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - If no such branch exists, then create one from the latest released branch. - [ ] If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like `someFunc: function () {..}`). - [ ] If I added a new recipe, I also added the recipe entry point into the `size-limit` section of `package.json` with the size limit set to the current size rounded up. - [ ] If I added a new recipe, I also added the recipe entry point into the `rollup.config.mjs` - [ ] If I added a new login method, I modified the list in `lib/ts/types.ts` - [ ] If I added a factor id, I modified the list in `lib/ts/recipe/multifactorauth/types.ts` ## Remaining TODOs for this PR
1 parent 6452530 commit 9d15cab

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)