2021-04-14 03:02:52 +08:00
|
|
|
import { test, expect } from "@playwright/test"
|
2021-04-22 05:31:15 +08:00
|
|
|
import { STORAGE } from "../utils/constants"
|
|
|
|
import { CodeServer } from "./models/CodeServer"
|
2021-04-02 02:48:23 +08:00
|
|
|
|
|
|
|
// This test is to make sure the globalSetup works as expected
|
|
|
|
// meaning globalSetup ran and stored the storageState in STORAGE
|
2021-04-14 03:02:52 +08:00
|
|
|
test.describe("globalSetup", () => {
|
|
|
|
// Create a new context with the saved storage state
|
|
|
|
// so we don't have to logged in
|
2021-04-14 08:15:07 +08:00
|
|
|
const options: any = {}
|
2021-04-22 05:31:15 +08:00
|
|
|
let codeServer: CodeServer
|
2021-04-14 08:15:07 +08:00
|
|
|
|
|
|
|
// TODO@jsjoeio
|
|
|
|
// Fix this once https://github.com/microsoft/playwright-test/issues/240
|
|
|
|
// is fixed
|
|
|
|
if (STORAGE) {
|
|
|
|
const storageState = JSON.parse(STORAGE) || {}
|
|
|
|
options.contextOptions = {
|
2021-04-03 07:49:01 +08:00
|
|
|
storageState,
|
2021-04-14 08:15:07 +08:00
|
|
|
}
|
2021-04-14 03:02:52 +08:00
|
|
|
}
|
2021-04-22 05:31:15 +08:00
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
codeServer = new CodeServer(page)
|
|
|
|
await codeServer.setup()
|
|
|
|
})
|
2021-04-14 03:02:52 +08:00
|
|
|
test("should keep us logged in using the storageState", options, async ({ page }) => {
|
2021-04-06 06:18:13 +08:00
|
|
|
// Make sure the editor actually loaded
|
2021-04-22 05:31:15 +08:00
|
|
|
expect(await codeServer.isEditorVisible()).toBe(true)
|
2021-04-02 02:48:23 +08:00
|
|
|
})
|
|
|
|
})
|