mirror of
https://github.com/coder/code-server.git
synced 2024-12-04 23:03:06 +08:00
f2fa7701a9
My thinking is that this may reduce the cognitive overhead for developers writing new test suites. This also allows us to perform different setup steps (like ensuring the editor is visible when authenticated).
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Cookie } from "playwright"
|
|
import { hash } from "../../src/node/util"
|
|
import { PASSWORD, workspaceDir } from "./constants"
|
|
import { clean } from "./helpers"
|
|
import * as wtfnode from "./wtfnode"
|
|
|
|
/**
|
|
* Perform workspace cleanup and authenticate. This should be set up to run
|
|
* before our tests execute.
|
|
*/
|
|
export default async function () {
|
|
console.log("\n🚨 Running Global Setup for Playwright End-to-End Tests")
|
|
console.log(" Please hang tight...")
|
|
|
|
// Cleanup workspaces from previous tests.
|
|
await clean(workspaceDir)
|
|
|
|
if (process.env.WTF_NODE) {
|
|
wtfnode.setup()
|
|
}
|
|
|
|
// TODO: Replace this with a call to code-server to get the cookie. To avoid
|
|
// too much overhead we can do an http POST request and avoid spawning a
|
|
// browser for it.
|
|
const cookies: Cookie[] = [
|
|
{
|
|
domain: "localhost",
|
|
expires: -1,
|
|
httpOnly: false,
|
|
name: "key",
|
|
path: "/",
|
|
sameSite: "Lax",
|
|
secure: false,
|
|
value: await hash(PASSWORD),
|
|
},
|
|
]
|
|
|
|
// Save storage state and store as an env variable
|
|
// More info: https://playwright.dev/docs/auth/#reuse-authentication-state
|
|
process.env.STORAGE = JSON.stringify({ cookies })
|
|
|
|
console.log("✅ Global Setup for Playwright End-to-End Tests is now complete.")
|
|
}
|