Skip to content

test: update assertion to allow image cdn responses be webp #2729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading