44 buildAppPageElement ,
55 resolveAppPageActionRerenderTarget ,
66 resolveAppPageIntercept ,
7- resolveAppPageInterceptMatch ,
7+ resolveAppPageInterceptionRerenderTarget ,
88 resolveAppPageGenerateStaticParamsSources ,
99 validateAppPageDynamicParams ,
1010} from "../packages/vinext/src/server/app-page-request.js" ;
@@ -681,7 +681,7 @@ describe("app page request helpers", () => {
681681 } ) ;
682682} ) ;
683683
684- describe ( "resolveAppPageInterceptMatch " , ( ) => {
684+ describe ( "resolveAppPageInterceptionRerenderTarget intercept loading " , ( ) => {
685685 const sourceRoute = { params : [ ] , pattern : "/feed" } ;
686686 const currentRoute = { params : [ "id" ] , pattern : "/photos/[id]" } ;
687687
@@ -695,56 +695,7 @@ describe("resolveAppPageInterceptMatch", () => {
695695 interceptSlotKey : intercept . slotKey ,
696696 } ) ;
697697
698- it ( "returns null on non-RSC requests" , async ( ) => {
699- const result = await resolveAppPageInterceptMatch ( {
700- cleanPathname : "/photos/123" ,
701- currentRoute,
702- findIntercept ( ) {
703- throw new Error ( "should not look up intercepts on non-RSC requests" ) ;
704- } ,
705- getRouteParamNames : ( route ) => route . params ,
706- getSourceRoute : ( ) => sourceRoute ,
707- isRscRequest : false ,
708- toInterceptOpts,
709- } ) ;
710-
711- expect ( result ) . toBeNull ( ) ;
712- } ) ;
713-
714- it ( "returns null when findIntercept returns nothing" , async ( ) => {
715- const result = await resolveAppPageInterceptMatch ( {
716- cleanPathname : "/photos/123" ,
717- currentRoute,
718- findIntercept : ( ) => null ,
719- getRouteParamNames : ( route ) => route . params ,
720- getSourceRoute : ( ) => sourceRoute ,
721- isRscRequest : true ,
722- toInterceptOpts,
723- } ) ;
724-
725- expect ( result ) . toBeNull ( ) ;
726- } ) ;
727-
728- it ( "returns null when the source route is the current route" , async ( ) => {
729- const result = await resolveAppPageInterceptMatch ( {
730- cleanPathname : "/photos/123" ,
731- currentRoute,
732- findIntercept : ( ) => ( {
733- matchedParams : { id : "123" } ,
734- page : { default : "modal-page" } ,
735- slotKey : "modal@app/photos/@modal" ,
736- sourceRouteIndex : 0 ,
737- } ) ,
738- getRouteParamNames : ( route ) => route . params ,
739- getSourceRoute : ( ) => currentRoute ,
740- isRscRequest : true ,
741- toInterceptOpts,
742- } ) ;
743-
744- expect ( result ) . toBeNull ( ) ;
745- } ) ;
746-
747- it ( "returns sourceRoute, sourceParams, matchedParams, and interceptOpts when an intercept applies" , async ( ) => {
698+ it ( "returns the source route, params, navigation params, and intercept options" , async ( ) => {
748699 const matchedParams = { id : "123" } ;
749700 const intercept = {
750701 matchedParams,
@@ -753,8 +704,9 @@ describe("resolveAppPageInterceptMatch", () => {
753704 sourceRouteIndex : 0 ,
754705 } ;
755706
756- const result = await resolveAppPageInterceptMatch ( {
707+ const result = await resolveAppPageInterceptionRerenderTarget ( {
757708 cleanPathname : "/photos/123" ,
709+ currentParams : matchedParams ,
758710 currentRoute,
759711 findIntercept : ( ) => intercept ,
760712 getRouteParamNames : ( route ) => route . params ,
@@ -763,13 +715,12 @@ describe("resolveAppPageInterceptMatch", () => {
763715 toInterceptOpts,
764716 } ) ;
765717
766- expect ( result ) . not . toBeNull ( ) ;
767- expect ( result ?. sourceRoute ) . toBe ( sourceRoute ) ;
768- expect ( result ?. matchedParams ) . toBe ( matchedParams ) ;
718+ expect ( result . route ) . toBe ( sourceRoute ) ;
719+ expect ( result . navigationParams ) . toEqual ( matchedParams ) ;
769720 // sourceParams keeps only the params declared by the source route.
770721 // /feed has no dynamic params, so the slice is empty.
771- expect ( result ?. sourceParams ) . toEqual ( { } ) ;
772- expect ( result ? .interceptOpts ) . toEqual ( toInterceptOpts ( intercept ) ) ;
722+ expect ( result . params ) . toEqual ( { } ) ;
723+ expect ( result . interceptOpts ) . toEqual ( toInterceptOpts ( intercept ) ) ;
773724 } ) ;
774725
775726 it ( "deduplicates concurrent intercept page and layout loads" , async ( ) => {
@@ -794,6 +745,7 @@ describe("resolveAppPageInterceptMatch", () => {
794745 } ;
795746 const options = {
796747 cleanPathname : "/photos/123" ,
748+ currentParams : { id : "123" } ,
797749 currentRoute,
798750 findIntercept : ( ) => ( { ...intercept , page : sharedLoadState . page } ) ,
799751 getRouteParamNames : ( route : { params : string [ ] } ) => route . params ,
@@ -803,8 +755,8 @@ describe("resolveAppPageInterceptMatch", () => {
803755 } ;
804756
805757 await Promise . all ( [
806- resolveAppPageInterceptMatch ( options ) ,
807- resolveAppPageInterceptMatch ( options ) ,
758+ resolveAppPageInterceptionRerenderTarget ( options ) ,
759+ resolveAppPageInterceptionRerenderTarget ( options ) ,
808760 ] ) ;
809761
810762 expect ( __pageLoader ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -845,8 +797,9 @@ describe("resolveAppPageInterceptMatch", () => {
845797
846798 const liveCookie = await runWithRequestContext ( requestContext , async ( ) => {
847799 const live = ( await cookies ( ) ) . get ( "session" ) ?. value ;
848- await resolveAppPageInterceptMatch ( {
800+ await resolveAppPageInterceptionRerenderTarget ( {
849801 cleanPathname : "/photos/123" ,
802+ currentParams : { id : "123" } ,
850803 currentRoute,
851804 findIntercept : ( ) => intercept ,
852805 getRouteParamNames : ( route : { params : string [ ] } ) => route . params ,
@@ -869,8 +822,9 @@ describe("resolveAppPageInterceptMatch", () => {
869822 const categorySourceRoute = { params : [ "category" ] , pattern : "/feed/[category]" } ;
870823 const matchedParams = { category : "nature" , id : "123" } ;
871824
872- const result = await resolveAppPageInterceptMatch ( {
825+ const result = await resolveAppPageInterceptionRerenderTarget ( {
873826 cleanPathname : "/photos/123" ,
827+ currentParams : matchedParams ,
874828 currentRoute,
875829 findIntercept : ( ) => ( {
876830 matchedParams,
@@ -885,8 +839,8 @@ describe("resolveAppPageInterceptMatch", () => {
885839 toInterceptOpts,
886840 } ) ;
887841
888- expect ( result ?. sourceParams ) . toEqual ( { category : "nature" } ) ;
889- expect ( result ?. matchedParams ) . toEqual ( { category : "nature" , id : "123" } ) ;
842+ expect ( result . params ) . toEqual ( { category : "nature" } ) ;
843+ expect ( result . navigationParams ) . toEqual ( { category : "nature" , tab : "recent ", id : "123" } ) ;
890844 } ) ;
891845} ) ;
892846
0 commit comments