2021-01-28 18:48:57 +00:00
|
|
|
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
|
|
|
|
|
|
|
describe("login", () => {
|
|
|
|
let browser: Browser
|
|
|
|
let page: Page
|
|
|
|
let context: BrowserContext
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
browser = await chromium.launch()
|
|
|
|
context = await browser.newContext()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await browser.close()
|
|
|
|
})
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
page = await context.newPage()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
await page.close()
|
|
|
|
// Remove password from local storage
|
|
|
|
await context.clearCookies()
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should be able to login with the password from config.yml", async () => {
|
2021-01-28 23:23:55 +00:00
|
|
|
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080")
|
2021-01-28 18:48:57 +00:00
|
|
|
// Type in password
|
2021-01-28 23:23:55 +00:00
|
|
|
await page.fill(".password", process.env.PASSWORD || "password")
|
2021-01-28 18:48:57 +00:00
|
|
|
// Click the submit button and login
|
|
|
|
await page.click(".submit")
|
|
|
|
// See the editor
|
|
|
|
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
|
|
|
expect(codeServerEditor).toBeTruthy()
|
|
|
|
})
|
|
|
|
})
|