mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-26 12:15:26 +00:00
Gate wtfnode behind WTF_NODE env var
After thinking about it some more it's probably mostly only useful to see the output when the tests are hanging. Otherwise there's a lot of noise about Jest child processes and pipes.
This commit is contained in:
parent
6685b3a4ff
commit
47a05c998a
@ -143,9 +143,6 @@
|
||||
"lines": 40
|
||||
}
|
||||
},
|
||||
"modulePathIgnorePatterns": [
|
||||
"<rootDir>/release"
|
||||
],
|
||||
"testTimeout": 30000,
|
||||
"globalSetup": "<rootDir>/test/globalSetup.ts",
|
||||
"modulePathIgnorePatterns": [
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { logger, field } from "@coder/logger"
|
||||
import { Cookie } from "../../test/helpers"
|
||||
|
||||
export interface Options {
|
||||
base: string
|
||||
@ -121,24 +120,3 @@ export function logError(prefix: string, err: any): void {
|
||||
logger.error(`${prefix}: ${err}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a cookie exists in array of cookies
|
||||
*/
|
||||
export function checkForCookie(cookies: Array<Cookie>, key: string): boolean {
|
||||
// Check for a cookie where the name is equal to key
|
||||
return Boolean(cookies.find((cookie) => cookie.name === key))
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a login cookie if one doesn't already exist
|
||||
*/
|
||||
export function createCookieIfDoesntExist(cookies: Array<Cookie>, cookieToStore: Cookie): Array<Cookie> {
|
||||
const cookieName = cookieToStore.name
|
||||
const doesCookieExist = checkForCookie(cookies, cookieName)
|
||||
if (!doesCookieExist) {
|
||||
const updatedCookies = [...cookies, cookieToStore]
|
||||
return updatedCookies
|
||||
}
|
||||
return cookies
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { chromium, Page, Browser } from "playwright"
|
||||
import { CODE_SERVER_ADDRESS } from "./constants"
|
||||
|
||||
let browser: Browser
|
||||
let page: Page
|
||||
@ -17,7 +18,7 @@ afterEach(async () => {
|
||||
})
|
||||
|
||||
it("should see the login page", async () => {
|
||||
await page.goto(process.env)
|
||||
await page.goto(CODE_SERVER_ADDRESS)
|
||||
// It should send us to the login page
|
||||
expect(await page.title()).toBe("code-server login")
|
||||
})
|
||||
|
@ -6,13 +6,15 @@ import { CODE_SERVER_ADDRESS, PASSWORD } from "./constants"
|
||||
import * as wtfnode from "./wtfnode"
|
||||
|
||||
module.exports = async () => {
|
||||
console.log("🚨 Running Global Setup for Jest Tests")
|
||||
console.log(" Please hang tight...")
|
||||
console.log("\n🚨 Running Global Setup for Jest Tests")
|
||||
console.log(" Please hang tight...")
|
||||
const browser = await chromium.launch()
|
||||
const context = await browser.newContext()
|
||||
const page = await context.newPage()
|
||||
|
||||
wtfnode.setup()
|
||||
if (process.env.WTF_NODE) {
|
||||
wtfnode.setup()
|
||||
}
|
||||
|
||||
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "domcontentloaded" })
|
||||
// Type in password
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright"
|
||||
import { createCookieIfDoesntExist } from "../src/common/util"
|
||||
import { hash } from "../src/node/util"
|
||||
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "./constants"
|
||||
import { createCookieIfDoesntExist } from "./helpers"
|
||||
|
||||
describe("go home", () => {
|
||||
let browser: Browser
|
||||
|
@ -12,3 +12,24 @@ export interface Cookie {
|
||||
secure: boolean
|
||||
sameSite: "Strict" | "Lax" | "None"
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a cookie exists in array of cookies
|
||||
*/
|
||||
export function checkForCookie(cookies: Array<Cookie>, key: string): boolean {
|
||||
// Check for a cookie where the name is equal to key
|
||||
return Boolean(cookies.find((cookie) => cookie.name === key))
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a login cookie if one doesn't already exist
|
||||
*/
|
||||
export function createCookieIfDoesntExist(cookies: Array<Cookie>, cookieToStore: Cookie): Array<Cookie> {
|
||||
const cookieName = cookieToStore.name
|
||||
const doesCookieExist = checkForCookie(cookies, cookieName)
|
||||
if (!doesCookieExist) {
|
||||
const updatedCookies = [...cookies, cookieToStore]
|
||||
return updatedCookies
|
||||
}
|
||||
return cookies
|
||||
}
|
||||
|
@ -13,13 +13,12 @@ import {
|
||||
resolveBase,
|
||||
split,
|
||||
trimSlashes,
|
||||
checkForCookie,
|
||||
createCookieIfDoesntExist,
|
||||
normalize,
|
||||
} from "../src/common/util"
|
||||
import { Cookie as CookieEnum } from "../src/node/routes/login"
|
||||
import { hash } from "../src/node/util"
|
||||
import { PASSWORD } from "./constants"
|
||||
import { checkForCookie, createCookieIfDoesntExist } from "./helpers"
|
||||
|
||||
const dom = new JSDOM()
|
||||
global.document = dom.window.document
|
||||
|
Loading…
Reference in New Issue
Block a user