Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/test/utils/globalSetup.ts
Teffen 62b3a6fd9f
Proxy path fixes (#4548)
* Fix issue where HTTP error status codes are not read.

* Fix issues surrounding sessions when accessed from a proxy.

- Updated vscode args to match latest upstream.
- Fixed issues surrounding trailing slashes affecting base paths.
- Updated cookie names to better match upstream's usage, debuggability.

* Bump vendor.

* Update tests.

* Fix issue where tests lack cookie key.

Co-authored-by: Asher <ash@coder.com>
2021-12-01 18:21:52 -06:00

45 lines
1.3 KiB
TypeScript

import { Cookie } from "playwright"
import { CookieKeys } from "../../src/common/http"
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: CookieKeys.Session,
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.")
}