2021-04-13 19:02:52 +00:00
|
|
|
import { test, expect } from "@playwright/test"
|
2021-03-09 23:33:01 +00:00
|
|
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
2021-01-28 18:48:57 +00:00
|
|
|
|
2021-04-13 19:02:52 +00:00
|
|
|
test.describe("login", () => {
|
2021-04-14 00:31:24 +00:00
|
|
|
// Reset the browser so no cookies are persisted
|
|
|
|
// by emptying the storageState
|
|
|
|
const options = {
|
|
|
|
contextOptions: {
|
|
|
|
storageState: {},
|
|
|
|
},
|
|
|
|
}
|
2021-01-28 18:48:57 +00:00
|
|
|
|
2021-04-15 22:16:50 +00:00
|
|
|
test("should see the login page", options, async ({ page }) => {
|
|
|
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
|
|
|
// It should send us to the login page
|
|
|
|
expect(await page.title()).toBe("code-server login")
|
|
|
|
})
|
|
|
|
|
2021-04-14 00:31:24 +00:00
|
|
|
test("should be able to login", options, async ({ page }) => {
|
|
|
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
2021-01-28 18:48:57 +00:00
|
|
|
// Type in password
|
2021-02-12 19:08:34 +00:00
|
|
|
await page.fill(".password", PASSWORD)
|
2021-01-28 18:48:57 +00:00
|
|
|
// Click the submit button and login
|
|
|
|
await page.click(".submit")
|
2021-04-01 21:52:46 +00:00
|
|
|
await page.waitForLoadState("networkidle")
|
2021-04-05 22:18:13 +00:00
|
|
|
// Make sure the editor actually loaded
|
|
|
|
expect(await page.isVisible("div.monaco-workbench"))
|
2021-01-28 18:48:57 +00:00
|
|
|
})
|
2021-04-15 22:27:17 +00:00
|
|
|
|
|
|
|
test("should see an error message for missing password", options, async ({ page }) => {
|
|
|
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
|
|
|
// Skip entering password
|
|
|
|
// Click the submit button and login
|
|
|
|
await page.click(".submit")
|
|
|
|
await page.waitForLoadState("networkidle")
|
|
|
|
expect(await page.isVisible("text=Missing password"))
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should see an error message for incorrect password", options, async ({ page }) => {
|
|
|
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
|
|
|
// Type in password
|
|
|
|
await page.fill(".password", "password123")
|
|
|
|
// Click the submit button and login
|
|
|
|
await page.click(".submit")
|
|
|
|
await page.waitForLoadState("networkidle")
|
|
|
|
expect(await page.isVisible("text=Incorrect password"))
|
|
|
|
})
|
2021-01-28 18:48:57 +00:00
|
|
|
})
|