Skip to content

Commit

Permalink
test: test deploy previews with e2e suite
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 13, 2023
1 parent af43e51 commit 87c7a8a
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/config-extends.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://config-extends.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('config-extends') })

test("App config merged", async ({ page }) => {
// TODO need a unique locator
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/error-handling.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect, Page } from "@playwright/test"

test.use({ baseURL: "https://error-handling.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('error-handling') })

test("Home page loads without any errors", async ({ page }) => {
await page.goto("/")
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/jsx.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://jsx.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('jsx') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/locale.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://locale.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('locale') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/module-extend-pages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://module-extend-pages.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('module-extend-pages') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/advanced/use-cookie.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://use-cookie.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('use-cookie') })

test("Login screen shows by default", async ({ page }) => {
await page.goto("/")
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/experimental/wasm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://wasm.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('wasm') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/features/auto-imports.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://auto-imports.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('auto-imports') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/features/data-fetching.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://data-fetching.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('data-fetching') })

test.describe("Index page", () => {
test("Hello world is shown on the index page", async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/features/meta-tags.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://meta-tags.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('meta-tags') })

const INDEX_LANG = "en"
const INDEX_DEFAULT_TITLE = "Lucky number: 1 - Meta Tags Example"
Expand Down
1 change: 1 addition & 0 deletions .e2e/tests/features/state-management.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getURLForDeployment } from "@/utils"
import { test, expect, type Page } from "@playwright/test"

test.use({ baseURL: "https://state-management.example.nuxt.space//" })
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/hello-world.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://hello-world.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('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 { wait } from "@/utils"
import { getURLForDeployment, wait } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://middleware.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('middleware') })

test("Global middleware is being registered", async ({ page }) => {
const globalMiddlewareMessageLoggedPromise = page.waitForEvent("console", {
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/routing/pages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://pages.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('pages') })

test.describe("Linked pages", () => {
test.beforeEach(async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/routing/universal-router.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://universal-router.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('universal-router') })

test("Global middleware is being registered", async ({ page }) => {
const globalMiddlewareMessageLoggedPromise = page.waitForEvent("console", {
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/ui/daisyui.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://daisyui.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('daisyui') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/ui/sass.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://sass.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('sass') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/ui/tailwindcss.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://tailwindcss.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('tailwindcss') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 2 additions & 1 deletion .e2e/tests/ui/vuetify.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getURLForDeployment } from "@/utils"
import { test, expect } from "@playwright/test"

test.use({ baseURL: "https://vuetify.example.nuxt.space/" })
test.use({ baseURL: getURLForDeployment('vuetify') })
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
Expand Down
3 changes: 3 additions & 0 deletions .e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
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/`
16 changes: 15 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
name: Playwright Tests

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
url:
required: false
description: The URL to run the test suite against. If omitted, it runs against all.
type: string
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
Expand All @@ -22,6 +34,8 @@ jobs:

- name: Run Playwright tests
run: pnpm --filter e2e test:all
env:
DEPLOY_URL: ${{ github.event.inputs.url || github.event.deployment.payload.web_url || github.event.deployment_status.target_url }}

- uses: actions/upload-artifact@v3
if: always()
Expand Down

0 comments on commit 87c7a8a

Please sign in to comment.