refactor: check for editor consistently in tests
This commit is contained in:
parent
dd80eed5b0
commit
ad0f12e664
@ -15,10 +15,12 @@ extends:
|
|||||||
- plugin:import/recommended
|
- plugin:import/recommended
|
||||||
- plugin:import/typescript
|
- plugin:import/typescript
|
||||||
- plugin:prettier/recommended
|
- plugin:prettier/recommended
|
||||||
- prettier # Removes eslint rules that conflict with prettier.
|
|
||||||
# Recommended by jest-playwright
|
# Recommended by jest-playwright
|
||||||
# https://github.com/playwright-community/jest-playwright#globals
|
# https://github.com/playwright-community/jest-playwright#globals
|
||||||
- plugin:jest-playwright/recommended
|
- plugin:jest-playwright/recommended
|
||||||
|
# Prettier should always be last
|
||||||
|
# Removes eslint rules that conflict with prettier.
|
||||||
|
- prettier
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
# Sometimes you need to add args to implement a function signature even
|
# Sometimes you need to add args to implement a function signature even
|
||||||
|
@ -10,17 +10,12 @@ describe("globalSetup", () => {
|
|||||||
const storageState = JSON.parse(STORAGE) || {}
|
const storageState = JSON.parse(STORAGE) || {}
|
||||||
await jestPlaywright.resetContext({
|
await jestPlaywright.resetContext({
|
||||||
storageState,
|
storageState,
|
||||||
logger: {
|
|
||||||
isEnabled: (name, severity) => name === "browser",
|
|
||||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should keep us logged in using the storageState", async () => {
|
it("should keep us logged in using the storageState", async () => {
|
||||||
// See the editor
|
// Make sure the editor actually loaded
|
||||||
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
expect(await page.isVisible("div.monaco-workbench"))
|
||||||
expect(codeServerEditor).toBeTruthy()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -3,12 +3,7 @@ import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
|||||||
|
|
||||||
describe("login", () => {
|
describe("login", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await jestPlaywright.resetBrowser({
|
await jestPlaywright.resetBrowser()
|
||||||
logger: {
|
|
||||||
isEnabled: (name, severity) => name === "browser",
|
|
||||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -18,8 +13,7 @@ describe("login", () => {
|
|||||||
// Click the submit button and login
|
// Click the submit button and login
|
||||||
await page.click(".submit")
|
await page.click(".submit")
|
||||||
await page.waitForLoadState("networkidle")
|
await page.waitForLoadState("networkidle")
|
||||||
// See the editor
|
// Make sure the editor actually loaded
|
||||||
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
expect(await page.isVisible("div.monaco-workbench"))
|
||||||
expect(codeServerEditor).toBeTruthy()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -3,12 +3,7 @@ import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
|||||||
|
|
||||||
describe("logout", () => {
|
describe("logout", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await jestPlaywright.resetBrowser({
|
await jestPlaywright.resetBrowser()
|
||||||
logger: {
|
|
||||||
isEnabled: (name, severity) => name === "browser",
|
|
||||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -18,9 +13,8 @@ describe("logout", () => {
|
|||||||
// Click the submit button and login
|
// Click the submit button and login
|
||||||
await page.click(".submit")
|
await page.click(".submit")
|
||||||
await page.waitForLoadState("networkidle")
|
await page.waitForLoadState("networkidle")
|
||||||
// See the editor
|
// Make sure the editor actually loaded
|
||||||
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
expect(await page.isVisible("div.monaco-workbench"))
|
||||||
expect(codeServerEditor).toBeTruthy()
|
|
||||||
|
|
||||||
// Click the Application menu
|
// Click the Application menu
|
||||||
await page.click("[aria-label='Application Menu']")
|
await page.click("[aria-label='Application Menu']")
|
||||||
|
@ -8,10 +8,6 @@ describe("Open Help > About", () => {
|
|||||||
const storageState = JSON.parse(STORAGE) || {}
|
const storageState = JSON.parse(STORAGE) || {}
|
||||||
await jestPlaywright.resetContext({
|
await jestPlaywright.resetContext({
|
||||||
storageState,
|
storageState,
|
||||||
logger: {
|
|
||||||
isEnabled: (name, severity) => name === "browser",
|
|
||||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
"@types/node-fetch": "^2.5.8",
|
"@types/node-fetch": "^2.5.8",
|
||||||
"@types/supertest": "^2.0.10",
|
"@types/supertest": "^2.0.10",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
|
"jest-playwright-preset": "^1.5.1",
|
||||||
"jsdom": "^16.4.0",
|
"jsdom": "^16.4.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"playwright": "^1.8.0",
|
"playwright": "^1.8.0",
|
||||||
"supertest": "^6.1.1",
|
|
||||||
"ts-jest": "^26.4.4"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"jest-playwright-preset": "^1.5.1",
|
|
||||||
"playwright-chromium": "^1.10.0",
|
"playwright-chromium": "^1.10.0",
|
||||||
"playwright-firefox": "^1.10.0",
|
"playwright-firefox": "^1.10.0",
|
||||||
"playwright-webkit": "^1.10.0"
|
"playwright-webkit": "^1.10.0",
|
||||||
|
"supertest": "^6.1.1",
|
||||||
|
"ts-jest": "^26.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// so that it authenticates us into code-server
|
// so that it authenticates us into code-server
|
||||||
// ensuring that we're logged in before we run any tests
|
// ensuring that we're logged in before we run any tests
|
||||||
import { chromium } from "playwright"
|
import { chromium } from "playwright"
|
||||||
import { PASSWORD } from "./constants"
|
|
||||||
import { hash } from "../../src/node/util"
|
import { hash } from "../../src/node/util"
|
||||||
|
import { PASSWORD } from "./constants"
|
||||||
import * as wtfnode from "./wtfnode"
|
import * as wtfnode from "./wtfnode"
|
||||||
|
|
||||||
const cookieToStore = {
|
const cookieToStore = {
|
||||||
|
Reference in New Issue
Block a user