1+ import { INTERNAL_FALLBACK_HEADER } from '../shared/manifestFallback' ;
2+
13const HOST_SERVER_CONFIG_MODULE = '../host/server/modern.server' ;
24
35const withRemotePort = < T > ( remotePort : string | undefined , run : ( ) => T ) : T => {
@@ -65,6 +67,18 @@ const getProxyMiddlewareHandler = () => {
6567 ) => Promise < void > ;
6668} ;
6769
70+ const expectInternalFallbackFetchCall = (
71+ fetchMock : jest . Mock ,
72+ nthCall : number ,
73+ url : string ,
74+ ) => {
75+ expect ( fetchMock ) . toHaveBeenNthCalledWith ( nthCall , url , {
76+ headers : {
77+ [ INTERNAL_FALLBACK_HEADER ] : '1' ,
78+ } ,
79+ } ) ;
80+ } ;
81+
6882describe ( 'rsc-mf host modern.server middleware contracts' , ( ) => {
6983 const originalFetch = global . fetch ;
7084 const originalFetchDescriptor = Object . getOwnPropertyDescriptor (
@@ -248,7 +262,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
248262 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
249263
250264 expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
251- expect ( fetchMock ) . toHaveBeenNthCalledWith (
265+ expectInternalFallbackFetchCall (
266+ fetchMock ,
252267 2 ,
253268 'http://127.0.0.1:3999/static/mf-manifest.json' ,
254269 ) ;
@@ -271,7 +286,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
271286 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
272287
273288 expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
274- expect ( fetchMock ) . toHaveBeenNthCalledWith (
289+ expectInternalFallbackFetchCall (
290+ fetchMock ,
275291 2 ,
276292 'http://127.0.0.1:3999/static/mf-manifest.json' ,
277293 ) ;
@@ -335,11 +351,13 @@ describe('rsc-mf host modern.server middleware contracts', () => {
335351 1 ,
336352 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteServerCard.js' ,
337353 ) ;
338- expect ( fetchMock ) . toHaveBeenNthCalledWith (
354+ expectInternalFallbackFetchCall (
355+ fetchMock ,
339356 2 ,
340357 'http://127.0.0.1:3999/static/mf-manifest.json' ,
341358 ) ;
342- expect ( fetchMock ) . toHaveBeenNthCalledWith (
359+ expectInternalFallbackFetchCall (
360+ fetchMock ,
343361 3 ,
344362 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteServerCard.6e997e54ed.js' ,
345363 ) ;
@@ -403,11 +421,13 @@ describe('rsc-mf host modern.server middleware contracts', () => {
403421 1 ,
404422 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteClientCounter.js' ,
405423 ) ;
406- expect ( fetchMock ) . toHaveBeenNthCalledWith (
424+ expectInternalFallbackFetchCall (
425+ fetchMock ,
407426 2 ,
408427 'http://127.0.0.1:3999/static/mf-manifest.json' ,
409428 ) ;
410- expect ( fetchMock ) . toHaveBeenNthCalledWith (
429+ expectInternalFallbackFetchCall (
430+ fetchMock ,
411431 3 ,
412432 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteClientCounter.7745fe5f0a.js' ,
413433 ) ;
@@ -471,11 +491,13 @@ describe('rsc-mf host modern.server middleware contracts', () => {
471491 1 ,
472492 'http://127.0.0.1:3999/static/css/async/__federation_expose_RemoteClientCounter.css' ,
473493 ) ;
474- expect ( fetchMock ) . toHaveBeenNthCalledWith (
494+ expectInternalFallbackFetchCall (
495+ fetchMock ,
475496 2 ,
476497 'http://127.0.0.1:3999/static/mf-manifest.json' ,
477498 ) ;
478- expect ( fetchMock ) . toHaveBeenNthCalledWith (
499+ expectInternalFallbackFetchCall (
500+ fetchMock ,
479501 3 ,
480502 'http://127.0.0.1:3999/static/css/async/__federation_expose_RemoteClientCounter.9f773de2aa.css' ,
481503 ) ;
@@ -532,7 +554,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
532554 1 ,
533555 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteServerCard.js' ,
534556 ) ;
535- expect ( fetchMock ) . toHaveBeenNthCalledWith (
557+ expectInternalFallbackFetchCall (
558+ fetchMock ,
536559 2 ,
537560 'http://127.0.0.1:3999/static/mf-manifest.json' ,
538561 ) ;
@@ -643,7 +666,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
643666
644667 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
645668
646- expect ( fetchMock ) . toHaveBeenNthCalledWith (
669+ expectInternalFallbackFetchCall (
670+ fetchMock ,
647671 3 ,
648672 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteClientCounter.7745fe5f0a.js?cache=1&v=2' ,
649673 ) ;
@@ -703,7 +727,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
703727
704728 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
705729
706- expect ( fetchMock ) . toHaveBeenNthCalledWith (
730+ expectInternalFallbackFetchCall (
731+ fetchMock ,
707732 3 ,
708733 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteClientCounter.7745fe5f0a.js?manifest=1&cache=1' ,
709734 ) ;
@@ -912,7 +937,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
912937
913938 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
914939
915- expect ( fetchMock ) . toHaveBeenNthCalledWith (
940+ expectInternalFallbackFetchCall (
941+ fetchMock ,
916942 3 ,
917943 'http://127.0.0.1:3999/static/js/async/__federation_expose_RemoteServerCard.a1b2c3x9.js' ,
918944 ) ;
@@ -974,7 +1000,8 @@ describe('rsc-mf host modern.server middleware contracts', () => {
9741000
9751001 await withRemotePort ( '3999' , ( ) => handler ( context , next ) ) ;
9761002
977- expect ( fetchMock ) . toHaveBeenNthCalledWith (
1003+ expectInternalFallbackFetchCall (
1004+ fetchMock ,
9781005 3 ,
9791006 'http://127.0.0.1:3999/static/js/async/__federation_expose_nestedActions.a8ce95b11a.js' ,
9801007 ) ;
0 commit comments