@@ -84,8 +84,8 @@ test('a post-hydration root reload keeps its fallback through pendingMinMs', asy
8484 } )
8585
8686 expect ( rootLoader ) . toHaveBeenCalledTimes ( 1 )
87- expect ( screen . getByTestId ( 'root-pending' ) ) . toBeInTheDocument ( )
88- expect ( screen . getByTestId ( 'root-content' ) ) . not . toBeVisible ( )
87+ expect ( screen . queryByTestId ( 'root-pending' ) ) . not . toBeInTheDocument ( )
88+ expect ( screen . getByTestId ( 'root-content' ) ) . toHaveTextContent ( 'Generation 1' )
8989
9090 await act ( async ( ) => {
9191 reloadGate . resolve ( )
@@ -95,7 +95,7 @@ test('a post-hydration root reload keeps its fallback through pendingMinMs', asy
9595 await act ( async ( ) => {
9696 await vi . advanceTimersByTimeAsync ( 99 )
9797 } )
98- expect ( screen . getByTestId ( 'root-pending' ) ) . toBeInTheDocument ( )
98+ expect ( screen . queryByTestId ( 'root-pending' ) ) . not . toBeInTheDocument ( )
9999
100100 await act ( async ( ) => {
101101 await vi . advanceTimersByTimeAsync ( 1 )
@@ -105,7 +105,7 @@ test('a post-hydration root reload keeps its fallback through pendingMinMs', asy
105105 expect ( screen . getByTestId ( 'root-content' ) ) . toHaveTextContent ( 'Generation 2' )
106106} )
107107
108- test ( 'root route hydration preserves component state across its Suspense boundary ' , async ( ) => {
108+ test ( 'root route hydration without a pending boundary preserves component state ' , async ( ) => {
109109 const mounts = vi . fn ( )
110110 const unmounts = vi . fn ( )
111111 const initializers = vi . fn ( ( ) => 'preserved' )
@@ -127,14 +127,13 @@ test('root route hydration preserves component state across its Suspense boundar
127127 } )
128128 await router . load ( )
129129
130- // Model the server render and the client router produced by hydrate(). The
131- // outer root boundary is intentionally absent from both trees, while the
132- // route's own pending boundary is present in both.
130+ // Model the server render and the client router produced by hydrate(). A root
131+ // without a separate shell stays unwrapped on both sides of hydration.
133132 router . ssr = { manifest : { routes : { } } }
134133 router . isServer = true
135134 const html = renderToString ( < RouterProvider router = { router } /> )
136135 router . isServer = false
137- expect ( html ) . toContain ( '<!--$-->' )
136+ expect ( html ) . not . toContain ( '<!--$-->' )
138137 expect ( html ) . toContain ( 'preserved' )
139138
140139 const container = document . createElement ( 'div' )
@@ -153,19 +152,23 @@ test('root route hydration preserves component state across its Suspense boundar
153152 } )
154153
155154 expect ( container ) . toHaveTextContent ( 'preserved' )
156- // One initializer belongs to the server render and one to client
157- // hydration. The stable boundary must preserve that hydrated client
158- // instance instead of creating a third one.
155+ // One initializer belongs to the server render and one to client hydration.
159156 expect ( initializers ) . toHaveBeenCalledTimes ( 2 )
160157 expect ( mounts ) . toHaveBeenCalledTimes ( 1 )
161158 expect ( unmounts ) . not . toHaveBeenCalled ( )
162159 expect ( consoleError ) . not . toHaveBeenCalled ( )
163160} )
164161
165- test ( 'server rendering uses the root pending boundary for route component suspension ' , async ( ) => {
162+ test ( 'server rendering uses the root pending boundary inside its document shell ' , async ( ) => {
166163 const gate = createControlledPromise < void > ( )
167164 const rootRoute = createRootRoute ( {
168165 pendingComponent : ( ) => < div > Server root pending</ div > ,
166+ shellComponent : ( { children } ) => (
167+ < html >
168+ < head />
169+ < body > { children } </ body >
170+ </ html >
171+ ) ,
169172 component : ( ) => {
170173 throw gate
171174 } ,
@@ -179,8 +182,7 @@ test('server rendering uses the root pending boundary for route component suspen
179182
180183 const html = renderToString ( < RouterProvider router = { router } /> )
181184
182- // renderToString cannot wait for Suspense, but the root route's stable
183- // boundary contains the suspension and emits its fallback. Streaming SSR
184- // can wait for the same boundary instead.
185+ // renderToString cannot wait for Suspense, but the boundary inside the root
186+ // shell contains the suspension and emits its fallback.
185187 expect ( html ) . toContain ( 'Server root pending' )
186188} )
0 commit comments