|
| 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