refactor: create helpers.ts & add Cookie
This commit is contained in:
parent
38d7718feb
commit
3fa460c244
|
@ -1,4 +1,5 @@
|
||||||
import { logger, field } from "@coder/logger"
|
import { logger, field } from "@coder/logger"
|
||||||
|
import { Cookie } from "../../test/helpers"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
base: string
|
base: string
|
||||||
|
@ -121,21 +122,6 @@ export function logError(prefix: string, err: any): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borrowed from playwright
|
|
||||||
export interface Cookie {
|
|
||||||
name: string
|
|
||||||
value: string
|
|
||||||
domain: string
|
|
||||||
path: string
|
|
||||||
/**
|
|
||||||
* Unix time in seconds.
|
|
||||||
*/
|
|
||||||
expires: number
|
|
||||||
httpOnly: boolean
|
|
||||||
secure: boolean
|
|
||||||
sameSite: "Strict" | "Lax" | "None"
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a cookie exists in array of cookies
|
* Checks if a cookie exists in array of cookies
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// This setup runs before our e2e tests
|
// This setup runs before our e2e tests
|
||||||
// so that it authenticates us into code-server
|
// so that it authenticates us into code-server
|
||||||
// ensuring that we're logged in before we run any tests
|
// ensuring that we're logged in before we run any tests
|
||||||
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
import { chromium } from "playwright"
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
console.log("🚨 Running Global Setup for Jest Tests")
|
console.log("🚨 Running Global Setup for Jest Tests")
|
||||||
console.log(" Please hang tight...")
|
console.log(" Please hang tight...")
|
||||||
const browser: Browser = await chromium.launch()
|
const browser = await chromium.launch()
|
||||||
const context: BrowserContext = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
const page: Page = await context.newPage()
|
const page = await context.newPage()
|
||||||
|
|
||||||
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" })
|
await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" })
|
||||||
// Type in password
|
// Type in password
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Borrowed from playwright
|
||||||
|
export interface Cookie {
|
||||||
|
name: string
|
||||||
|
value: string
|
||||||
|
domain: string
|
||||||
|
path: string
|
||||||
|
/**
|
||||||
|
* Unix time in seconds.
|
||||||
|
*/
|
||||||
|
expires: number
|
||||||
|
httpOnly: boolean
|
||||||
|
secure: boolean
|
||||||
|
sameSite: "Strict" | "Lax" | "None"
|
||||||
|
}
|
Loading…
Reference in New Issue