|
1 | 1 | import assert from "assert"; |
2 | | -import puppeteer from "puppeteer"; |
3 | | -import fetch from "isomorphic-fetch"; |
4 | | -import { TEST_SERVER_BASE_URL } from "../constants"; |
5 | 2 | import { AuthPage } from "./pages/AuthPage"; |
6 | 3 | import { EmailVerificationPage } from "./pages/EmailVerificationPage"; |
7 | 4 | import { ResetPasswordPage } from "./pages/ResetPasswordPage"; |
8 | 5 | import { |
9 | | - backendBeforeEach, |
10 | 6 | clearBrowserCookiesWithoutAffectingConsole, |
11 | 7 | screenshotOnFailure, |
12 | 8 | setupBrowser, |
| 9 | + backendHook, |
| 10 | + createCoreApp, |
| 11 | + logoutFromEmailVerification, |
13 | 12 | } from "../helpers"; |
14 | 13 |
|
15 | 14 | describe("Embed components", async () => { |
16 | | - let browser; |
17 | | - let page; |
18 | | - |
19 | | - before(async function () { |
20 | | - browser = await setupBrowser(); |
21 | | - |
22 | | - await backendBeforeEach(); |
23 | | - await fetch(`${TEST_SERVER_BASE_URL}/startst`, { |
24 | | - method: "POST", |
25 | | - }).catch(console.error); |
26 | | - }); |
27 | | - |
28 | | - beforeEach(async () => { |
29 | | - page = await browser.newPage(); |
30 | | - await clearBrowserCookiesWithoutAffectingConsole(page, []); |
31 | | - }); |
32 | | - |
33 | | - after(async function () { |
34 | | - await page.close(); |
35 | | - await fetch(`${TEST_SERVER_BASE_URL}/after`, { |
36 | | - method: "POST", |
37 | | - }).catch(console.error); |
38 | | - await fetch(`${TEST_SERVER_BASE_URL}/stopst`, { |
39 | | - method: "POST", |
40 | | - }).catch(console.error); |
41 | | - |
42 | | - await browser.close(); |
43 | | - }); |
44 | | - |
45 | | - afterEach(function () { |
46 | | - return screenshotOnFailure(this, browser); |
47 | | - }); |
| 15 | + let browser; |
| 16 | + let page; |
| 17 | + let consoleLogs; |
| 18 | + |
| 19 | + before(async function () { |
| 20 | + await backendHook("before"); |
| 21 | + browser = await setupBrowser(); |
| 22 | + }); |
| 23 | + |
| 24 | + beforeEach(async function () { |
| 25 | + await backendHook("beforeEach"); |
| 26 | + await createCoreApp(); |
| 27 | + page = await browser.newPage(); |
| 28 | + |
| 29 | + consoleLogs = []; |
| 30 | + page.on("console", (consoleObj) => { |
| 31 | + const log = consoleObj.text(); |
| 32 | + if (log.startsWith("ST_LOGS")) { |
| 33 | + consoleLogs.push(log); |
| 34 | + } |
| 35 | + }); |
| 36 | + consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, consoleLogs); |
| 37 | + }); |
| 38 | + |
| 39 | + afterEach(async function () { |
| 40 | + await screenshotOnFailure(this, browser); |
| 41 | + await page?.close(); |
| 42 | + await backendHook("afterEach"); |
| 43 | + }); |
| 44 | + |
| 45 | + after(async function () { |
| 46 | + await browser?.close(); |
| 47 | + await backendHook("after"); |
| 48 | + }); |
48 | 49 |
|
49 | 50 | describe("EmailPassword SignInAndUp feature", () => { |
50 | 51 | const testContext = { |
@@ -112,10 +113,10 @@ describe("Embed components", async () => { |
112 | 113 | }); |
113 | 114 |
|
114 | 115 | it("don't mount EmailVerification on /auth/verify-email if disableDefaultUI = true", async () => { |
115 | | - // First, sign in, as we signed up previously |
116 | | - const authPage = await AuthPage.navigate(page, { |
117 | | - ...testContext, |
118 | | - }); |
| 116 | + // First, sign up and logout |
| 117 | + const authPage = await AuthPage.navigate(page, testContext); |
| 118 | + await authPage.signUp(); |
| 119 | + await logoutFromEmailVerification(page); |
119 | 120 |
|
120 | 121 | await authPage.signIn("[email protected]", "Str0ngP@ssw0rd"); |
121 | 122 |
|
|
0 commit comments