Skip to content

Commit 710c48f

Browse files
committed
test: update og image test (but skip it for now)
1 parent 790a3d6 commit 710c48f

7 files changed

Lines changed: 25 additions & 13 deletions

File tree

nuxt.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export default defineNuxtConfig({
9090
ogImage: {
9191
defaults: {
9292
component: 'Default',
93-
9493
},
9594
},
9695

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test:nuxt": "vitest --project nuxt",
2323
"test:browser": "playwright test",
2424
"test:browser:ui": "playwright test --ui",
25-
"test:browser:update": "docker run --rm --network host -v $(pwd):/work/ -v /tmp/playwright-node-modules:/work/node_modules -w /work/ -it mcr.microsoft.com/playwright:v1.55.0-noble bash -c 'corepack enable && pnpm i && pnpm playwright test test/browser --update-snapshots'"
25+
"test:browser:update": "playwright test --update-snapshots"
2626
},
2727
"dependencies": {
2828
"@nuxt/eslint": "^1.12.1",

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig<ConfigOptions>({
99
retries: process.env.CI ? 2 : 0,
1010
workers: process.env.CI ? 1 : undefined,
1111
reporter: 'html',
12+
timeout: 120_000,
1213
use: {
1314
trace: 'on-first-retry',
1415
nuxt: {

tests/index.spec.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.
-6.55 KB
Binary file not shown.
-59.7 KB
Binary file not shown.

tests/og-image.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect, test } from '@nuxt/test-utils/playwright'
2+
3+
const paths = ['/', '/package/nuxt/v/3.20.2']
4+
for (const path of paths) {
5+
test.describe(path, () => {
6+
test.skip(`og image for ${path}`, async ({ page, goto, baseURL }) => {
7+
await goto(path, { waitUntil: 'domcontentloaded' })
8+
9+
const ogImageUrl = await page.locator('meta[property="og:image"]').getAttribute('content')
10+
expect(ogImageUrl).toBeTruthy()
11+
12+
const ogImagePath = new URL(ogImageUrl!).pathname
13+
const localUrl = baseURL?.endsWith('/') ? `${baseURL}${ogImagePath.slice(1)}` : `${baseURL}${ogImagePath}`
14+
const response = await page.request.get(localUrl)
15+
16+
expect(response.status()).toBe(200)
17+
expect(response.headers()['content-type']).toContain('image/png')
18+
19+
const imageBuffer = await response.body()
20+
expect(imageBuffer).toMatchSnapshot({ name: `og-image-for-${path.replace(/\//g, '-')}.png` })
21+
})
22+
})
23+
}

0 commit comments

Comments
 (0)