Skip to content

Commit 1b174bd

Browse files
committed
update: userContext/userroles tests use core apps
1 parent 78bd022 commit 1b174bd

File tree

2 files changed

+38
-46
lines changed

2 files changed

+38
-46
lines changed

test/end-to-end/userContext.test.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* under the License.
1414
*/
1515

16-
import puppeteer from "puppeteer";
1716
import {
1817
clearBrowserCookiesWithoutAffectingConsole,
1918
getLatestURLWithToken,
@@ -24,13 +23,15 @@ import {
2423
assertProviders,
2524
clickOnProviderButton,
2625
loginWithAuth0,
27-
backendBeforeEach,
2826
waitForUrl,
2927
setupBrowser,
28+
backendHook,
29+
setupCoreApp,
30+
setupST,
31+
screenshotOnFailure,
3032
} from "../helpers";
3133
import {
3234
TEST_CLIENT_BASE_URL,
33-
TEST_SERVER_BASE_URL,
3435
RESET_PASSWORD_TOKEN_API,
3536
RESET_PASSWORD_API,
3637
SIGN_IN_UP_API,
@@ -43,11 +44,9 @@ describe("SuperTokens userContext with UI components test", function () {
4344
let consoleLogs = [];
4445

4546
before(async function () {
46-
await backendBeforeEach();
47-
48-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
49-
method: "POST",
50-
}).catch(console.error);
47+
backendHook("before");
48+
const coreUrl = await setupCoreApp();
49+
await setupST({ coreUrl });
5150

5251
browser = await setupBrowser();
5352
page = await browser.newPage();
@@ -59,18 +58,8 @@ describe("SuperTokens userContext with UI components test", function () {
5958
});
6059
});
6160

62-
after(async function () {
63-
await browser.close();
64-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
65-
method: "POST",
66-
}).catch(console.error);
67-
68-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
69-
method: "POST",
70-
}).catch(console.error);
71-
});
72-
7361
beforeEach(async function () {
62+
await backendHook("beforeEach");
7463
consoleLogs = [];
7564
consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, consoleLogs);
7665
await Promise.all([
@@ -79,6 +68,17 @@ describe("SuperTokens userContext with UI components test", function () {
7968
]);
8069
});
8170

71+
afterEach(async function () {
72+
await screenshotOnFailure(this, browser);
73+
await backendHook("afterEach");
74+
});
75+
76+
after(async function () {
77+
await page?.close();
78+
await browser?.close();
79+
await backendHook("after");
80+
});
81+
8282
it("Test that user context gets passed correctly when resetting password", async function () {
8383
await Promise.all([
8484
page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=thirdpartyemailpassword&mode=OFF&forUserContext=true`),

test/end-to-end/userroles.test.js

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* Imports
1818
*/
1919
import assert from "assert";
20-
import puppeteer from "puppeteer";
21-
import fetch from "isomorphic-fetch";
2220
import {
2321
clearBrowserCookiesWithoutAffectingConsole,
2422
screenshotOnFailure,
@@ -30,15 +28,17 @@ import {
3028
getInvalidClaimsJSON as getInvalidClaims,
3129
waitFor,
3230
waitForText,
33-
backendBeforeEach,
3431
waitForUrl,
3532
setupBrowser,
33+
backendHook,
34+
setupCoreApp,
35+
setupST,
3636
} from "../helpers";
37-
38-
import { TEST_APPLICATION_SERVER_BASE_URL, TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL } from "../constants";
37+
import { TEST_APPLICATION_SERVER_BASE_URL, TEST_CLIENT_BASE_URL } from "../constants";
3938

4039
describe("User Roles in the frontend", function () {
4140
before(async function () {
41+
backendHook("before");
4242
const isRolesSupported = await isUserRolesSupported();
4343
if (!isRolesSupported) {
4444
this.skip();
@@ -49,11 +49,8 @@ describe("User Roles in the frontend", function () {
4949
let browser;
5050
let page;
5151
before(async function () {
52-
await backendBeforeEach();
53-
54-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
55-
method: "POST",
56-
}).catch(console.error);
52+
const coreUrl = await setupCoreApp();
53+
await setupST({ coreUrl });
5754

5855
browser = await setupBrowser();
5956
page = await browser.newPage();
@@ -66,24 +63,8 @@ describe("User Roles in the frontend", function () {
6663
await page.close();
6764
});
6865

69-
after(async function () {
70-
await browser.close();
71-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
72-
method: "POST",
73-
}).catch(console.error);
74-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
75-
method: "POST",
76-
}).catch(console.error);
77-
});
78-
79-
afterEach(async function () {
80-
await screenshotOnFailure(this, browser);
81-
if (page) {
82-
page.close();
83-
}
84-
});
85-
8666
beforeEach(async function () {
67+
backendHook("beforeEach");
8768
page = await browser.newPage();
8869
await clearBrowserCookiesWithoutAffectingConsole(page, []);
8970

@@ -100,6 +81,17 @@ describe("User Roles in the frontend", function () {
10081
await page.waitForSelector(".sessionInfo-user-id");
10182
});
10283

84+
afterEach(async function () {
85+
await screenshotOnFailure(this, browser);
86+
await page?.close();
87+
await backendHook("afterEach");
88+
});
89+
90+
after(async function () {
91+
await browser?.close();
92+
await backendHook("after");
93+
});
94+
10395
it("should be able to read in the frontend", async () => {
10496
assert.deepStrictEqual(
10597
await page.evaluate(() =>

0 commit comments

Comments
 (0)