diff --git a/examples/for-tests-react-16/src/App.js b/examples/for-tests-react-16/src/App.js index c772bbc9f..fdc197859 100644 --- a/examples/for-tests-react-16/src/App.js +++ b/examples/for-tests-react-16/src/App.js @@ -272,50 +272,52 @@ if (testContext.enableMFA) { ); } -SuperTokens.init({ - usesDynamicLoginMethods: testContext.usesDynamicLoginMethods, - clientType: testContext.clientType, - appInfo: { - appName: "SuperTokens", - websiteDomain: getWebsiteDomain(), - apiDomain: getApiDomain(), - websiteBasePath, - }, - languageTranslations: { - translations: { - en: { - AUTH_PAGE_FOOTER_TOS: "TOS", - }, - hu: { - AUTH_PAGE_FOOTER_TOS: "ÁSZF", +if (!window.location.pathname.startsWith("/mockProvider")) { + SuperTokens.init({ + usesDynamicLoginMethods: testContext.usesDynamicLoginMethods, + clientType: testContext.clientType, + appInfo: { + appName: "SuperTokens", + websiteDomain: getWebsiteDomain(), + apiDomain: getApiDomain(), + websiteBasePath, + }, + languageTranslations: { + translations: { + en: { + AUTH_PAGE_FOOTER_TOS: "TOS", + }, + hu: { + AUTH_PAGE_FOOTER_TOS: "ÁSZF", + }, }, }, - }, - getRedirectionURL: (context) => { - if (context.action === "SUCCESS") { - let logId = { - emailpassword: "EMAIL_PASSWORD", - thirdparty: "THIRD_PARTY", - passwordless: "PASSWORDLESS", - }[context.recipeId]; - - console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`); - setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser); - if (testContext.disableRedirectionAfterSuccessfulSignInUp) { - return null; + getRedirectionURL: (context) => { + if (context.action === "SUCCESS") { + let logId = { + emailpassword: "EMAIL_PASSWORD", + thirdparty: "THIRD_PARTY", + passwordless: "PASSWORDLESS", + }[context.recipeId]; + + console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`); + setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser); + if (testContext.disableRedirectionAfterSuccessfulSignInUp) { + return null; + } + return context.redirectToPath || "/dashboard"; + } else { + console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`); } - return context.redirectToPath || "/dashboard"; - } else { - console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`); - } - }, - useShadowDom, - privacyPolicyLink: "https://supertokens.com/legal/privacy-policy", - termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions", - defaultToSignUp, - disableAuthRoute: testContext.disableDefaultUI, - recipeList, -}); + }, + useShadowDom, + privacyPolicyLink: "https://supertokens.com/legal/privacy-policy", + termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions", + defaultToSignUp, + disableAuthRoute: testContext.disableDefaultUI, + recipeList, + }); +} /* App */ function App() { diff --git a/examples/for-tests/src/App.js b/examples/for-tests/src/App.js index 71c1d7ea3..53353cc73 100644 --- a/examples/for-tests/src/App.js +++ b/examples/for-tests/src/App.js @@ -439,55 +439,56 @@ if (testContext.enableMFA) { }) ); } - -SuperTokens.init({ - usesDynamicLoginMethods: testContext.usesDynamicLoginMethods, - clientType: testContext.clientType, - enableDebugLogs: true, - appInfo: { - appName: "SuperTokens", - websiteDomain: getWebsiteDomain(), - apiDomain: getApiDomain(), - websiteBasePath, - }, - languageTranslations: { - translations: { - en: { - AUTH_PAGE_FOOTER_TOS: "TOS", - }, - hu: { - AUTH_PAGE_FOOTER_TOS: "ÁSZF", +if (!window.location.pathname.startsWith("/mockProvider")) { + SuperTokens.init({ + usesDynamicLoginMethods: testContext.usesDynamicLoginMethods, + clientType: testContext.clientType, + enableDebugLogs: true, + appInfo: { + appName: "SuperTokens", + websiteDomain: getWebsiteDomain(), + apiDomain: getApiDomain(), + websiteBasePath, + }, + languageTranslations: { + translations: { + en: { + AUTH_PAGE_FOOTER_TOS: "TOS", + }, + hu: { + AUTH_PAGE_FOOTER_TOS: "ÁSZF", + }, }, }, - }, - getRedirectionURL: (context) => { - if (context.action === "SUCCESS") { - let logId = { - emailpassword: "EMAIL_PASSWORD", - thirdparty: "THIRD_PARTY", - passwordless: "PASSWORDLESS", - thirdpartypasswordless: "THIRDPARTYPASSWORDLESS", - thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD", - }[context.recipeId]; - - console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`); - setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser); - if (testContext.disableRedirectionAfterSuccessfulSignInUp) { - return null; + getRedirectionURL: (context) => { + if (context.action === "SUCCESS") { + let logId = { + emailpassword: "EMAIL_PASSWORD", + thirdparty: "THIRD_PARTY", + passwordless: "PASSWORDLESS", + thirdpartypasswordless: "THIRDPARTYPASSWORDLESS", + thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD", + }[context.recipeId]; + + console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`); + setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser); + if (testContext.disableRedirectionAfterSuccessfulSignInUp) { + return null; + } + console.log(JSON.stringify(context)); + return context.redirectToPath || "/dashboard"; + } else { + console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`); } - console.log(JSON.stringify(context)); - return context.redirectToPath || "/dashboard"; - } else { - console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`); - } - }, - useShadowDom, - privacyPolicyLink: "https://supertokens.com/legal/privacy-policy", - termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions", - defaultToSignUp, - disableAuthRoute: testContext.disableDefaultUI, - recipeList, -}); + }, + useShadowDom, + privacyPolicyLink: "https://supertokens.com/legal/privacy-policy", + termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions", + defaultToSignUp, + disableAuthRoute: testContext.disableDefaultUI, + recipeList, + }); +} /* App */ function App() { diff --git a/test/end-to-end/thirdparty.test.js b/test/end-to-end/thirdparty.test.js index 4a659ea70..0a2d131ef 100644 --- a/test/end-to-end/thirdparty.test.js +++ b/test/end-to-end/thirdparty.test.js @@ -272,10 +272,7 @@ export function getThirdPartyTestCases({ authRecipe, rid, signInUpPageLoadLogs, it("should work with custom getRedirectUrl", async function () { await page.evaluate((TEST_CLIENT_BASE_URL) => { - localStorage.setItem( - "thirdPartyRedirectURL", - `${TEST_CLIENT_BASE_URL}/auth/mock-provider-custom-redirect` - ); + localStorage.setItem("thirdPartyRedirectURL", `${TEST_CLIENT_BASE_URL}/auth/auth0-custom-redirect`); }, TEST_CLIENT_BASE_URL); await Promise.all([ @@ -283,10 +280,10 @@ export function getThirdPartyTestCases({ authRecipe, rid, signInUpPageLoadLogs, page.waitForNavigation({ waitUntil: "networkidle0" }), ]); await assertProviders(page); - await clickOnProviderButton(page, "Mock Provider"); - await loginWithMockProvider(page); + await clickOnProviderButton(page, "Auth0"); + await loginWithAuth0(page); - await waitForUrl(page, "/auth/mock-provider-custom-redirect"); + await waitForUrl(page, "/auth/auth0-custom-redirect"); }); // it("Successful signin with facebook", async function () { diff --git a/test/helpers.js b/test/helpers.js index b672e0c50..2473c15a1 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -630,6 +630,7 @@ export async function loginWithMockProvider( userId = "123", isVerified = true ) { + const url = new URL(page.url()); await Promise.all([ page.goto( `${TEST_CLIENT_BASE_URL}/auth/callback/mock-provider?code=asdf&email=${encodeURIComponent( @@ -639,7 +640,6 @@ export async function loginWithMockProvider( page.waitForNavigation({ waitUntil: "networkidle0" }), ]); } -loginWithMockProvider; export async function loginWithAuth0(page) { await page.focus("input[type=email]");