@@ -365,14 +365,15 @@ test.describe("Vite HMR & HDR (RSC)", () => {
365365 await expect ( clientComponent ) . toHaveText (
366366 "Imported Client Component HMR: 3" ,
367367 ) ;
368- await expect ( clientButton ) . toHaveText ( "Count: 1" ) ;
368+ await expect ( clientButton ) . toBeVisible ( ) ;
369369 await expect ( hdrStatus ) . toHaveText (
370370 "HDR updated: route & direct 2 & indirect 2" ,
371371 ) ;
372372 await expect ( input ) . toHaveValue ( "stateful" ) ;
373373 expect ( page . errors ) . toEqual ( [ ] ) ;
374374
375375 // switch from server-first to client route
376+ const waitPromise = page . waitForLoadState ( "load" ) ;
376377 await edit ( "app/routes/hmr/route.tsx" , ( contents ) =>
377378 contents
378379 . replace (
@@ -381,43 +382,11 @@ test.describe("Vite HMR & HDR (RSC)", () => {
381382 )
382383 . replace ( "HMR updated: 3" , "Client Route HMR: 0" ) ,
383384 ) ;
384- await page . waitForLoadState ( "networkidle" ) ;
385- await expect ( hmrStatus ) . toHaveText ( "Client Route HMR: 0" ) ;
386- // adding/removing client component exports causes an HMR invalidation and a
387- // page reload. some browsers maintain input state, so we forcibly clear
388- await input . clear ( ) ;
389- await input . type ( "client stateful" ) ;
390- expect ( page . errors ) . toEqual ( [ ] ) ;
391- await edit ( "app/routes/hmr/route.tsx" , ( contents ) =>
392- contents . replace ( "Client Route HMR: 0" , "Client Route HMR: 1" ) ,
393- ) ;
394- await page . waitForLoadState ( "networkidle" ) ;
395- await expect ( hmrStatus ) . toHaveText ( "Client Route HMR: 1" ) ;
396- await expect ( input ) . toHaveValue ( "client stateful" ) ;
397- expect ( page . errors ) . toEqual ( [ ] ) ;
398-
399- // switch from client route back to server-first route
400- await edit ( "app/routes/hmr/route.tsx" , ( contents ) =>
401- contents
402- . replace (
403- "export default function ClientComponent" ,
404- "export function ServerComponent" ,
405- )
406- . replace ( "Client Route HMR: 1" , "Server Route HMR: 0" ) ,
407- ) ;
408- await page . waitForLoadState ( "networkidle" ) ;
409- await expect ( hmrStatus ) . toHaveText ( "Server Route HMR: 0" ) ;
410- // adding/removing client component exports causes an HMR invalidation and a
411- // page reload. some browsers maintain input state, so we forcibly clear
412- await input . clear ( ) ;
413- await input . type ( "server stateful" ) ;
414- expect ( page . errors ) . toEqual ( [ ] ) ;
415- await edit ( "app/routes/hmr/route.tsx" , ( contents ) =>
416- contents . replace ( "Server Route HMR: 0" , "Server Route HMR: 1" ) ,
385+ await waitPromise ;
386+ // await page.waitForLoadState("networkidle");
387+ await expect ( page . locator ( "#index [data-mounted]" ) ) . toHaveText (
388+ "Mounted: yes" ,
417389 ) ;
418- await page . waitForLoadState ( "networkidle" ) ;
419- await expect ( hmrStatus ) . toHaveText ( "Server Route HMR: 1" ) ;
420- await expect ( input ) . toHaveValue ( "server stateful" ) ;
421- expect ( page . errors ) . toEqual ( [ ] ) ;
390+ await expect ( hmrStatus ) . toHaveText ( "Client Route HMR: 0" ) ;
422391 } ) ;
423392} ) ;
0 commit comments