@@ -16,9 +16,13 @@ const fixtureDir = path.resolve(__dirname, '../');
1616const hostDir = path . resolve ( fixtureDir , 'host' ) ;
1717const remoteDir = path . resolve ( fixtureDir , 'remote' ) ;
1818const HOST_RSC_URL = '/server-component-root' ;
19- const EXPECTED_ACTION_POSTS_PER_MODE = 24 ;
19+ const EXPECTED_REMOTE_ACTION_POSTS_PER_MODE = 24 ;
20+ const EXPECTED_HOST_ACTION_POSTS_PER_MODE = 2 ;
21+ const EXPECTED_ACTION_POSTS_PER_MODE =
22+ EXPECTED_REMOTE_ACTION_POSTS_PER_MODE + EXPECTED_HOST_ACTION_POSTS_PER_MODE ;
2023const EXPECTED_ACTION_POSTS_PER_FAMILY = 6 ;
21- const EXPECTED_UNIQUE_ACTION_IDS_PER_MODE = 4 ;
24+ const EXPECTED_UNIQUE_REMOTE_ACTION_IDS_PER_MODE = 4 ;
25+ const EXPECTED_UNIQUE_HOST_ACTION_IDS_PER_MODE = 1 ;
2226const EXPECTED_BROWSER_EXPOSE_CHUNKS = [
2327 '__federation_expose_RemoteClientCounter' ,
2428 '__federation_expose_RemoteClientBadge' ,
@@ -365,6 +369,9 @@ async function supportRemoteClientAndServerActions({
365369 const bundledIncrementActionResult = document . querySelector (
366370 '.host-remote-bundled-increment-action-result' ,
367371 ) ;
372+ const hostLocalActionResult = document . querySelector (
373+ '.host-local-action-result' ,
374+ ) ;
368375 return (
369376 defaultActionResult ?. textContent ?. trim ( ) ===
370377 'default-action:from-host-client' &&
@@ -379,7 +386,9 @@ async function supportRemoteClientAndServerActions({
379386 'remote-action:from-host-client-bundled' &&
380387 bundledNestedActionResult ?. textContent ?. trim ( ) ===
381388 'nested-action:from-host-client-bundled' &&
382- bundledIncrementActionResult ?. textContent ?. trim ( ) === '4'
389+ bundledIncrementActionResult ?. textContent ?. trim ( ) === '4' &&
390+ hostLocalActionResult ?. textContent ?. trim ( ) ===
391+ 'host-action:from-host-local'
383392 ) ;
384393 } ) ;
385394
@@ -624,30 +633,54 @@ function runTests({ mode }: TestConfig) {
624633 expect ( actionRequestIds . length ) . toBe ( EXPECTED_ACTION_POSTS_PER_MODE ) ;
625634 expect ( actionRequestIds . length ) . toBe ( actionRequestUrls . length ) ;
626635 expect ( actionRequestIds . length ) . toBe ( actionRequestAcceptHeaders . length ) ;
627- const uniqueActionRequestIds = new Set ( actionRequestIds ) ;
636+ const remoteActionRequestIds = actionRequestIds . filter ( id =>
637+ id . startsWith ( 'remote:rscRemote:' ) ,
638+ ) ;
639+ const hostLocalActionRequestIds = actionRequestIds . filter (
640+ id => ! id . startsWith ( 'remote:' ) ,
641+ ) ;
642+ const uniqueRemoteActionRequestIds = new Set ( remoteActionRequestIds ) ;
643+ const uniqueHostLocalActionRequestIds = new Set (
644+ hostLocalActionRequestIds ,
645+ ) ;
646+ expect ( remoteActionRequestIds . length ) . toBe (
647+ EXPECTED_REMOTE_ACTION_POSTS_PER_MODE ,
648+ ) ;
649+ expect ( hostLocalActionRequestIds . length ) . toBe (
650+ EXPECTED_HOST_ACTION_POSTS_PER_MODE ,
651+ ) ;
628652 expect (
629- actionRequestIds . every ( id =>
653+ remoteActionRequestIds . every ( id =>
630654 / ^ r e m o t e : r s c R e m o t e : [ a - f 0 - 9 ] { 64 , } $ / i. test ( id ) ,
631655 ) ,
632656 ) . toBe ( true ) ;
657+ expect (
658+ hostLocalActionRequestIds . every ( id => ! id . startsWith ( 'remote:' ) ) ,
659+ ) . toBe ( true ) ;
660+ expect ( hostLocalActionRequestIds . every ( id => id . length > 0 ) ) . toBe ( true ) ;
633661 expect (
634662 actionRequestAcceptHeaders . every (
635663 acceptHeader => acceptHeader . toLowerCase ( ) === 'text/x-component' ,
636664 ) ,
637665 ) . toBe ( true ) ;
638- expect ( uniqueActionRequestIds . size ) . toBe (
639- EXPECTED_UNIQUE_ACTION_IDS_PER_MODE ,
666+ expect ( uniqueRemoteActionRequestIds . size ) . toBe (
667+ EXPECTED_UNIQUE_REMOTE_ACTION_IDS_PER_MODE ,
640668 ) ;
641- const actionRequestCountById = new Map < string , number > ( ) ;
642- for ( const actionId of actionRequestIds ) {
643- actionRequestCountById . set (
669+ expect ( uniqueHostLocalActionRequestIds . size ) . toBe (
670+ EXPECTED_UNIQUE_HOST_ACTION_IDS_PER_MODE ,
671+ ) ;
672+ const remoteActionRequestCountById = new Map < string , number > ( ) ;
673+ for ( const actionId of remoteActionRequestIds ) {
674+ remoteActionRequestCountById . set (
644675 actionId ,
645- ( actionRequestCountById . get ( actionId ) || 0 ) + 1 ,
676+ ( remoteActionRequestCountById . get ( actionId ) || 0 ) + 1 ,
646677 ) ;
647678 }
648- expect ( actionRequestCountById . size ) . toBe ( uniqueActionRequestIds . size ) ;
679+ expect ( remoteActionRequestCountById . size ) . toBe (
680+ uniqueRemoteActionRequestIds . size ,
681+ ) ;
649682 expect (
650- [ ...actionRequestCountById . values ( ) ] . every (
683+ [ ...remoteActionRequestCountById . values ( ) ] . every (
651684 count => count === EXPECTED_ACTION_POSTS_PER_FAMILY ,
652685 ) ,
653686 ) . toBe ( true ) ;
0 commit comments