Skip to content

Commit 26097c2

Browse files
committed
test: switch to mock provider (#866)
* test: switch most thirdparty test to use mock provider * test: fix test errors
1 parent 42a5746 commit 26097c2

File tree

11 files changed

+155
-131
lines changed

11 files changed

+155
-131
lines changed

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

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -283,47 +283,49 @@ if (testContext.enableMFA) {
283283
);
284284
}
285285

286-
SuperTokens.init({
287-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
288-
clientType: testContext.clientType,
289-
appInfo: {
290-
appName: "SuperTokens",
291-
websiteDomain: getWebsiteDomain(),
292-
apiDomain: getApiDomain(),
293-
websiteBasePath,
294-
},
295-
languageTranslations: {
296-
translations: {
297-
en: {
298-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
299-
},
300-
hu: {
301-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
286+
if (!window.location.pathname.startsWith("/mockProvider")) {
287+
SuperTokens.init({
288+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
289+
clientType: testContext.clientType,
290+
appInfo: {
291+
appName: "SuperTokens",
292+
websiteDomain: getWebsiteDomain(),
293+
apiDomain: getApiDomain(),
294+
websiteBasePath,
295+
},
296+
languageTranslations: {
297+
translations: {
298+
en: {
299+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
300+
},
301+
hu: {
302+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
303+
},
302304
},
303305
},
304-
},
305-
getRedirectionURL: (context) => {
306-
if (context.action === "SUCCESS") {
307-
let logId = {
308-
emailpassword: "EMAIL_PASSWORD",
309-
thirdparty: "THIRD_PARTY",
310-
passwordless: "PASSWORDLESS",
311-
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
312-
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
313-
}[context.recipeId];
314-
315-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
316-
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
317-
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
318-
return null;
306+
getRedirectionURL: (context) => {
307+
if (context.action === "SUCCESS") {
308+
let logId = {
309+
emailpassword: "EMAIL_PASSWORD",
310+
thirdparty: "THIRD_PARTY",
311+
passwordless: "PASSWORDLESS",
312+
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
313+
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
314+
}[context.recipeId];
315+
316+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
317+
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
318+
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
319+
return null;
320+
}
321+
return context.redirectToPath || "/dashboard";
322+
} else {
323+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
319324
}
320-
return context.redirectToPath || "/dashboard";
321-
} else {
322-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
323-
}
324-
},
325-
recipeList,
326-
});
325+
},
326+
recipeList,
327+
});
328+
}
327329

328330
/* App */
329331
function App() {

examples/for-tests/src/App.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -459,48 +459,50 @@ if (testContext.enableMFA) {
459459
);
460460
}
461461

462-
SuperTokens.init({
463-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
464-
clientType: testContext.clientType,
465-
appInfo: {
466-
appName: "SuperTokens",
467-
websiteDomain: getWebsiteDomain(),
468-
apiDomain: getApiDomain(),
469-
websiteBasePath,
470-
},
471-
languageTranslations: {
472-
translations: {
473-
en: {
474-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
475-
},
476-
hu: {
477-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
462+
if (!window.location.pathname.startsWith("/mockProvider")) {
463+
SuperTokens.init({
464+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
465+
clientType: testContext.clientType,
466+
appInfo: {
467+
appName: "SuperTokens",
468+
websiteDomain: getWebsiteDomain(),
469+
apiDomain: getApiDomain(),
470+
websiteBasePath,
471+
},
472+
languageTranslations: {
473+
translations: {
474+
en: {
475+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
476+
},
477+
hu: {
478+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
479+
},
478480
},
479481
},
480-
},
481-
getRedirectionURL: (context) => {
482-
if (context.action === "SUCCESS") {
483-
let logId = {
484-
emailpassword: "EMAIL_PASSWORD",
485-
thirdparty: "THIRD_PARTY",
486-
passwordless: "PASSWORDLESS",
487-
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
488-
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
489-
}[context.recipeId];
490-
491-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
492-
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
493-
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
494-
return null;
482+
getRedirectionURL: (context) => {
483+
if (context.action === "SUCCESS") {
484+
let logId = {
485+
emailpassword: "EMAIL_PASSWORD",
486+
thirdparty: "THIRD_PARTY",
487+
passwordless: "PASSWORDLESS",
488+
thirdpartypasswordless: "THIRDPARTYPASSWORDLESS",
489+
thirdpartyemailpassword: "THIRD_PARTY_EMAIL_PASSWORD",
490+
}[context.recipeId];
491+
492+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL SUCCESS ${logId}`);
493+
setIsNewUserToStorage(context.recipeId, context.isNewRecipeUser);
494+
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
495+
return null;
496+
}
497+
console.log(JSON.stringify(context));
498+
return context.redirectToPath || "/dashboard";
499+
} else {
500+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
495501
}
496-
console.log(JSON.stringify(context));
497-
return context.redirectToPath || "/dashboard";
498-
} else {
499-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
500-
}
501-
},
502-
recipeList,
503-
});
502+
},
503+
recipeList,
504+
});
505+
}
504506

505507
/* App */
506508
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)