Skip to content

Commit 897e6e3

Browse files
committed
update: generalerror tests use core apps
1 parent 8f450e0 commit 897e6e3

File tree

1 file changed

+35
-83
lines changed

1 file changed

+35
-83
lines changed

test/end-to-end/generalerror.test.js

Lines changed: 35 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ import {
4040
loginWithAuth0,
4141
isGeneralErrorSupported,
4242
setGeneralErrorToLocalStorage,
43-
backendBeforeEach,
43+
backendHook,
44+
createCoreApp,
4445
waitForUrl,
4546
setupBrowser,
4647
} from "../helpers";
@@ -57,48 +58,53 @@ import {
5758
SIGN_IN_UP_API,
5859
} from "../constants";
5960

61+
let browser;
62+
let page;
63+
let consoleLogs;
64+
6065
describe("General error rendering", function () {
6166
before(async function () {
6267
const _isGeneralErrorSupported = await isGeneralErrorSupported();
6368
if (!_isGeneralErrorSupported) {
6469
this.skip();
6570
}
66-
});
6771

68-
describe("EmailPassword", function () {
69-
getEmailPasswordTests("emailpassword", "EMAIL_PASSWORD");
72+
await backendHook("before");
73+
browser = await setupBrowser();
7074
});
7175

72-
describe("Email verification", function () {
73-
let browser;
74-
let page;
75-
before(async function () {
76-
await backendBeforeEach();
77-
78-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
79-
method: "POST",
80-
}).catch(console.error);
81-
82-
browser = await setupBrowser();
76+
beforeEach(async function () {
77+
await backendHook("beforeEach");
78+
await createCoreApp();
79+
page = await browser.newPage();
80+
81+
consoleLogs = [];
82+
page.on("console", (consoleObj) => {
83+
const log = consoleObj.text();
84+
if (log.startsWith("ST_LOGS")) {
85+
consoleLogs.push(log);
86+
}
8387
});
88+
consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, consoleLogs);
89+
});
8490

85-
after(async function () {
86-
await browser.close();
87-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
88-
method: "POST",
89-
}).catch(console.error);
90-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
91-
method: "POST",
92-
}).catch(console.error);
93-
});
91+
afterEach(async function () {
92+
await screenshotOnFailure(this, browser);
93+
await page?.close();
94+
await backendHook("afterEach");
95+
});
9496

95-
afterEach(function () {
96-
return screenshotOnFailure(this, browser);
97-
});
97+
after(async function () {
98+
await browser?.close();
99+
await backendHook("after");
100+
});
101+
102+
describe("EmailPassword", function () {
103+
getEmailPasswordTests("emailpassword", "EMAIL_PASSWORD");
104+
});
98105

106+
describe("Email verification", function () {
99107
beforeEach(async function () {
100-
page = await browser.newPage();
101-
await clearBrowserCookiesWithoutAffectingConsole(page, []);
102108
await page.evaluate(() => localStorage.removeItem("SHOW_GENERAL_ERROR"));
103109
await Promise.all([
104110
page.goto(`${TEST_CLIENT_BASE_URL}/auth?mode=REQUIRED`),
@@ -229,34 +235,7 @@ describe("General error rendering", function () {
229235

230236
function getEmailPasswordTests(rid, ridForStorage) {
231237
describe("Email Password Tests", function () {
232-
let browser;
233-
let page;
234-
before(async function () {
235-
await backendBeforeEach();
236-
237-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
238-
method: "POST",
239-
}).catch(console.error);
240-
241-
browser = await setupBrowser();
242-
});
243-
244-
after(async function () {
245-
await browser.close();
246-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
247-
method: "POST",
248-
}).catch(console.error);
249-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
250-
method: "POST",
251-
}).catch(console.error);
252-
});
253-
254-
afterEach(function () {
255-
return screenshotOnFailure(this, browser);
256-
});
257-
258238
beforeEach(async function () {
259-
page = await browser.newPage();
260239
await Promise.all([
261240
page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=${rid}`),
262241
page.waitForNavigation({ waitUntil: "networkidle0" }),
@@ -364,34 +343,7 @@ function getEmailPasswordTests(rid, ridForStorage) {
364343

365344
function getThirdPartyTests(rid, ridForStorage) {
366345
describe("Third Party Tests", function () {
367-
let browser;
368-
let page;
369-
before(async function () {
370-
await backendBeforeEach();
371-
372-
await fetch(`${TEST_SERVER_BASE_URL}/startst`, {
373-
method: "POST",
374-
}).catch(console.error);
375-
376-
browser = await setupBrowser();
377-
});
378-
379-
after(async function () {
380-
await browser.close();
381-
await fetch(`${TEST_SERVER_BASE_URL}/after`, {
382-
method: "POST",
383-
}).catch(console.error);
384-
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, {
385-
method: "POST",
386-
}).catch(console.error);
387-
});
388-
389-
afterEach(function () {
390-
return screenshotOnFailure(this, browser);
391-
});
392-
393346
beforeEach(async function () {
394-
page = await browser.newPage();
395347
await page.goto(`${TEST_CLIENT_BASE_URL}/auth?authRecipe=${rid}`);
396348
await page.evaluate(() => localStorage.removeItem("SHOW_GENERAL_ERROR"));
397349
});

0 commit comments

Comments
 (0)