Skip to content

Commit fdc6220

Browse files
committed
update: oauth2provider tests use core apps
1 parent f4b5871 commit fdc6220

File tree

1 file changed

+23
-38
lines changed

1 file changed

+23
-38
lines changed

test/end-to-end/oauth2provider.test.js

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
*/
1919

2020
import assert from "assert";
21-
import puppeteer from "puppeteer";
2221
import {
2322
clearBrowserCookiesWithoutAffectingConsole,
2423
toggleSignInSignUp,
2524
screenshotOnFailure,
26-
backendBeforeEach,
2725
waitForUrl,
2826
createOAuth2Client,
2927
setOAuth2ClientInfo,
@@ -41,13 +39,12 @@ import {
4139
isOauth2Supported,
4240
setupBrowser,
4341
getGeneralError,
42+
backendHook,
43+
setupCoreApp,
44+
setupST,
4445
} from "../helpers";
45-
import fetch from "isomorphic-fetch";
46-
4746
import {
4847
TEST_CLIENT_BASE_URL,
49-
TEST_SERVER_BASE_URL,
50-
SIGN_OUT_API,
5148
TEST_APPLICATION_SERVER_BASE_URL,
5249
SOMETHING_WENT_WRONG_ERROR,
5350
} from "../constants";
@@ -63,50 +60,27 @@ describe("SuperTokens OAuth2Provider", function () {
6360
let browser;
6461
let page;
6562
let consoleLogs = [];
66-
let skipped = false;
6763

6864
before(async function () {
65+
await backendHook("before");
6966
// Skip these tests if running in React 16
7067
if (isReact16() || !(await isOauth2Supported())) {
71-
skipped = true;
7268
this.skip();
7369
}
7470

75-
await backendBeforeEach();
76-
77-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
78-
method: "POST",
79-
headers: { "content-type": "application/json" },
80-
body: JSON.stringify({
81-
coreConfig: {
82-
access_token_validity: 5, // 5 seconds
83-
},
84-
}),
85-
}).catch(console.error);
71+
const coreUrl = await setupCoreApp({
72+
coreConfig: {
73+
access_token_validity: 5, // 5 seconds
74+
},
75+
});
76+
await setupST({ coreUrl });
8677

8778
browser = await setupBrowser();
8879
});
8980

90-
after(async function () {
91-
if (skipped) {
92-
return;
93-
}
94-
await browser.close();
95-
96-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
97-
method: "POST",
98-
}).catch(console.error);
99-
100-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
101-
method: "POST",
102-
}).catch(console.error);
103-
});
104-
105-
afterEach(function () {
106-
return screenshotOnFailure(this, browser);
107-
});
108-
10981
beforeEach(async function () {
82+
await backendHook("beforeEach");
83+
11084
page = await browser.newPage();
11185
page.on("console", (consoleObj) => {
11286
const log = consoleObj.text();
@@ -117,6 +91,17 @@ describe("SuperTokens OAuth2Provider", function () {
11791
consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, []);
11892
});
11993

94+
afterEach(async function () {
95+
await screenshotOnFailure(this, browser);
96+
await page?.close();
97+
await backendHook("afterEach");
98+
});
99+
100+
after(async function () {
101+
await browser?.close();
102+
await backendHook("after");
103+
});
104+
120105
describe("Generic OAuth2 Client Library", function () {
121106
afterEach(async function () {
122107
await removeOAuth2ClientInfo(page);

0 commit comments

Comments
 (0)