login.test.ts 970 字节
Newer Older
J
Joe Previte 已提交
1
import { chromium, Page, Browser, BrowserContext } from "playwright"
2
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
J
Joe Previte 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

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()
  })

28
  it("should be able to login", async () => {
29
    await page.goto(CODE_SERVER_ADDRESS)
J
Joe Previte 已提交
30
    // Type in password
31
    await page.fill(".password", PASSWORD)
J
Joe Previte 已提交
32 33 34 35 36 37 38
    // Click the submit button and login
    await page.click(".submit")
    // See the editor
    const codeServerEditor = await page.isVisible(".monaco-workbench")
    expect(codeServerEditor).toBeTruthy()
  })
})