From 3fa460c24436eff0d1b1b6e6252473327424141b Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 12 Feb 2021 11:55:16 -0700 Subject: [PATCH] refactor: create helpers.ts & add Cookie --- src/common/util.ts | 16 +--------------- test/globalSetup.ts | 8 ++++---- test/helpers.ts | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 test/helpers.ts diff --git a/src/common/util.ts b/src/common/util.ts index 9b6418da..e8edc13b 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -1,4 +1,5 @@ import { logger, field } from "@coder/logger" +import { Cookie } from "../../test/helpers" export interface Options { 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 */ diff --git a/test/globalSetup.ts b/test/globalSetup.ts index daaf7921..dcf5047d 100644 --- a/test/globalSetup.ts +++ b/test/globalSetup.ts @@ -1,14 +1,14 @@ // This setup runs before our e2e tests // so that it authenticates us into code-server // 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 () => { console.log("🚨 Running Global Setup for Jest Tests") console.log(" Please hang tight...") - const browser: Browser = await chromium.launch() - const context: BrowserContext = await browser.newContext() - const page: Page = await context.newPage() + const browser = await chromium.launch() + const context = await browser.newContext() + const page = await context.newPage() await page.goto(process.env.CODE_SERVER_ADDRESS || "http://localhost:8080", { waitUntil: "domcontentloaded" }) // Type in password diff --git a/test/helpers.ts b/test/helpers.ts new file mode 100644 index 00000000..07a85996 --- /dev/null +++ b/test/helpers.ts @@ -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" +}