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
|
||||
// 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 () => {
|
||||
test("should display correct browser based on userAgent", async ({ page, browserName }) => {
|
||||
const displayNames = {
|
||||
chromium: "Chrome",
|
||||
firefox: "Firefox",
|
||||
@ -31,5 +19,4 @@ describe("Browser gutcheck", () => {
|
||||
if (browserName === "webkit") {
|
||||
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"
|
||||
|
||||
// This test is to make sure the globalSetup works as expected
|
||||
// meaning globalSetup ran and stored the storageState in STORAGE
|
||||
describe("globalSetup", () => {
|
||||
beforeEach(async () => {
|
||||
test.describe("globalSetup", () => {
|
||||
// Create a new context with the saved storage state
|
||||
// so we don't have to logged in
|
||||
const storageState = JSON.parse(STORAGE) || {}
|
||||
await jestPlaywright.resetContext({
|
||||
const options = {
|
||||
contextOptions: {
|
||||
storageState,
|
||||
})
|
||||
},
|
||||
}
|
||||
test("should keep us logged in using the storageState", options, async ({ page }) => {
|
||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||
})
|
||||
|
||||
it("should keep us logged in using the storageState", async () => {
|
||||
// Make sure the editor actually loaded
|
||||
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"
|
||||
|
||||
describe("login", () => {
|
||||
beforeEach(async () => {
|
||||
await jestPlaywright.resetBrowser()
|
||||
test.describe("login", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// TODO@jsjoeio reset the browser
|
||||
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
|
||||
await page.fill(".password", PASSWORD)
|
||||
// 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"
|
||||
|
||||
describe("login page", () => {
|
||||
beforeEach(async () => {
|
||||
await jestPlaywright.resetContext({
|
||||
logger: {
|
||||
isEnabled: (name, severity) => name === "browser",
|
||||
log: (name, severity, message, args) => console.log(`${name} ${message}`),
|
||||
},
|
||||
})
|
||||
test.describe("login page", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// TODO@jsjoeio reset context somehow
|
||||
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
|
||||
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"
|
||||
|
||||
describe("logout", () => {
|
||||
beforeEach(async () => {
|
||||
await jestPlaywright.resetBrowser()
|
||||
test.describe("logout", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// TODO@jsjoeio reset context
|
||||
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
|
||||
await page.fill(".password", PASSWORD)
|
||||
// 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"
|
||||
|
||||
describe("Open Help > About", () => {
|
||||
beforeEach(async () => {
|
||||
test.describe("Open Help > About", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Create a new context with the saved storage state
|
||||
// so we don't have to logged in
|
||||
// TODO@jsjoeio reset context and use storageState
|
||||
const storageState = JSON.parse(STORAGE) || {}
|
||||
await jestPlaywright.resetContext({
|
||||
storageState,
|
||||
})
|
||||
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
|
||||
expect(await page.isVisible("div.monaco-workbench"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user