2021-04-19 22:25:57 +00:00
|
|
|
import { test, expect } from "@playwright/test"
|
2021-04-20 19:41:54 +00:00
|
|
|
import { CODE_SERVER_ADDRESS, STORAGE } from "../utils/constants"
|
2021-04-19 22:25:57 +00:00
|
|
|
import { CodeServer } from "./models/CodeServer"
|
|
|
|
|
|
|
|
test.describe("CodeServer", () => {
|
|
|
|
// Create a new context with the saved storage state
|
|
|
|
// so we don't have to logged in
|
|
|
|
const options: any = {}
|
|
|
|
let codeServer: CodeServer
|
|
|
|
|
|
|
|
// TODO@jsjoeio
|
|
|
|
// Fix this once https://github.com/microsoft/playwright-test/issues/240
|
|
|
|
// is fixed
|
|
|
|
if (STORAGE) {
|
|
|
|
const storageState = JSON.parse(STORAGE) || {}
|
|
|
|
options.contextOptions = {
|
|
|
|
storageState,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
codeServer = new CodeServer(page)
|
2021-04-21 21:31:15 +00:00
|
|
|
await codeServer.setup()
|
2021-04-19 22:25:57 +00:00
|
|
|
})
|
|
|
|
|
2021-04-21 21:31:15 +00:00
|
|
|
test(`should navigate to ${CODE_SERVER_ADDRESS}`, options, async ({ page }) => {
|
2021-04-20 19:41:54 +00:00
|
|
|
// We navigate codeServer before each test
|
|
|
|
// and we start the test with a storage state
|
|
|
|
// which means we should be logged in
|
|
|
|
// so it should be on the address
|
|
|
|
const url = page.url()
|
|
|
|
// We use match because there may be a / at the end
|
|
|
|
// so we don't want it to fail if we expect http://localhost:8080 to match http://localhost:8080/
|
|
|
|
expect(url).toMatch(CODE_SERVER_ADDRESS)
|
|
|
|
})
|
2021-04-19 22:25:57 +00:00
|
|
|
|
2021-04-20 19:41:54 +00:00
|
|
|
test("should always see the code-server editor", options, async ({ page }) => {
|
|
|
|
expect(await codeServer.isEditorVisible()).toBe(true)
|
2021-04-19 22:25:57 +00:00
|
|
|
})
|
|
|
|
|
2021-04-30 20:26:25 +00:00
|
|
|
test("should always have a connection", options, async ({ page }) => {
|
2021-04-30 19:33:20 +00:00
|
|
|
expect(await codeServer.isConnected()).toBe(true)
|
|
|
|
})
|
|
|
|
|
2021-04-19 22:25:57 +00:00
|
|
|
test("should show the Integrated Terminal", options, async ({ page }) => {
|
2021-04-20 19:41:54 +00:00
|
|
|
await codeServer.focusTerminal()
|
2021-04-19 22:25:57 +00:00
|
|
|
expect(await page.isVisible("#terminal")).toBe(true)
|
|
|
|
})
|
|
|
|
})
|