Skip to content

Commit

Permalink
test: fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Nov 25, 2024
1 parent 2ee063c commit 5a10f4b
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 95 deletions.
84 changes: 43 additions & 41 deletions examples/for-tests-react-16/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
93 changes: 47 additions & 46 deletions examples/for-tests/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 4 additions & 7 deletions test/end-to-end/thirdparty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,18 @@ 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([
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=/hello`),
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 () {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -639,7 +640,6 @@ export async function loginWithMockProvider(
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
}
loginWithMockProvider;

export async function loginWithAuth0(page) {
await page.focus("input[type=email]");
Expand Down

0 comments on commit 5a10f4b

Please sign in to comment.