From cfb85ac8702671bee6f5af02dee8c5c29a7dd05c Mon Sep 17 00:00:00 2001 From: pieh Date: Thu, 19 Dec 2024 12:33:42 +0100 Subject: [PATCH] test: update assertion to allow image cdn responses be webp --- tests/e2e/export.test.ts | 6 ++++-- tests/e2e/simple-app.test.ts | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/e2e/export.test.ts b/tests/e2e/export.test.ts index 715ec18f1d..916f668f97 100644 --- a/tests/e2e/export.test.ts +++ b/tests/e2e/export.test.ts @@ -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')) }) diff --git a/tests/e2e/simple-app.test.ts b/tests/e2e/simple-app.test.ts index 15f1f585fe..980ad84dd0 100644 --- a/tests/e2e/simple-app.test.ts +++ b/tests/e2e/simple-app.test.ts @@ -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')) }) @@ -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')) }) @@ -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')) }) @@ -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')) }) @@ -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')) })