Skip to content

Commit

Permalink
test(open-graph): account for static image paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Sep 29, 2024
1 parent 78f24aa commit 3c1a86f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/specs/pages/root/error-404.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ test.describe('visual regression', () => {

// TODO: enable (https://github.com/harlan-zw/nuxt-og-image/issues/81)
// test('generates the open graph image', async ({ page }) => {
// await page.goto('/__og-image__/image/does-not-exist/og.png')
// await page.goto(`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/does-not-exist/og.png`)
// await expect(page).toHaveScreenshot({ fullPage: true })

// await page.goto('/__og-image__/image/de/does-not-exist/og.png')
// await page.goto(`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/de/does-not-exist/og.png`)
// await expect(page).toHaveScreenshot({ fullPage: true })
// })
})
8 changes: 6 additions & 2 deletions tests/e2e/specs/pages/root/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ test.describe('visual regression', () => {
})

test('generates the open graph image', async ({ page }) => {
await page.goto('/__og-image__/image/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })

await page.goto('/__og-image__/image/de/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/de/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })
})
})
8 changes: 6 additions & 2 deletions tests/e2e/specs/pages/root/legal-notice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ test.describe('visual regression', () => {
})

test('generates the open graph image', async ({ page }) => {
await page.goto('/__og-image__/image/legal-notice/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/legal-notice/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })

await page.goto('/__og-image__/image/de/legal-notice/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/de/legal-notice/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })
})
})
8 changes: 6 additions & 2 deletions tests/e2e/specs/pages/root/privacy-policy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ test.describe('visual regression', () => {
})

test('generates the open graph image', async ({ page }) => {
await page.goto('/__og-image__/image/privacy-policy/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/privacy-policy/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })

await page.goto('/__og-image__/image/de/privacy-policy/og.png')
await page.goto(
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}/de/privacy-policy/og.png`,
)
await expect(page).toHaveScreenshot({ fullPage: true })
})
})
21 changes: 18 additions & 3 deletions tests/e2e/utils/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export const testMetadata = async ({
},
{
key: 'content',
value: joinURL(SITE_URL, '/__og-image__/image', path, '/og.png'),
value: joinURL(
SITE_URL,
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}`,
path,
'/og.png',
),
},
],
},
Expand Down Expand Up @@ -111,7 +116,12 @@ export const testMetadata = async ({
},
{
key: 'content',
value: joinURL(SITE_URL, '/__og-image__/image', path, '/og.png'),
value: joinURL(
SITE_URL,
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}`,
path,
'/og.png',
),
},
],
},
Expand All @@ -124,7 +134,12 @@ export const testMetadata = async ({
},
{
key: 'content',
value: joinURL(SITE_URL, '/__og-image__/image', path, '/og.png'),
value: joinURL(
SITE_URL,
`/__og-image__/${process.env.VIO_SERVER === 'static' ? 'static' : 'image'}`,
path,
'/og.png',
),
},
],
},
Expand Down

0 comments on commit 3c1a86f

Please sign in to comment.