|
1 | 1 | /// <reference types="jest-playwright-preset" /> |
2 | | -import { Cookie } from "playwright" |
3 | | -import { hash } from "../../src/node/util" |
4 | | -import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "../utils/constants" |
5 | | -import { createCookieIfDoesntExist } from "../utils/helpers" |
| 2 | +import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants" |
6 | 3 |
|
7 | 4 | describe("Open Help > About", () => { |
8 | 5 | beforeEach(async () => { |
9 | 6 | // Create a new context with the saved storage state |
| 7 | + // so we don't have to logged in |
10 | 8 | const storageState = JSON.parse(STORAGE) || {} |
11 | | - |
12 | | - const cookieToStore = { |
13 | | - sameSite: "Lax" as const, |
14 | | - name: "key", |
15 | | - value: hash(PASSWORD), |
16 | | - domain: "localhost", |
17 | | - path: "/", |
18 | | - expires: -1, |
19 | | - httpOnly: false, |
20 | | - secure: false, |
21 | | - } |
22 | | - |
23 | | - // For some odd reason, the login method used in globalSetup.ts doesn't always work |
24 | | - // I don't know if it's on playwright clearing our cookies by accident |
25 | | - // or if it's our cookies disappearing. |
26 | | - // This means we need an additional check to make sure we're logged in. |
27 | | - // We do this by manually adding the cookie to the browser environment |
28 | | - // if it's not there at the time the test starts |
29 | | - const cookies: Cookie[] = storageState.cookies || [] |
30 | | - // If the cookie exists in cookies then |
31 | | - // this will return the cookies with no changes |
32 | | - // otherwise if it doesn't exist, it will create it |
33 | | - // hence the name maybeUpdatedCookies |
34 | | - // |
35 | | - // TODO(@jsjoeio) |
36 | | - // The playwright storage thing sometimes works and sometimes doesn't. We should investigate this further |
37 | | - // at some point. |
38 | | - // See discussion: https://github.com/cdr/code-server/pull/2648#discussion_r575434946 |
39 | | - |
40 | | - const maybeUpdatedCookies = createCookieIfDoesntExist(cookies, cookieToStore) |
41 | | - await jestPlaywright.resetBrowser({ storageState: { cookies: maybeUpdatedCookies } }) |
| 9 | + await jestPlaywright.resetContext({ storageState }) |
| 10 | + await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" }) |
42 | 11 | }) |
43 | 12 |
|
44 | 13 | it("should see a 'Help' then 'About' button in the Application Menu that opens a dialog", async () => { |
45 | | - // waitUntil: "domcontentloaded" |
46 | | - // In case the page takes a long time to load |
47 | | - await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "domcontentloaded" }) |
48 | | - |
49 | 14 | // Make sure the editor actually loaded |
50 | 15 | expect(await page.isVisible("div.monaco-workbench")) |
51 | 16 |
|
|
0 commit comments