Skip to content

Commit 79948d9

Browse files
authored
test: switch to mock provider (#866)
* test: switch most thirdparty test to use mock provider * test: fix test errors
1 parent bfe9f61 commit 79948d9

File tree

11 files changed

+164
-141
lines changed

11 files changed

+164
-141
lines changed

examples/for-tests-react-16/src/App.js

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -272,50 +272,52 @@ if (testContext.enableMFA) {
272272
);
273273
}
274274

275-
SuperTokens.init({
276-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
277-
clientType: testContext.clientType,
278-
appInfo: {
279-
appName: "SuperTokens",
280-
websiteDomain: getWebsiteDomain(),
281-
apiDomain: getApiDomain(),
282-
websiteBasePath,
283-
},
284-
languageTranslations: {
285-
translations: {
286-
en: {
287-
AUTH_PAGE_FOOTER_TOS: "TOS",
288-
},
289-
hu: {
290-
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
275+
if (!window.location.pathname.startsWith("/mockProvider")) {
276+
SuperTokens.init({
277+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
278+
clientType: testContext.clientType,
279+
appInfo: {
280+
appName: "SuperTokens",
281+
websiteDomain: getWebsiteDomain(),
282+
apiDomain: getApiDomain(),
283+
websiteBasePath,
284+
},
285+
languageTranslations: {
286+
translations: {
287+
en: {
288+
AUTH_PAGE_FOOTER_TOS: "TOS",
289+
},
290+
hu: {
291+
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
292+
},
291293
},
292294
},
293-
},
294-
getRedirectionURL: (context) => {
295-
if (context.action === "SUCCESS") {
296-
let logId = {
297-
emailpassword: "EMAIL_PASSWORD",
298-
thirdparty: "THIRD_PARTY",
299-
passwordless: "PASSWORDLESS",
300-
}[context.recipeId];
301-
302-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
303-
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
304-
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
305-
return null;
295+
getRedirectionURL: (context) => {
296+
if (context.action === "SUCCESS") {
297+
let logId = {
298+
emailpassword: "EMAIL_PASSWORD",
299+
thirdparty: "THIRD_PARTY",
300+
passwordless: "PASSWORDLESS",
301+
}[context.recipeId];
302+
303+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
304+
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
305+
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
306+
return null;
307+
}
308+
return context.redirectToPath || "/dashboard";
309+
} else {
310+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
306311
}
307-
return context.redirectToPath || "/dashboard";
308-
} else {
309-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
310-
}
311-
},
312-
useShadowDom,
313-
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
314-
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
315-
defaultToSignUp,
316-
disableAuthRoute: testContext.disableDefaultUI,
317-
recipeList,
318-
});
312+
},
313+
useShadowDom,
314+
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
315+
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
316+
defaultToSignUp,
317+
disableAuthRoute: testContext.disableDefaultUI,
318+
recipeList,
319+
});
320+
}
319321

320322
/* App */
321323
function App() {

examples/for-tests/src/App.js

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -439,55 +439,56 @@ if (testContext.enableMFA) {
439439
})
440440
);
441441
}
442-
443-
SuperTokens.init({
444-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
445-
clientType: testContext.clientType,
446-
enableDebugLogs: true,
447-
appInfo: {
448-
appName: "SuperTokens",
449-
websiteDomain: getWebsiteDomain(),
450-
apiDomain: getApiDomain(),
451-
websiteBasePath,
452-
},
453-
languageTranslations: {
454-
translations: {
455-
en: {
456-
AUTH_PAGE_FOOTER_TOS: "TOS",
457-
},
458-
hu: {
459-
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
442+
if (!window.location.pathname.startsWith("/mockProvider")) {
443+
SuperTokens.init({
444+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
445+
clientType: testContext.clientType,
446+
enableDebugLogs: true,
447+
appInfo: {
448+
appName: "SuperTokens",
449+
websiteDomain: getWebsiteDomain(),
450+
apiDomain: getApiDomain(),
451+
websiteBasePath,
452+
},
453+
languageTranslations: {
454+
translations: {
455+
en: {
456+
AUTH_PAGE_FOOTER_TOS: "TOS",
457+
},
458+
hu: {
459+
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
460+
},
460461
},
461462
},
462-
},
463-
getRedirectionURL: (context) => {
464-
if (context.action === "SUCCESS") {
465-
let logId = {
466-
emailpassword: "EMAIL_PASSWORD",
467-
thirdparty: "THIRD_PARTY",
468-
passwordless: "PASSWORDLESS",
469-
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
470-
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
471-
}[context.recipeId];
472-
473-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
474-
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
475-
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
476-
return null;
463+
getRedirectionURL: (context) => {
464+
if (context.action === "SUCCESS") {
465+
let logId = {
466+
emailpassword: "EMAIL_PASSWORD",
467+
thirdparty: "THIRD_PARTY",
468+
passwordless: "PASSWORDLESS",
469+
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
470+
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
471+
}[context.recipeId];
472+
473+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
474+
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
475+
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
476+
return null;
477+
}
478+
console.log(JSON.stringify(context));
479+
return context.redirectToPath || "/dashboard";
480+
} else {
481+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
477482
}
478-
console.log(JSON.stringify(context));
479-
return context.redirectToPath || "/dashboard";
480-
} else {
481-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
482-
}
483-
},
484-
useShadowDom,
485-
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
486-
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
487-
defaultToSignUp,
488-
disableAuthRoute: testContext.disableDefaultUI,
489-
recipeList,
490-
});
483+
},
484+
useShadowDom,
485+
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
486+
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
487+
defaultToSignUp,
488+
disableAuthRoute: testContext.disableDefaultUI,
489+
recipeList,
490+
});
491+
}
491492

492493
/* App */
493494
function App() {

test/end-to-end/generalerror.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
assertProviders,
3838
clickOnProviderButton,
3939
clickOnProviderButtonWithoutWaiting,
40-
loginWithAuth0,
40+
loginWithMockProvider,
4141
isGeneralErrorSupported,
4242
setGeneralErrorToLocalStorage,
4343
backendBeforeEach,
@@ -403,7 +403,7 @@ function getThirdPartyTests(rid, ridForStorage) {
403403
await assertProviders(page);
404404

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

429429
await page.goto(`${TEST_CLIENT_BASE_URL}/auth`);
430430
await assertProviders(page);
431-
await clickOnProviderButton(page, "Auth0");
431+
await clickOnProviderButton(page, "Mock Provider");
432432

433433
let [_, response1] = await Promise.all([
434-
loginWithAuth0(page),
434+
loginWithMockProvider(page),
435435
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
436436
]);
437437

test/end-to-end/getRedirectionURL.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
screenshotOnFailure,
88
assertProviders,
99
clickOnProviderButton,
10-
loginWithAuth0,
10+
loginWithMockProvider,
1111
setPasswordlessFlowType,
1212
waitForSTElement,
1313
getPasswordlessDevice,
@@ -114,9 +114,9 @@ describe("getRedirectionURL Tests", function () {
114114
page.waitForNavigation({ waitUntil: "networkidle0" }),
115115
]);
116116
await assertProviders(page);
117-
await clickOnProviderButton(page, "Auth0");
117+
await clickOnProviderButton(page, "Mock Provider");
118118
await Promise.all([
119-
loginWithAuth0(page),
119+
loginWithMockProvider(page),
120120
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
121121
]);
122122
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -170,9 +170,9 @@ describe("getRedirectionURL Tests", function () {
170170

171171
it("Test that isNewRecipeUser works correctly when signing up with auth 0", async function () {
172172
await assertProviders(page);
173-
await clickOnProviderButton(page, "Auth0");
173+
await clickOnProviderButton(page, "Mock Provider");
174174
await Promise.all([
175-
loginWithAuth0(page),
175+
loginWithMockProvider(page),
176176
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
177177
]);
178178
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -354,9 +354,9 @@ describe("getRedirectionURL Tests", function () {
354354
page.waitForNavigation({ waitUntil: "networkidle0" }),
355355
]);
356356
await assertProviders(page);
357-
await clickOnProviderButton(page, "Auth0");
357+
await clickOnProviderButton(page, "Mock Provider");
358358
await Promise.all([
359-
loginWithAuth0(page),
359+
loginWithMockProvider(page),
360360
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
361361
]);
362362
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -642,10 +642,10 @@ describe("getRedirectionURL Tests", function () {
642642
]);
643643

644644
await assertProviders(page);
645-
await clickOnProviderButton(page, "Auth0");
645+
await clickOnProviderButton(page, "Mock Provider");
646646

647647
await Promise.all([
648-
loginWithAuth0(page),
648+
loginWithMockProvider(page),
649649
page.waitForResponse(
650650
(response) => response.url() === SIGN_IN_UP_API && response.status() === 200
651651
),
@@ -654,7 +654,7 @@ describe("getRedirectionURL Tests", function () {
654654
const urlAfterSignUp = await page.url();
655655
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
656656
assert.equal(newUserCheck, "thirdparty-true");
657-
assert(urlAfterSignUp.includes("/auth/callback/auth0"));
657+
assert(urlAfterSignUp.includes("/auth/callback/mock-provider"));
658658
});
659659
});
660660
});

test/end-to-end/multitenancy.dynamic_login_methods.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ import {
3434
loginWithGoogle,
3535
clearBrowserCookiesWithoutAffectingConsole,
3636
clickOnProviderButton,
37-
loginWithAuth0,
37+
loginWithMockProvider,
3838
isMultitenancySupported,
3939
isMultitenancyManagementEndpointsSupported,
4040
setupTenant,
4141
backendBeforeEach,
4242
getTextByDataSupertokens,
4343
setupBrowser,
44+
loginWithAuth0,
4445
} from "../helpers";
4546
import {
4647
TEST_CLIENT_BASE_URL,

0 commit comments

Comments
 (0)