@@ -431,6 +431,48 @@ function defineTest(f: Fixture) {
431431 await page . reload ( )
432432 await expect ( page . getByText ( 'ok (test-shared)' ) ) . toBeVisible ( )
433433 } )
434+
435+ test ( 'hmr switch server to client' , async ( { page } ) => {
436+ await page . goto ( f . url ( ) )
437+ await waitForHydration ( page )
438+ await using _ = await expectNoReload ( page )
439+
440+ await expect ( page . getByTestId ( 'test-hmr-switch-server' ) ) . toContainText (
441+ '(useState: false)' ,
442+ )
443+ const editor = f . createEditor ( 'src/routes/hmr-switch/server.tsx' )
444+ editor . edit ( ( s ) => `"use client";\n` + s )
445+ await expect ( page . getByTestId ( 'test-hmr-switch-server' ) ) . toContainText (
446+ '(useState: true)' ,
447+ )
448+
449+ await page . waitForTimeout ( 100 )
450+ editor . reset ( )
451+ await expect ( page . getByTestId ( 'test-hmr-switch-server' ) ) . toContainText (
452+ '(useState: false)' ,
453+ )
454+ } )
455+
456+ test ( 'hmr switch client to server' , async ( { page } ) => {
457+ await page . goto ( f . url ( ) )
458+ await waitForHydration ( page )
459+ await using _ = await expectNoReload ( page )
460+
461+ await expect ( page . getByTestId ( 'test-hmr-switch-client' ) ) . toContainText (
462+ '(useState: true)' ,
463+ )
464+ const editor = f . createEditor ( 'src/routes/hmr-switch/client.tsx' )
465+ editor . edit ( ( s ) => s . replace ( `'use client'` , '' ) )
466+ await expect ( page . getByTestId ( 'test-hmr-switch-client' ) ) . toContainText (
467+ '(useState: false)' ,
468+ )
469+
470+ await page . waitForTimeout ( 100 )
471+ editor . reset ( )
472+ await expect ( page . getByTestId ( 'test-hmr-switch-client' ) ) . toContainText (
473+ '(useState: true)' ,
474+ )
475+ } )
434476 } )
435477
436478 test ( 'css @js' , async ( { page } ) => {
0 commit comments