Skip to content

Commit

Permalink
test: update assertion to allow image cdn responses be webp
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Dec 19, 2024
1 parent 6a2c39c commit cfb85ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 4 additions & 2 deletions tests/e2e/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ test.describe('next/image is using Netlify Image CDN', () => {

expect(nextImageResponse.status()).toBe(200)
// ensure next/image is using Image CDN
// source image is jpg, but when requesting it through Image CDN avif will be returned
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
// source image is jpg, but when requesting it through Image CDN avif or webp will be returned
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand Down
22 changes: 16 additions & 6 deletions tests/e2e/simple-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ test.describe('next/image is using Netlify Image CDN', () => {

expect(nextImageResponse.status()).toBe(200)
// ensure next/image is using Image CDN
// source image is jpg, but when requesting it through Image CDN avif will be returned
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
// source image is jpg, but when requesting it through Image CDN avif or webp will be returned
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand All @@ -142,7 +144,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
)

expect(nextImageResponse.status()).toBe(200)
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand All @@ -164,7 +168,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
)

expect(nextImageResponse.status()).toBe(200)
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand All @@ -183,7 +189,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
)

expect(nextImageResponse?.status()).toBe(200)
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand All @@ -203,7 +211,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
)

expect(nextImageResponse.status()).toEqual(200)
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
expect(['image/avif', 'image/webp']).toContain(
await nextImageResponse.headerValue('content-type'),
)

await expectImageWasLoaded(page.locator('img'))
})
Expand Down

0 comments on commit cfb85ac

Please sign in to comment.