@@ -33,8 +33,6 @@ const {
33
33
} = require ( '../plugin/src/helpers/config' )
34
34
const { dirname } = require ( 'path' )
35
35
const { getProblematicUserRewrites } = require ( '../plugin/src/helpers/verification' )
36
- const { onPostBuild } = require ( '../plugin/lib' )
37
- const { basePath } = require ( '../demos/next-i18next/next.config' )
38
36
39
37
const chance = new Chance ( )
40
38
const FIXTURES_DIR = `${ __dirname } /fixtures`
@@ -455,7 +453,7 @@ describe('onBuild()', () => {
455
453
'.next/static/chunks/webpack-middleware*.js' ,
456
454
'!.next/server/**/*.js.nft.json' ,
457
455
".next/static/css/1152424140993be6.css" ,
458
- ".next/static/css/84099ae0bbc955fa.css" ,
456
+ ".next/static/css/84099ae0bbc955fa.css" ,
459
457
'!../../node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*' ,
460
458
`!node_modules/next/dist/server/lib/squoosh/**/*.wasm` ,
461
459
`!node_modules/next/dist/next-server/server/lib/squoosh/**/*.wasm` ,
@@ -530,13 +528,32 @@ describe('onBuild()', () => {
530
528
expect ( await plugin . onBuild ( defaultArgs ) ) . toBeUndefined ( )
531
529
} )
532
530
533
- test ( 'generates imageconfig file with entries for domains and remotePatterns ' , async ( ) => {
531
+ test ( 'generates imageconfig file with entries for domains, remotePatterns, and custom response headers ' , async ( ) => {
534
532
await moveNextDist ( )
535
- await plugin . onBuild ( defaultArgs )
533
+ const mockHeaderValue = chance . string ( )
534
+
535
+ const updatedArgs = {
536
+ ...defaultArgs ,
537
+ netlifyConfig : {
538
+ ...defaultArgs . netlifyConfig ,
539
+ headers : [ {
540
+ for : '/_next/image/' ,
541
+ values : {
542
+ 'X-Foo' : mockHeaderValue
543
+ }
544
+ } ]
545
+ }
546
+ }
547
+ await plugin . onBuild ( updatedArgs )
548
+
536
549
const imageConfigPath = path . join ( constants . INTERNAL_FUNCTIONS_SRC , IMAGE_FUNCTION_NAME , 'imageconfig.json' )
537
550
const imageConfigJson = await readJson ( imageConfigPath )
551
+
538
552
expect ( imageConfigJson . domains . length ) . toBe ( 1 )
539
553
expect ( imageConfigJson . remotePatterns . length ) . toBe ( 1 )
554
+ expect ( imageConfigJson . responseHeaders ) . toStrictEqual ( {
555
+ 'X-Foo' : mockHeaderValue
556
+ } )
540
557
} )
541
558
} )
542
559
0 commit comments