mirror of https://git.tuxpa.in/a/code-server.git
refactor: use playwright-test syntax for e2e tests
This commit is contained in:
parent
08cd2d8191
commit
52586706c4
|
@ -1,18 +1,6 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
|
|
||||||
// This test is for nothing more than to make sure
|
test("should display correct browser based on userAgent", async ({ page, browserName }) => {
|
||||||
// tests are running in multiple browsers
|
|
||||||
describe("Browser gutcheck", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await jestPlaywright.resetBrowser({
|
|
||||||
logger: {
|
|
||||||
isEnabled: (name) => name === "browser",
|
|
||||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should display correct browser based on userAgent", async () => {
|
|
||||||
const displayNames = {
|
const displayNames = {
|
||||||
chromium: "Chrome",
|
chromium: "Chrome",
|
||||||
firefox: "Firefox",
|
firefox: "Firefox",
|
||||||
|
@ -32,4 +20,3 @@ describe("Browser gutcheck", () => {
|
||||||
expect(userAgent).toContain(displayNames[browserName])
|
expect(userAgent).toContain(displayNames[browserName])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants"
|
||||||
|
|
||||||
// This test is to make sure the globalSetup works as expected
|
// This test is to make sure the globalSetup works as expected
|
||||||
// meaning globalSetup ran and stored the storageState in STORAGE
|
// meaning globalSetup ran and stored the storageState in STORAGE
|
||||||
describe("globalSetup", () => {
|
test.describe("globalSetup", () => {
|
||||||
beforeEach(async () => {
|
|
||||||
// Create a new context with the saved storage state
|
// Create a new context with the saved storage state
|
||||||
// so we don't have to logged in
|
// so we don't have to logged in
|
||||||
const storageState = JSON.parse(STORAGE) || {}
|
const storageState = JSON.parse(STORAGE) || {}
|
||||||
await jestPlaywright.resetContext({
|
const options = {
|
||||||
|
contextOptions: {
|
||||||
storageState,
|
storageState,
|
||||||
})
|
},
|
||||||
|
}
|
||||||
|
test("should keep us logged in using the storageState", options, async ({ page }) => {
|
||||||
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 () => {
|
|
||||||
// Make sure the editor actually loaded
|
// Make sure the editor actually loaded
|
||||||
expect(await page.isVisible("div.monaco-workbench"))
|
expect(await page.isVisible("div.monaco-workbench"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
||||||
|
|
||||||
describe("login", () => {
|
test.describe("login", () => {
|
||||||
beforeEach(async () => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await jestPlaywright.resetBrowser()
|
// TODO@jsjoeio reset the browser
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to login", async () => {
|
test("should be able to login", async ({ page }) => {
|
||||||
// Type in password
|
// Type in password
|
||||||
await page.fill(".password", PASSWORD)
|
await page.fill(".password", PASSWORD)
|
||||||
// Click the submit button and login
|
// Click the submit button and login
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
|
|
||||||
import { CODE_SERVER_ADDRESS } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS } from "../utils/constants"
|
||||||
|
|
||||||
describe("login page", () => {
|
test.describe("login page", () => {
|
||||||
beforeEach(async () => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await jestPlaywright.resetContext({
|
// TODO@jsjoeio reset context somehow
|
||||||
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 see the login page", async () => {
|
test("should see the login page", async ({ page }) => {
|
||||||
// It should send us to the login page
|
// It should send us to the login page
|
||||||
expect(await page.title()).toBe("code-server login")
|
expect(await page.title()).toBe("code-server login")
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
||||||
|
|
||||||
describe("logout", () => {
|
test.describe("logout", () => {
|
||||||
beforeEach(async () => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await jestPlaywright.resetBrowser()
|
// TODO@jsjoeio reset context
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able login and logout", async () => {
|
test("should be able login and logout", async ({ page }) => {
|
||||||
// Type in password
|
// Type in password
|
||||||
await page.fill(".password", PASSWORD)
|
await page.fill(".password", PASSWORD)
|
||||||
// Click the submit button and login
|
// Click the submit button and login
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
import { test, expect } from "@playwright/test"
|
||||||
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants"
|
||||||
|
|
||||||
describe("Open Help > About", () => {
|
test.describe("Open Help > About", () => {
|
||||||
beforeEach(async () => {
|
test.beforeEach(async ({ page }) => {
|
||||||
// Create a new context with the saved storage state
|
// Create a new context with the saved storage state
|
||||||
// so we don't have to logged in
|
// so we don't have to logged in
|
||||||
|
// TODO@jsjoeio reset context and use storageState
|
||||||
const storageState = JSON.parse(STORAGE) || {}
|
const storageState = JSON.parse(STORAGE) || {}
|
||||||
await jestPlaywright.resetContext({
|
|
||||||
storageState,
|
|
||||||
})
|
|
||||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should see a 'Help' then 'About' button in the Application Menu that opens a dialog", async () => {
|
test("should see a 'Help' then 'About' button in the Application Menu that opens a dialog", async ({ page }) => {
|
||||||
// Make sure the editor actually loaded
|
// Make sure the editor actually loaded
|
||||||
expect(await page.isVisible("div.monaco-workbench"))
|
expect(await page.isVisible("div.monaco-workbench"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue