diff --git a/test/end-to-end/generalerror.test.js b/test/end-to-end/generalerror.test.js index 8afc3fccf..2a950d841 100644 --- a/test/end-to-end/generalerror.test.js +++ b/test/end-to-end/generalerror.test.js @@ -63,7 +63,6 @@ let consoleLogs; describe("General error rendering", function () { let coreUrl; - let enabledRecipes = undefined; before(async function () { const _isGeneralErrorSupported = await isGeneralErrorSupported(); if (!_isGeneralErrorSupported) { @@ -77,7 +76,7 @@ describe("General error rendering", function () { beforeEach(async function () { await backendHook("beforeEach"); coreUrl = await setupCoreApp(); - await setupST({ coreUrl, enabledRecipes }); + await setupST({ coreUrl }); page = await browser.newPage(); consoleLogs = []; @@ -210,18 +209,11 @@ describe("General error rendering", function () { }); describe("ThirdPartyEmailPassword", function () { - before(async function () { - enabledRecipes = ["thirdpartyemailpassword", "session"]; - }); - getEmailPasswordTests("thirdpartyemailpassword", "THIRD_PARTY_EMAIL_PASSWORD"); getThirdPartyTests("thirdpartyemailpassword", "THIRD_PARTY_EMAIL_PASSWORD"); }); describe("ThirdPartyPasswordless", function () { - before(async function () { - enabledRecipes = ["thirdpartypasswordless", "session"]; - }); getThirdPartyTests("thirdpartypasswordless", "THIRD_PARTY_PASSWORDLESS"); }); diff --git a/test/end-to-end/getRedirectionURL.test.js b/test/end-to-end/getRedirectionURL.test.js index 9b0e36ed2..3d40ca801 100644 --- a/test/end-to-end/getRedirectionURL.test.js +++ b/test/end-to-end/getRedirectionURL.test.js @@ -23,7 +23,6 @@ import { TEST_CLIENT_BASE_URL, SIGN_IN_UP_API } from "../constants"; describe("getRedirectionURL Tests", function () { let browser; - let page; before(async function () { await backendHook("before"); @@ -46,6 +45,8 @@ describe("getRedirectionURL Tests", function () { describe("Test that isNewRecipeUser is passed correctly", function () { describe("Email Password Recipe", function () { + let page; + beforeEach(async function () { page = await browser.newPage(); const coreUrl = await setupCoreApp(); @@ -72,6 +73,8 @@ describe("getRedirectionURL Tests", function () { }); describe("Third party recipe", function () { + let page; + before(async function () { const coreUrl = await setupCoreApp(); await setupST({ coreUrl }); @@ -105,6 +108,8 @@ describe("getRedirectionURL Tests", function () { }); describe("Thirdpartyemailpassword recipe", function () { + let page; + before(async function () { const coreUrl = await setupCoreApp(); await setupST({ coreUrl }); @@ -145,6 +150,7 @@ describe("getRedirectionURL Tests", function () { describe("Passwordless recipe", function () { const exampleEmail = "test@example.com"; + let page; before(async function () { let _isPasswordlessSupported = await isPasswordlessSupported(); @@ -207,6 +213,7 @@ describe("getRedirectionURL Tests", function () { describe("ThirdPartyPasswordless recipe", function () { const exampleEmail = "test@example.com"; + let page; before(async function () { let _isThirdPartyPasswordlessSupported = await isThirdPartyPasswordlessSupported(); @@ -283,6 +290,8 @@ describe("getRedirectionURL Tests", function () { describe("No Redirection", function () { describe("Email Password Recipe", function () { + let page; + before(async function () { const coreUrl = await setupCoreApp(); await setupST({ coreUrl }); @@ -320,6 +329,7 @@ describe("getRedirectionURL Tests", function () { describe("Passwordless recipe", function () { const exampleEmail = "test@example.com"; + let page; before(async function () { let _isPasswordlessSupported = await isPasswordlessSupported(); @@ -387,6 +397,7 @@ describe("getRedirectionURL Tests", function () { describe("ThirdPartyPasswordless recipe: Magic Link", function () { const exampleEmail = "test@example.com"; + let page; before(async function () { let _isThirdPartyPasswordlessSupported = await isThirdPartyPasswordlessSupported(); @@ -453,6 +464,7 @@ describe("getRedirectionURL Tests", function () { }); describe("ThirdParty Recipe", function () { + let page; before(async function () { const coreUrl = await setupCoreApp(); await setupST({ coreUrl }); diff --git a/test/end-to-end/mfa.chooserscreen.test.js b/test/end-to-end/mfa.chooserscreen.test.js index d15148841..3fe5c3691 100644 --- a/test/end-to-end/mfa.chooserscreen.test.js +++ b/test/end-to-end/mfa.chooserscreen.test.js @@ -256,7 +256,7 @@ describe("SuperTokens SignIn w/ MFA", function () { await chooseFactor(page, "otp-phone"); await completeOTP(page); - await goToFactorChooser(page); + await goToFactorChooser(page, true, false); await waitForSTElement(page, "[data-supertokens~=backButton]"); }); diff --git a/test/end-to-end/mfa.helpers.js b/test/end-to-end/mfa.helpers.js index e47494dad..451c186cb 100644 --- a/test/end-to-end/mfa.helpers.js +++ b/test/end-to-end/mfa.helpers.js @@ -191,10 +191,16 @@ export async function tryPasswordlessSignInUp(page, contactInfo, queryParams) { await submitForm(page); await new Promise((res) => setTimeout(res, 1000)); } -export async function goToFactorChooser(page, waitForList = true) { +export async function goToFactorChooser(page, waitForList = true, waitForNetworkIdle = true) { const ele = await page.waitForSelector(".goToFactorChooser"); - await waitFor(100); - await Promise.all([page.waitForNavigation({ waitUntil: "networkidle0" }), ele.click()]); + await waitFor(waitForNetworkIdle ? 100 : 1000); + const steps = [ele.click()]; + if (waitForNetworkIdle) { + // Insert at the start of the array + steps.unshift(page.waitForNavigation({ waitUntil: "networkidle0" })); + } + + await Promise.all(steps); if (waitForList) { await waitForSTElement(page, "[data-supertokens~=factorChooserList]"); } diff --git a/test/end-to-end/mfa.requirement_handling.test.js b/test/end-to-end/mfa.requirement_handling.test.js index b401d7795..74971fc51 100644 --- a/test/end-to-end/mfa.requirement_handling.test.js +++ b/test/end-to-end/mfa.requirement_handling.test.js @@ -124,7 +124,7 @@ describe("SuperTokens SignIn w/ MFA", function () { await tryEmailPasswordSignUp(page, email); await waitForDashboard(page); - await goToFactorChooser(page); + await goToFactorChooser(page, true, false); await chooseFactor(page, "otp-email"); await completeOTP(page); await setupOTP(page, "PHONE", phoneNumber); diff --git a/test/end-to-end/mfa.signin.test.js b/test/end-to-end/mfa.signin.test.js index 60e330ccd..45864b681 100644 --- a/test/end-to-end/mfa.signin.test.js +++ b/test/end-to-end/mfa.signin.test.js @@ -113,7 +113,7 @@ describe("SuperTokens SignIn w/ MFA", function () { it("sign in with email-otp (auto-setup)", async function () { const email = await getTestEmail(); - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: ["otp-email"], @@ -139,7 +139,7 @@ describe("SuperTokens SignIn w/ MFA", function () { const email = await getTestEmail(); const phoneNumber = getTestPhoneNumber(); - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: [{ oneOf: ["otp-email", "otp-phone"] }], @@ -163,7 +163,7 @@ describe("SuperTokens SignIn w/ MFA", function () { }); it("set up otp-email and sign-in", async function () { - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: [], @@ -179,7 +179,7 @@ describe("SuperTokens SignIn w/ MFA", function () { await logout(page); - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: [{ oneOf: ["otp-email"] }], @@ -203,7 +203,7 @@ describe("SuperTokens SignIn w/ MFA", function () { }); it("set up totp and sign-in", async function () { - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: [], @@ -211,7 +211,7 @@ describe("SuperTokens SignIn w/ MFA", function () { }); const email = await getTestEmail(); - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: [{ oneOf: ["otp-email", "totp"] }], @@ -245,7 +245,7 @@ describe("SuperTokens SignIn w/ MFA", function () { it("should show access denied if the only next option is an unknown factor id", async () => { const email = await getTestEmail(); - setupST({ + await setupST({ ...appConfig, mfaInfo: { requirements: ["unknown"], diff --git a/test/end-to-end/multitenancy.tenant_interactions.test.js b/test/end-to-end/multitenancy.tenant_interactions.test.js index 123475f28..bbb5cfac1 100644 --- a/test/end-to-end/multitenancy.tenant_interactions.test.js +++ b/test/end-to-end/multitenancy.tenant_interactions.test.js @@ -647,6 +647,11 @@ describe("SuperTokens Multitenancy tenant interactions", function () { await removeTenant("customer1"); + // We need to wait for a while so that the login_methods + // endpoint doesn't crash. Essentially, it seems like the core + // take a few seconds to update. + await page.waitForTimeout(3000); + let getDynamicLoginMethodsCalled = false; await page.setRequestInterception(true); const requestHandler = (request) => { diff --git a/test/end-to-end/passwordless.test.js b/test/end-to-end/passwordless.test.js index 339d7e8a4..c538a9a68 100644 --- a/test/end-to-end/passwordless.test.js +++ b/test/end-to-end/passwordless.test.js @@ -112,7 +112,11 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe await backendHook("before"); ({ browser, page } = await initBrowser(contactMethod, consoleLogs, authRecipe)); const coreUrl = await setupCoreApp(); - await setupST({ coreUrl, passwordlessFlowType: "USER_INPUT_CODE", passwordlessContactMethod: contactMethod }); + await setupST({ + coreUrl, + passwordlessFlowType: "USER_INPUT_CODE", + passwordlessContactMethod: contactMethod, + }); }); after(async function () { @@ -463,7 +467,11 @@ export function getPasswordlessTestCases({ authRecipe, logId, generalErrorRecipe disablePhoneGuess: true, })); const coreUrl = await setupCoreApp(); - await setupST({ coreUrl, passwordlessFlowType: "USER_INPUT_CODE", passwordlessContactMethod: contactMethod }); + await setupST({ + coreUrl, + passwordlessFlowType: "USER_INPUT_CODE", + passwordlessContactMethod: contactMethod, + }); }); after(async function () { diff --git a/test/end-to-end/thirdpartyemailpassword.test.js b/test/end-to-end/thirdpartyemailpassword.test.js index 1dd035f4c..24163c8fd 100644 --- a/test/end-to-end/thirdpartyemailpassword.test.js +++ b/test/end-to-end/thirdpartyemailpassword.test.js @@ -49,6 +49,7 @@ import { backendHook, setupCoreApp, setupST, + isThirdPartyEmailPasswordSupported, } from "../helpers"; import { TEST_CLIENT_BASE_URL, @@ -71,6 +72,10 @@ describe("SuperTokens Third Party Email Password", function () { const appConfig = {}; before(async function () { + if (!(await isThirdPartyEmailPasswordSupported())) { + this.skip(); + } + await backendHook("before"); const coreUrl = await setupCoreApp(); appConfig.coreUrl = coreUrl; diff --git a/test/helpers.js b/test/helpers.js index 44540efb9..1f2ad0c43 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1003,6 +1003,15 @@ export async function isThirdPartyPasswordlessSupported() { return false; } +export async function isThirdPartyEmailPasswordSupported() { + const features = await getFeatureFlags(); + if (features.includes("thirdpartyemailpassword")) { + return true; + } + + return false; +} + export async function isUserRolesSupported() { const features = await getFeatureFlags(); if (!features.includes("userroles")) {