Skip to content

Commit

Permalink
test: pass forced deployment via cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 13, 2023
1 parent 30ee4f9 commit 9dba958
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/config-extends.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/error-handling.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/jsx.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/locale.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/module-extend-pages.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/advanced/use-cookie.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/experimental/wasm.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/features/auto-imports.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/features/data-fetching.spec.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/features/meta-tags.spec.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .e2e/tests/features/state-management.spec.ts
Original file line number Diff line number Diff line change
@@ -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//" })
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/hello-world.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/routing/middleware.spec.ts
Original file line number Diff line number Diff line change
@@ -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", {
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/routing/pages.spec.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/routing/universal-router.spec.ts
Original file line number Diff line number Diff line change
@@ -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", {
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/ui/daisyui.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/ui/sass.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/ui/tailwindcss.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
4 changes: 2 additions & 2 deletions .e2e/tests/ui/vuetify.spec.ts
Original file line number Diff line number Diff line change
@@ -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("/")
})
Expand Down
6 changes: 4 additions & 2 deletions .e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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}` }
})

0 comments on commit 9dba958

Please sign in to comment.