|
1 |
| -import { chromium, Page, Browser, BrowserContext } from "playwright" |
| 1 | +/// <reference types="jest-playwright-preset" /> |
2 | 2 | import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
3 | 3 |
|
4 | 4 | describe("login", () => {
|
5 |
| - let browser: Browser |
6 |
| - let page: Page |
7 |
| - let context: BrowserContext |
8 |
| - |
9 |
| - beforeAll(async () => { |
10 |
| - browser = await chromium.launch() |
11 |
| - context = await browser.newContext() |
12 |
| - }) |
13 |
| - |
14 |
| - afterAll(async () => { |
15 |
| - await browser.close() |
16 |
| - }) |
17 |
| - |
18 | 5 | beforeEach(async () => {
|
19 |
| - page = await context.newPage() |
20 |
| - }) |
21 |
| - |
22 |
| - afterEach(async () => { |
23 |
| - await page.close() |
24 |
| - // Remove password from local storage |
25 |
| - await context.clearCookies() |
| 6 | + await jestPlaywright.resetBrowser() |
| 7 | + await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) |
26 | 8 | })
|
27 | 9 |
|
28 | 10 | it("should be able to login", async () => {
|
29 |
| - await page.goto(CODE_SERVER_ADDRESS) |
30 | 11 | // Type in password
|
31 | 12 | await page.fill(".password", PASSWORD)
|
32 | 13 | // Click the submit button and login
|
33 | 14 | await page.click(".submit")
|
34 |
| - // See the editor |
35 |
| - const codeServerEditor = await page.isVisible(".monaco-workbench") |
36 |
| - expect(codeServerEditor).toBeTruthy() |
| 15 | + await page.waitForLoadState("networkidle") |
| 16 | + // Make sure the editor actually loaded |
| 17 | + expect(await page.isVisible("div.monaco-workbench")) |
37 | 18 | })
|
38 | 19 | })
|
0 commit comments