|
1 | | -import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright" |
| 1 | +/// <reference types="jest-playwright-preset" /> |
| 2 | +import { Cookie } from "playwright" |
2 | 3 | import { hash } from "../../src/node/util" |
3 | 4 | import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "../utils/constants" |
4 | 5 | import { createCookieIfDoesntExist } from "../utils/helpers" |
5 | 6 |
|
6 | 7 | describe("Open Help > About", () => { |
7 | | - let browser: Browser |
8 | | - let page: Page |
9 | | - let context: BrowserContext |
10 | | - |
11 | | - beforeAll(async () => { |
12 | | - browser = await chromium.launch() |
| 8 | + beforeEach(async () => { |
13 | 9 | // Create a new context with the saved storage state |
14 | 10 | const storageState = JSON.parse(STORAGE) || {} |
15 | 11 |
|
@@ -42,22 +38,7 @@ describe("Open Help > About", () => { |
42 | 38 | // See discussion: https://github.com/cdr/code-server/pull/2648#discussion_r575434946 |
43 | 39 |
|
44 | 40 | const maybeUpdatedCookies = createCookieIfDoesntExist(cookies, cookieToStore) |
45 | | - |
46 | | - context = await browser.newContext({ |
47 | | - storageState: { cookies: maybeUpdatedCookies }, |
48 | | - }) |
49 | | - }) |
50 | | - |
51 | | - afterAll(async () => { |
52 | | - // Remove password from local storage |
53 | | - await context.clearCookies() |
54 | | - |
55 | | - await context.close() |
56 | | - await browser.close() |
57 | | - }) |
58 | | - |
59 | | - beforeEach(async () => { |
60 | | - page = await context.newPage() |
| 41 | + await jestPlaywright.resetBrowser({ storageState: { cookies: maybeUpdatedCookies } }) |
61 | 42 | }) |
62 | 43 |
|
63 | 44 | it("should see a 'Help' then 'About' button in the Application Menu that opens a dialog", async () => { |
|
0 commit comments