Skip to content
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

test: switch to mock provider #866

Merged
merged 2 commits into from
Nov 25, 2024
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
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
8 changes: 4 additions & 4 deletions test/end-to-end/generalerror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
assertProviders,
clickOnProviderButton,
clickOnProviderButtonWithoutWaiting,
loginWithAuth0,
loginWithMockProvider,
isGeneralErrorSupported,
setGeneralErrorToLocalStorage,
backendBeforeEach,
Expand Down Expand Up @@ -403,7 +403,7 @@ function getThirdPartyTests(rid, ridForStorage) {
await assertProviders(page);

let [_, response1] = await Promise.all([
clickOnProviderButtonWithoutWaiting(page, "Auth0"),
clickOnProviderButtonWithoutWaiting(page, "Mock Provider"),
page.waitForResponse(
(response) =>
response.url().includes(GET_AUTH_URL_API) &&
Expand All @@ -428,10 +428,10 @@ function getThirdPartyTests(rid, ridForStorage) {

await page.goto(`${TEST_CLIENT_BASE_URL}/auth`);
await assertProviders(page);
await clickOnProviderButton(page, "Auth0");
await clickOnProviderButton(page, "Mock Provider");

let [_, response1] = await Promise.all([
loginWithAuth0(page),
loginWithMockProvider(page),
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
]);

Expand Down
20 changes: 10 additions & 10 deletions test/end-to-end/getRedirectionURL.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
screenshotOnFailure,
assertProviders,
clickOnProviderButton,
loginWithAuth0,
loginWithMockProvider,
setPasswordlessFlowType,
waitForSTElement,
getPasswordlessDevice,
Expand Down Expand Up @@ -114,9 +114,9 @@ describe("getRedirectionURL Tests", function () {
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
await assertProviders(page);
await clickOnProviderButton(page, "Auth0");
await clickOnProviderButton(page, "Mock Provider");
await Promise.all([
loginWithAuth0(page),
loginWithMockProvider(page),
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
]);
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
Expand Down Expand Up @@ -170,9 +170,9 @@ describe("getRedirectionURL Tests", function () {

it("Test that isNewRecipeUser works correctly when signing up with auth 0", async function () {
await assertProviders(page);
await clickOnProviderButton(page, "Auth0");
await clickOnProviderButton(page, "Mock Provider");
await Promise.all([
loginWithAuth0(page),
loginWithMockProvider(page),
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
]);
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
Expand Down Expand Up @@ -354,9 +354,9 @@ describe("getRedirectionURL Tests", function () {
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
await assertProviders(page);
await clickOnProviderButton(page, "Auth0");
await clickOnProviderButton(page, "Mock Provider");
await Promise.all([
loginWithAuth0(page),
loginWithMockProvider(page),
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
]);
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
Expand Down Expand Up @@ -642,10 +642,10 @@ describe("getRedirectionURL Tests", function () {
]);

await assertProviders(page);
await clickOnProviderButton(page, "Auth0");
await clickOnProviderButton(page, "Mock Provider");

await Promise.all([
loginWithAuth0(page),
loginWithMockProvider(page),
page.waitForResponse(
(response) => response.url() === SIGN_IN_UP_API && response.status() === 200
),
Expand All @@ -654,7 +654,7 @@ describe("getRedirectionURL Tests", function () {
const urlAfterSignUp = await page.url();
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
assert.equal(newUserCheck, "thirdparty-true");
assert(urlAfterSignUp.includes("/auth/callback/auth0"));
assert(urlAfterSignUp.includes("/auth/callback/mock-provider"));
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/multitenancy.dynamic_login_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ import {
loginWithGoogle,
clearBrowserCookiesWithoutAffectingConsole,
clickOnProviderButton,
loginWithAuth0,
loginWithMockProvider,
isMultitenancySupported,
isMultitenancyManagementEndpointsSupported,
setupTenant,
backendBeforeEach,
getTextByDataSupertokens,
setupBrowser,
loginWithAuth0,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
Expand Down
Loading
Loading