@@ -47,9 +47,18 @@ describe('issue #5106 - hydrating a server-committed notFound boundary', () => {
4747 component : ( ) => 'Post' ,
4848 notFoundComponent : ( ) => 'Post not found' ,
4949 } )
50+ const safeLoader = vi . fn ( ( ) => 'safe-data' )
51+ const safeRoute = new BaseRoute ( {
52+ getParentRoute : ( ) => rootRoute ,
53+ path : '/safe' ,
54+ loader : safeLoader ,
55+ } )
5056
5157 const router = createTestRouter ( {
52- routeTree : rootRoute . addChildren ( [ postsRoute . addChildren ( [ postRoute ] ) ] ) ,
58+ routeTree : rootRoute . addChildren ( [
59+ postsRoute . addChildren ( [ postRoute ] ) ,
60+ safeRoute ,
61+ ] ) ,
5362 history,
5463 isServer : false ,
5564 } )
@@ -112,16 +121,24 @@ describe('issue #5106 - hydrating a server-committed notFound boundary', () => {
112121 expect ( postsLoader ) . not . toHaveBeenCalled ( )
113122 expect ( postLoader ) . not . toHaveBeenCalled ( )
114123
115- // Every match settled: an unsettled loadPromise here is the #5106 freeze -
116- // the framework Match suspends on it and the parent never hydrates.
117- for ( const match of stateMatches ) {
118- expect ( match . _ . dehydrated ) . toBeUndefined ( )
119- expect ( match . _ . loadPromise ) . toBeUndefined ( )
120- }
121-
122124 // Hydration finished without needing a follow-up router.load().
123125 expect ( router . stores . resolvedLocation . get ( ) ) . toBeDefined ( )
124126 expect ( router . stores . isLoading . get ( ) ) . toBe ( false )
127+
128+ // Prove the hydrated lane did not freeze the router by leaving it able to
129+ // complete an ordinary client navigation. This observes the consequence
130+ // that matters without reading hydration/readiness bookkeeping.
131+ await router . navigate ( { to : '/safe' } )
132+ expect ( router . state . location . pathname ) . toBe ( '/safe' )
133+ expect ( router . state . isLoading ) . toBe ( false )
134+ expect ( router . state . matches . at ( - 1 ) ) . toMatchObject ( {
135+ routeId : safeRoute . id ,
136+ status : 'success' ,
137+ loaderData : 'safe-data' ,
138+ } )
139+ expect ( safeLoader ) . toHaveBeenCalledTimes ( 1 )
140+ expect ( postsLoader ) . not . toHaveBeenCalled ( )
141+ expect ( postLoader ) . not . toHaveBeenCalled ( )
125142 } )
126143
127144 it ( 'ancestor boundary replays the dehydrated notFound in the follow-up load instead of loading the omitted child' , async ( ) => {
@@ -147,9 +164,18 @@ describe('issue #5106 - hydrating a server-committed notFound boundary', () => {
147164 loader : postLoader ,
148165 component : ( ) => 'Post' ,
149166 } )
167+ const safeLoader = vi . fn ( ( ) => 'safe-data' )
168+ const safeRoute = new BaseRoute ( {
169+ getParentRoute : ( ) => rootRoute ,
170+ path : '/safe' ,
171+ loader : safeLoader ,
172+ } )
150173
151174 const router = createTestRouter ( {
152- routeTree : rootRoute . addChildren ( [ postsRoute . addChildren ( [ postRoute ] ) ] ) ,
175+ routeTree : rootRoute . addChildren ( [
176+ postsRoute . addChildren ( [ postRoute ] ) ,
177+ safeRoute ,
178+ ] ) ,
153179 history,
154180 isServer : false ,
155181 } )
@@ -210,11 +236,17 @@ describe('issue #5106 - hydrating a server-committed notFound boundary', () => {
210236 expect ( postLoader ) . not . toHaveBeenCalled ( )
211237 expect ( postsLoader ) . not . toHaveBeenCalled ( )
212238
213- // The committed lane is fully settled - nothing left for React to
214- // suspend on (the #5106 freeze).
215- for ( const match of stateMatches ) {
216- expect ( match . _ . dehydrated ) . toBeUndefined ( )
217- expect ( match . _ . loadPromise ) . toBeUndefined ( )
218- }
239+ // The replayed boundary must not strand subsequent client work.
240+ await router . navigate ( { to : '/safe' } )
241+ expect ( router . state . location . pathname ) . toBe ( '/safe' )
242+ expect ( router . state . isLoading ) . toBe ( false )
243+ expect ( router . state . matches . at ( - 1 ) ) . toMatchObject ( {
244+ routeId : safeRoute . id ,
245+ status : 'success' ,
246+ loaderData : 'safe-data' ,
247+ } )
248+ expect ( safeLoader ) . toHaveBeenCalledTimes ( 1 )
249+ expect ( postLoader ) . not . toHaveBeenCalled ( )
250+ expect ( postsLoader ) . not . toHaveBeenCalled ( )
219251 } )
220252} )
0 commit comments