@@ -238,6 +238,42 @@ function defineTest(f: Fixture) {
238238 await testUseActionState ( page )
239239 } )
240240
241+ test ( 'useActionState nojs to js' , async ( { page, browserName } ) => {
242+ // firefox seems to cache html and route interception doesn't work
243+ test . skip ( browserName === 'firefox' )
244+
245+ // this test fails without `formState` passed to `hydrateRoot(..., { formState })`
246+
247+ // intercept request to disable js
248+ let js : boolean
249+ await page . route ( f . url ( ) , async ( route ) => {
250+ if ( ! js ) {
251+ await route . continue ( { url : route . request ( ) . url ( ) + '?__nojs' } )
252+ return
253+ }
254+ await route . continue ( )
255+ } )
256+
257+ // no js
258+ js = false
259+ await page . goto ( f . url ( ) )
260+ await expect ( page . getByTestId ( 'use-action-state' ) ) . toContainText (
261+ 'test-useActionState: 0' ,
262+ )
263+ await page . getByTestId ( 'use-action-state' ) . click ( )
264+ await expect ( page . getByTestId ( 'use-action-state' ) ) . toContainText (
265+ 'test-useActionState: 1' ,
266+ )
267+
268+ // with js (hydration)
269+ js = true
270+ await page . getByTestId ( 'use-action-state' ) . click ( )
271+ await waitForHydration ( page )
272+ await expect ( page . getByTestId ( 'use-action-state' ) ) . toContainText (
273+ 'test-useActionState: 2' , // this becomes "0" without formState
274+ )
275+ } )
276+
241277 async function testUseActionState ( page : Page ) {
242278 await expect ( page . getByTestId ( 'use-action-state' ) ) . toContainText (
243279 'test-useActionState: 0' ,
0 commit comments