feat: add test for login page
This commit is contained in:
41
test/login.test.ts
Normal file
41
test/login.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
||||
|
||||
// NOTE: this is hard-coded and passed as an environment variable
|
||||
// See the test job in ci.yml
|
||||
const PASSWORD = "e45432jklfdsab"
|
||||
|
||||
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 () => {
|
||||
await page.goto("http://localhost:8080")
|
||||
// Type in password
|
||||
await page.fill(".password", PASSWORD)
|
||||
// Click the submit button and login
|
||||
await page.click(".submit")
|
||||
// See the editor
|
||||
const codeServerEditor = await page.isVisible(".monaco-workbench")
|
||||
expect(codeServerEditor).toBeTruthy()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user