From 9dba958d7379fb0b36c4d895b75e8ce2cc6290d5 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 31 Aug 2023 11:55:22 +0100 Subject: [PATCH] test: pass forced deployment via cookie --- .e2e/tests/advanced/config-extends.spec.ts | 4 ++-- .e2e/tests/advanced/error-handling.spec.ts | 4 ++-- .e2e/tests/advanced/jsx.spec.ts | 4 ++-- .e2e/tests/advanced/locale.spec.ts | 4 ++-- .e2e/tests/advanced/module-extend-pages.spec.ts | 4 ++-- .e2e/tests/advanced/use-cookie.spec.ts | 4 ++-- .e2e/tests/experimental/wasm.spec.ts | 4 ++-- .e2e/tests/features/auto-imports.spec.ts | 4 ++-- .e2e/tests/features/data-fetching.spec.ts | 4 ++-- .e2e/tests/features/meta-tags.spec.ts | 4 ++-- .e2e/tests/features/state-management.spec.ts | 2 +- .e2e/tests/hello-world.spec.ts | 4 ++-- .e2e/tests/routing/middleware.spec.ts | 4 ++-- .e2e/tests/routing/pages.spec.ts | 4 ++-- .e2e/tests/routing/universal-router.spec.ts | 4 ++-- .e2e/tests/ui/daisyui.spec.ts | 4 ++-- .e2e/tests/ui/sass.spec.ts | 4 ++-- .e2e/tests/ui/tailwindcss.spec.ts | 4 ++-- .e2e/tests/ui/vuetify.spec.ts | 4 ++-- .e2e/utils/index.ts | 6 ++++-- 20 files changed, 41 insertions(+), 39 deletions(-) diff --git a/.e2e/tests/advanced/config-extends.spec.ts b/.e2e/tests/advanced/config-extends.spec.ts index 15fcf62d..b3ae3324 100644 --- a/.e2e/tests/advanced/config-extends.spec.ts +++ b/.e2e/tests/advanced/config-extends.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('config-extends') }) +test.use(getSettingsForDeployment('config-extends')) test("App config merged", async ({ page }) => { // TODO need a unique locator diff --git a/.e2e/tests/advanced/error-handling.spec.ts b/.e2e/tests/advanced/error-handling.spec.ts index 735ff51c..4892f26d 100644 --- a/.e2e/tests/advanced/error-handling.spec.ts +++ b/.e2e/tests/advanced/error-handling.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect, Page } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('error-handling') }) +test.use(getSettingsForDeployment('error-handling')) test("Home page loads without any errors", async ({ page }) => { await page.goto("/") diff --git a/.e2e/tests/advanced/jsx.spec.ts b/.e2e/tests/advanced/jsx.spec.ts index f05c2785..a8a7d36c 100644 --- a/.e2e/tests/advanced/jsx.spec.ts +++ b/.e2e/tests/advanced/jsx.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('jsx') }) +test.use(getSettingsForDeployment('jsx')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/advanced/locale.spec.ts b/.e2e/tests/advanced/locale.spec.ts index 428d7a84..c64a5947 100644 --- a/.e2e/tests/advanced/locale.spec.ts +++ b/.e2e/tests/advanced/locale.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('locale') }) +test.use(getSettingsForDeployment('locale')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/advanced/module-extend-pages.spec.ts b/.e2e/tests/advanced/module-extend-pages.spec.ts index 8cfa0b5e..5ea6441b 100644 --- a/.e2e/tests/advanced/module-extend-pages.spec.ts +++ b/.e2e/tests/advanced/module-extend-pages.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('module-extend-pages') }) +test.use(getSettingsForDeployment('module-extend-pages')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/advanced/use-cookie.spec.ts b/.e2e/tests/advanced/use-cookie.spec.ts index 4314df7b..feef225d 100644 --- a/.e2e/tests/advanced/use-cookie.spec.ts +++ b/.e2e/tests/advanced/use-cookie.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('use-cookie') }) +test.use(getSettingsForDeployment('use-cookie')) test("Login screen shows by default", async ({ page }) => { await page.goto("/") diff --git a/.e2e/tests/experimental/wasm.spec.ts b/.e2e/tests/experimental/wasm.spec.ts index d56d6290..2e7b64e4 100644 --- a/.e2e/tests/experimental/wasm.spec.ts +++ b/.e2e/tests/experimental/wasm.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('wasm') }) +test.use(getSettingsForDeployment('wasm')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/features/auto-imports.spec.ts b/.e2e/tests/features/auto-imports.spec.ts index b530f82e..04f26e41 100644 --- a/.e2e/tests/features/auto-imports.spec.ts +++ b/.e2e/tests/features/auto-imports.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('auto-imports') }) +test.use(getSettingsForDeployment('auto-imports')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/features/data-fetching.spec.ts b/.e2e/tests/features/data-fetching.spec.ts index 9eac76fc..fdd6ace3 100644 --- a/.e2e/tests/features/data-fetching.spec.ts +++ b/.e2e/tests/features/data-fetching.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('data-fetching') }) +test.use(getSettingsForDeployment('data-fetching')) test.describe("Index page", () => { test("Hello world is shown on the index page", async ({ page }) => { diff --git a/.e2e/tests/features/meta-tags.spec.ts b/.e2e/tests/features/meta-tags.spec.ts index 1ef44b80..ce40c416 100644 --- a/.e2e/tests/features/meta-tags.spec.ts +++ b/.e2e/tests/features/meta-tags.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('meta-tags') }) +test.use(getSettingsForDeployment('meta-tags')) const INDEX_LANG = "en" const INDEX_DEFAULT_TITLE = "Lucky number: 1 - Meta Tags Example" diff --git a/.e2e/tests/features/state-management.spec.ts b/.e2e/tests/features/state-management.spec.ts index 4e561676..d1198c4c 100644 --- a/.e2e/tests/features/state-management.spec.ts +++ b/.e2e/tests/features/state-management.spec.ts @@ -1,4 +1,4 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect, type Page } from "@playwright/test" test.use({ baseURL: "https://state-management.example.nuxt.space//" }) diff --git a/.e2e/tests/hello-world.spec.ts b/.e2e/tests/hello-world.spec.ts index d477f51a..91624f59 100644 --- a/.e2e/tests/hello-world.spec.ts +++ b/.e2e/tests/hello-world.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('hello-world') }) +test.use(getSettingsForDeployment('hello-world')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/routing/middleware.spec.ts b/.e2e/tests/routing/middleware.spec.ts index e1e6a580..aff8def9 100644 --- a/.e2e/tests/routing/middleware.spec.ts +++ b/.e2e/tests/routing/middleware.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment, wait } from "@/utils" +import { getSettingsForDeployment, wait } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('middleware') }) +test.use(getSettingsForDeployment('middleware')) test("Global middleware is being registered", async ({ page }) => { const globalMiddlewareMessageLoggedPromise = page.waitForEvent("console", { diff --git a/.e2e/tests/routing/pages.spec.ts b/.e2e/tests/routing/pages.spec.ts index 8b883388..00d1b996 100644 --- a/.e2e/tests/routing/pages.spec.ts +++ b/.e2e/tests/routing/pages.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('pages') }) +test.use(getSettingsForDeployment('pages')) test.describe("Linked pages", () => { test.beforeEach(async ({ page }) => { diff --git a/.e2e/tests/routing/universal-router.spec.ts b/.e2e/tests/routing/universal-router.spec.ts index 6280864b..ffd857a1 100644 --- a/.e2e/tests/routing/universal-router.spec.ts +++ b/.e2e/tests/routing/universal-router.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('universal-router') }) +test.use(getSettingsForDeployment('universal-router')) test("Global middleware is being registered", async ({ page }) => { const globalMiddlewareMessageLoggedPromise = page.waitForEvent("console", { diff --git a/.e2e/tests/ui/daisyui.spec.ts b/.e2e/tests/ui/daisyui.spec.ts index 2e1b6f8c..5f1e89af 100644 --- a/.e2e/tests/ui/daisyui.spec.ts +++ b/.e2e/tests/ui/daisyui.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('daisyui') }) +test.use(getSettingsForDeployment('daisyui')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/ui/sass.spec.ts b/.e2e/tests/ui/sass.spec.ts index 4a46912d..6c09552a 100644 --- a/.e2e/tests/ui/sass.spec.ts +++ b/.e2e/tests/ui/sass.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('sass') }) +test.use(getSettingsForDeployment('sass')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/ui/tailwindcss.spec.ts b/.e2e/tests/ui/tailwindcss.spec.ts index b9ed2949..a955b17f 100644 --- a/.e2e/tests/ui/tailwindcss.spec.ts +++ b/.e2e/tests/ui/tailwindcss.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('tailwindcss') }) +test.use(getSettingsForDeployment('tailwindcss')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/tests/ui/vuetify.spec.ts b/.e2e/tests/ui/vuetify.spec.ts index ee1062bc..0e0d504b 100644 --- a/.e2e/tests/ui/vuetify.spec.ts +++ b/.e2e/tests/ui/vuetify.spec.ts @@ -1,7 +1,7 @@ -import { getURLForDeployment } from "@/utils" +import { getSettingsForDeployment } from "@/utils" import { test, expect } from "@playwright/test" -test.use({ baseURL: getURLForDeployment('vuetify') }) +test.use(getSettingsForDeployment('vuetify')) test.beforeEach(async ({ page }) => { await page.goto("/") }) diff --git a/.e2e/utils/index.ts b/.e2e/utils/index.ts index e3a3cceb..36d40f06 100644 --- a/.e2e/utils/index.ts +++ b/.e2e/utils/index.ts @@ -1,5 +1,7 @@ export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) -export const getURLForDeployment = (slug: string) => - process.env.DEPLOY_URL ? `${process.env.DEPLOY_URL}?force=${slug}` : `https://${slug}.example.nuxt.space/` +export const getSettingsForDeployment = (slug: string) => ({ + baseURL: process.env.DEPLOY_URL || `https://${slug}.example.nuxt.space/`, + extraHTTPHeaders: { 'cookie': `forced=${slug}` } +})