Skip to content

Commit ced6289

Browse files
Fix all tests to ensure they pass
1 parent d86c6b9 commit ced6289

14 files changed

+11315
-36801
lines changed

package-lock.json

Lines changed: 10737 additions & 34066 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/end-to-end/emailverification.test.js

Lines changed: 69 additions & 273 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -300,22 +300,6 @@ describe("getRedirectionURL Tests", function () {
300300
after(async function () {
301301
await page?.close();
302302
});
303-
304-
it("should not do any redirection after successful sign up", async function () {
305-
await Promise.all([
306-
page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=emailpassword`),
307-
page.waitForNavigation({ waitUntil: "networkidle0" }),
308-
]);
309-
310-
await toggleSignInSignUp(page);
311-
const urlBeforeSignUp = await page.url();
312-
await defaultSignUp(page);
313-
const urlAfterSignUp = await page.url();
314-
315-
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
316-
assert.equal(newUserCheck, "emailpassword-true");
317-
assert.equal(urlBeforeSignUp, urlAfterSignUp);
318-
});
319303
});
320304

321305
describe("Passwordless recipe", function () {
@@ -357,32 +341,6 @@ describe("getRedirectionURL Tests", function () {
357341
after(async function () {
358342
await page?.close();
359343
});
360-
361-
it("should not do any redirection after successful sign up", async function () {
362-
await Promise.all([
363-
page.goto(`${TEST_CLIENT_BASE_URL}/auth`),
364-
page.waitForNavigation({ waitUntil: "networkidle0" }),
365-
]);
366-
await setInputValues(page, [{ name: "email", value: exampleEmail }]);
367-
await submitForm(page);
368-
await waitForSTElement(page, "[data-supertokens~=input][name=userInputCode]");
369-
370-
const urlBeforeSignUp = await page.url();
371-
372-
const loginAttemptInfo = JSON.parse(
373-
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
374-
);
375-
const device = await getPasswordlessDevice(loginAttemptInfo);
376-
await setInputValues(page, [{ name: "userInputCode", value: device.codes[0].userInputCode }]);
377-
await submitForm(page);
378-
// wait until network idle to ensure that the page has not been redirected
379-
await page.waitForNetworkIdle();
380-
381-
const urlAfterSignUp = await page.url();
382-
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
383-
assert.equal(newUserCheck, "passwordless-true");
384-
assert.equal(urlBeforeSignUp, urlAfterSignUp);
385-
});
386344
});
387345

388346
describe("ThirdPartyPasswordless recipe: Magic Link", function () {
@@ -425,31 +383,6 @@ describe("getRedirectionURL Tests", function () {
425383
after(async function () {
426384
await page?.close();
427385
});
428-
429-
it("should not do any redirection after successful sign up", async function () {
430-
await Promise.all([
431-
page.goto(`${TEST_CLIENT_BASE_URL}/auth`),
432-
page.waitForNavigation({ waitUntil: "networkidle0" }),
433-
]);
434-
await setInputValues(page, [{ name: "email", value: exampleEmail }]);
435-
await submitForm(page);
436-
await waitForSTElement(page, "[data-supertokens~=sendCodeIcon]");
437-
438-
const loginAttemptInfo = JSON.parse(
439-
await page.evaluate(() => localStorage.getItem("supertokens-passwordless-loginAttemptInfo"))
440-
);
441-
const device = await getPasswordlessDevice(loginAttemptInfo);
442-
443-
const magicLink = device.codes[0].urlWithLinkCode;
444-
445-
await page.goto(magicLink);
446-
await page.waitForNetworkIdle();
447-
448-
const urlAfterSignUp = await page.url();
449-
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
450-
assert.equal(newUserCheck, "thirdpartypasswordless-true");
451-
assert.equal(magicLink, urlAfterSignUp);
452-
});
453386
});
454387

455388
describe("ThirdParty Recipe", function () {
@@ -470,28 +403,6 @@ describe("getRedirectionURL Tests", function () {
470403
after(async function () {
471404
await page?.close();
472405
});
473-
474-
it("should not do any redirection after successful sign up", async function () {
475-
await Promise.all([
476-
page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=thirdparty`),
477-
page.waitForNavigation({ waitUntil: "networkidle0" }),
478-
]);
479-
480-
await assertProviders(page);
481-
await clickOnProviderButton(page, "Mock Provider");
482-
483-
await Promise.all([
484-
loginWithMockProvider(page),
485-
page.waitForResponse(
486-
(response) => response.url() === SIGN_IN_UP_API && response.status() === 200
487-
),
488-
]);
489-
490-
const urlAfterSignUp = await page.url();
491-
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
492-
assert.equal(newUserCheck, "thirdparty-true");
493-
assert(urlAfterSignUp.includes("/auth/callback/mock-provider"));
494-
});
495406
});
496407
});
497408
});

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

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ import {
3535
clickOnProviderButton,
3636
loginWithMockProvider,
3737
isMultitenancySupported,
38-
isMultitenancyManagementEndpointsSupported,
3938
setupTenant,
4039
getTextByDataSupertokens,
4140
loginWithAuth0,
4241
setupCoreApp,
4342
setupST,
4443
backendHook,
4544
setupBrowser,
45+
isAccountLinkingSupported,
4646
} from "../helpers";
4747
import {
4848
TEST_CLIENT_BASE_URL,
@@ -63,7 +63,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
6363

6464
before(async function () {
6565
await backendHook("before");
66-
const isSupported = (await isMultitenancySupported()) && (await isMultitenancyManagementEndpointsSupported());
66+
const isSupported = (await isMultitenancySupported());
6767
if (!isSupported) {
6868
this.skip();
6969
}
@@ -122,7 +122,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
122122
"Continue with Google",
123123
"Continue with Facebook",
124124
"Continue with Auth0",
125-
...((await isAccountLinkingSupported()) ? ["Continue with Mock Provider"] : []),
125+
"Continue with Mock Provider",
126126
]);
127127
const inputNames = await getInputNames(page);
128128
assert.deepStrictEqual(inputNames, ["email", "password"]);
@@ -378,7 +378,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
378378
"Continue with Google",
379379
"Continue with Facebook",
380380
"Continue with Auth0",
381-
...((await isAccountLinkingSupported()) ? ["Continue with Mock Provider"] : []),
381+
"Continue with Mock Provider",
382382
]);
383383
assert.strictEqual(await getProviderLogoCount(page), 3);
384384
});
@@ -958,50 +958,6 @@ function clearDynamicLoginMethodsSettings(page) {
958958
});
959959
}
960960

961-
export async function enableDynamicLoginMethods(page, mockLoginMethods, tenantId = "public", app = "public") {
962-
let coreResp = await fetch(`http://localhost:9000/appid-${app}/recipe/multitenancy/tenant`, {
963-
method: "PUT",
964-
headers: new Headers([
965-
["content-type", "application/json"],
966-
["rid", "multitenancy"],
967-
["cdi-version", "3.0"],
968-
]),
969-
body: JSON.stringify({
970-
tenantId,
971-
emailPasswordEnabled: mockLoginMethods.emailPassword?.enabled === true,
972-
thirdPartyEnabled: mockLoginMethods.thirdParty?.enabled === true,
973-
passwordlessEnabled: mockLoginMethods.passwordless?.enabled === true,
974-
coreConfig: {},
975-
}),
976-
});
977-
assert.strictEqual(coreResp.status, 200);
978-
979-
for (const provider of mockLoginMethods["thirdParty"]?.providers) {
980-
coreResp = await fetch(`http://localhost:9000/appid-${app}/${tenantId}/recipe/multitenancy/config/thirdparty`, {
981-
method: "PUT",
982-
headers: new Headers([
983-
["content-type", "application/json"],
984-
["rid", "multitenancy"],
985-
["cdi-version", "3.0"],
986-
]),
987-
body: JSON.stringify({
988-
skipValidation: true,
989-
config: {
990-
...providerConfigs[provider.id.split("-")[0]],
991-
thirdPartyId: provider.id,
992-
name: provider.name,
993-
},
994-
}),
995-
});
996-
997-
assert.strictEqual(coreResp.status, 200);
998-
}
999-
1000-
return page.evaluate(() => {
1001-
window.localStorage.setItem("usesDynamicLoginMethods", "true");
1002-
});
1003-
}
1004-
1005961
/**
1006962
*
1007963
* @param {Array<string>} actual
@@ -1074,3 +1030,11 @@ const providerConfigs = {
10741030
],
10751031
},
10761032
};
1033+
1034+
export async function enableDynamicLoginMethods(page, mockLoginMethods, tenantId = "public") {
1035+
await setupTenant(tenantId, mockLoginMethods);
1036+
1037+
return page.evaluate(() => {
1038+
window.localStorage.setItem("usesDynamicLoginMethods", "true");
1039+
});
1040+
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
setupCoreApp,
3434
setupST,
3535
isMultitenancySupported,
36-
isMultitenancyManagementEndpointsSupported,
3736
} from "../helpers";
3837
import { TEST_CLIENT_BASE_URL, DEFAULT_WEBSITE_BASE_PATH, ST_ROOT_SELECTOR } from "../constants";
3938

@@ -50,7 +49,7 @@ describe("SuperTokens Multitenancy w/ mocked login methods", function () {
5049

5150
before(async function () {
5251
await backendHook("before");
53-
const isSupported = (await isMultitenancySupported()) && (await isMultitenancyManagementEndpointsSupported());
52+
const isSupported = (await isMultitenancySupported());
5453
if (!isSupported) {
5554
this.skip();
5655
}
@@ -286,9 +285,11 @@ describe("SuperTokens Multitenancy w/ mocked login methods", function () {
286285
providers: [
287286
{
288287
id: "apple",
288+
name: "Apple",
289289
},
290290
{
291291
id: "google",
292+
name: "Google",
292293
},
293294
],
294295
},
@@ -332,9 +333,11 @@ describe("SuperTokens Multitenancy w/ mocked login methods", function () {
332333
providers: [
333334
{
334335
id: "apple",
336+
name: "Apple",
335337
},
336338
{
337339
id: "google",
340+
name: "Google",
338341
},
339342
],
340343
},
@@ -359,9 +362,11 @@ describe("SuperTokens Multitenancy w/ mocked login methods", function () {
359362
providers: [
360363
{
361364
id: "google",
365+
name: "Google",
362366
},
363367
{
364368
id: "facebook",
369+
name: "Facebook",
365370
},
366371
],
367372
},
@@ -390,6 +395,7 @@ describe("SuperTokens Multitenancy w/ mocked login methods", function () {
390395
},
391396
{
392397
id: "facebook",
398+
name: "Facebook",
393399
},
394400
],
395401
},

0 commit comments

Comments
 (0)