Skip to content

Commit bb2252d

Browse files
committed
test: switch to mock provider (#866)
* test: switch most thirdparty test to use mock provider * test: fix test errors
1 parent 7501c03 commit bb2252d

File tree

11 files changed

+163
-139
lines changed

11 files changed

+163
-139
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: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -449,53 +449,55 @@ if (testContext.enableMFA) {
449449
);
450450
}
451451

452-
SuperTokens.init({
453-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
454-
clientType: testContext.clientType,
455-
appInfo: {
456-
appName: "SuperTokens",
457-
websiteDomain: getWebsiteDomain(),
458-
apiDomain: getApiDomain(),
459-
websiteBasePath,
460-
},
461-
languageTranslations: {
462-
translations: {
463-
en: {
464-
AUTH_PAGE_FOOTER_TOS: "TOS",
465-
},
466-
hu: {
467-
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
452+
if (!window.location.pathname.startsWith("/mockProvider")) {
453+
SuperTokens.init({
454+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
455+
clientType: testContext.clientType,
456+
appInfo: {
457+
appName: "SuperTokens",
458+
websiteDomain: getWebsiteDomain(),
459+
apiDomain: getApiDomain(),
460+
websiteBasePath,
461+
},
462+
languageTranslations: {
463+
translations: {
464+
en: {
465+
AUTH_PAGE_FOOTER_TOS: "TOS",
466+
},
467+
hu: {
468+
AUTH_PAGE_FOOTER_TOS: "ÁSZF",
469+
},
468470
},
469471
},
470-
},
471-
getRedirectionURL: (context) => {
472-
if (context.action === "SUCCESS") {
473-
let logId = {
474-
emailpassword: "EMAIL_PASSWORD",
475-
thirdparty: "THIRD_PARTY",
476-
passwordless: "PASSWORDLESS",
477-
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
478-
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
479-
}[context.recipeId];
480-
481-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
482-
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
483-
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
484-
return null;
472+
getRedirectionURL: (context) => {
473+
if (context.action === "SUCCESS") {
474+
let logId = {
475+
emailpassword: "EMAIL_PASSWORD",
476+
thirdparty: "THIRD_PARTY",
477+
passwordless: "PASSWORDLESS",
478+
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
479+
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
480+
}[context.recipeId];
481+
482+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
483+
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
484+
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
485+
return null;
486+
}
487+
console.log(JSON.stringify(context));
488+
return context.redirectToPath || "/dashboard";
489+
} else {
490+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
485491
}
486-
console.log(JSON.stringify(context));
487-
return context.redirectToPath || "/dashboard";
488-
} else {
489-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
490-
}
491-
},
492-
useShadowDom,
493-
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
494-
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
495-
defaultToSignUp,
496-
disableAuthRoute: testContext.disableDefaultUI,
497-
recipeList,
498-
});
492+
},
493+
useShadowDom,
494+
privacyPolicyLink: "https://supertokens.com/legal/privacy-policy",
495+
termsOfServiceLink: "https://supertokens.com/legal/terms-and-conditions",
496+
defaultToSignUp,
497+
disableAuthRoute: testContext.disableDefaultUI,
498+
recipeList,
499+
});
500+
}
499501

500502
/* App */
501503
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,
@@ -411,7 +411,7 @@ function getThirdPartyTests(rid, ridForStorage) {
411411
await assertProviders(page);
412412

413413
let [_, response1] = await Promise.all([
414-
clickOnProviderButtonWithoutWaiting(page, "Auth0"),
414+
clickOnProviderButtonWithoutWaiting(page, "Mock Provider"),
415415
page.waitForResponse(
416416
(response) =>
417417
response.url().includes(GET_AUTH_URL_API) &&
@@ -436,10 +436,10 @@ function getThirdPartyTests(rid, ridForStorage) {
436436

437437
await page.goto(`${TEST_CLIENT_BASE_URL}/auth`);
438438
await assertProviders(page);
439-
await clickOnProviderButton(page, "Auth0");
439+
await clickOnProviderButton(page, "Mock Provider");
440440

441441
let [_, response1] = await Promise.all([
442-
loginWithAuth0(page),
442+
loginWithMockProvider(page),
443443
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
444444
]);
445445

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,
@@ -119,9 +119,9 @@ describe("getRedirectionURL Tests", function () {
119119
page.waitForNavigation({ waitUntil: "networkidle0" }),
120120
]);
121121
await assertProviders(page);
122-
await clickOnProviderButton(page, "Auth0");
122+
await clickOnProviderButton(page, "Mock Provider");
123123
await Promise.all([
124-
loginWithAuth0(page),
124+
loginWithMockProvider(page),
125125
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
126126
]);
127127
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -178,9 +178,9 @@ describe("getRedirectionURL Tests", function () {
178178

179179
it("Test that isNewRecipeUser works correctly when signing up with auth 0", async function () {
180180
await assertProviders(page);
181-
await clickOnProviderButton(page, "Auth0");
181+
await clickOnProviderButton(page, "Mock Provider");
182182
await Promise.all([
183-
loginWithAuth0(page),
183+
loginWithMockProvider(page),
184184
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
185185
]);
186186
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -368,9 +368,9 @@ describe("getRedirectionURL Tests", function () {
368368
page.waitForNavigation({ waitUntil: "networkidle0" }),
369369
]);
370370
await assertProviders(page);
371-
await clickOnProviderButton(page, "Auth0");
371+
await clickOnProviderButton(page, "Mock Provider");
372372
await Promise.all([
373-
loginWithAuth0(page),
373+
loginWithMockProvider(page),
374374
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
375375
]);
376376
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -668,10 +668,10 @@ describe("getRedirectionURL Tests", function () {
668668
]);
669669

670670
await assertProviders(page);
671-
await clickOnProviderButton(page, "Auth0");
671+
await clickOnProviderButton(page, "Mock Provider");
672672

673673
await Promise.all([
674-
loginWithAuth0(page),
674+
loginWithMockProvider(page),
675675
page.waitForResponse(
676676
(response) => response.url() === SIGN_IN_UP_API && response.status() === 200
677677
),
@@ -680,7 +680,7 @@ describe("getRedirectionURL Tests", function () {
680680
const urlAfterSignUp = await page.url();
681681
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
682682
assert.equal(newUserCheck, "thirdparty-true");
683-
assert(urlAfterSignUp.includes("/auth/callback/auth0"));
683+
assert(urlAfterSignUp.includes("/auth/callback/mock-provider"));
684684
});
685685
});
686686
});

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,12 +34,13 @@ import {
3434
loginWithGoogle,
3535
clearBrowserCookiesWithoutAffectingConsole,
3636
clickOnProviderButton,
37-
loginWithAuth0,
37+
loginWithMockProvider,
3838
isMultitenancySupported,
3939
isMultitenancyManagementEndpointsSupported,
4040
setupTenant,
4141
backendBeforeEach,
4242
getTextByDataSupertokens,
43+
loginWithAuth0,
4344
} from "../helpers";
4445
import {
4546
TEST_CLIENT_BASE_URL,

0 commit comments

Comments
 (0)