2021-01-29 01:48:57 +07:00
|
|
|
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
2021-02-13 02:08:34 +07:00
|
|
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "./constants"
|
2021-01-29 01:48:57 +07:00
|
|
|
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
|
2021-02-03 03:58:51 +07:00
|
|
|
it("should be able to login", async () => {
|
2021-02-13 02:08:34 +07:00
|
|
|
await page.goto(CODE_SERVER_ADDRESS)
|
2021-01-29 01:48:57 +07:00
|
|
|
// Type in password
|
2021-02-13 02:08:34 +07:00
|
|
|
await page.fill(".password", PASSWORD)
|
2021-01-29 01:48:57 +07:00
|
|
|
// Click the submit button and login
|
|
|
|
await page.click(".submit")
|
|
|
|
// See the editor
|
|
|
|
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
|
|
|
expect(codeServerEditor).toBeTruthy()
|
|
|
|
})
|
|
|
|
})
|