Skip to content

Commit 47cbad2

Browse files
committed
feat: add test for login page
1 parent 4be6393 commit 47cbad2

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/login.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { chromium, Page, Browser, BrowserContext } from "playwright"
2+
3+
describe("login", () => {
4+
let browser: Browser
5+
let page: Page
6+
let context: BrowserContext
7+
8+
beforeAll(async () => {
9+
browser = await chromium.launch()
10+
context = await browser.newContext()
11+
})
12+
13+
afterAll(async () => {
14+
await browser.close()
15+
})
16+
17+
beforeEach(async () => {
18+
page = await context.newPage()
19+
})
20+
21+
afterEach(async () => {
22+
await page.close()
23+
await context.clearCookies()
24+
})
25+
26+
it("should see the login page", async () => {
27+
await page.goto("http://localhost:8080")
28+
// It should send us to the login page
29+
expect(await page.title()).toBe("code-server login")
30+
})
31+
32+
it("should be able to login with the password from config.yml", async () => {
33+
await page.goto("http://localhost:8080")
34+
// Get password
35+
const password = "helloworld"
36+
// Type in password
37+
await page.fill(".password", password)
38+
// Click the submit button and login
39+
await page.click(".submit")
40+
// See the editor
41+
const codeServerEditor = await page.isVisible(".monaco-workbench")
42+
expect(codeServerEditor).toBeTruthy()
43+
// Remove password from local storage
44+
})
45+
})

0 commit comments

Comments
 (0)