Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/plugin-rsc/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,42 @@ function defineTest(f: Fixture) {
await testUseActionState(page)
})

test('useActionState nojs to js', async ({ page, browserName }) => {
// firefox seems to cache html and route interception doesn't work
test.skip(browserName === 'firefox')

// this test fails without `formState` passed to `hydrateRoot(..., { formState })`

// intercept request to disable js
let js: boolean
await page.route(f.url(), async (route) => {
if (!js) {
await route.continue({ url: route.request().url() + '?__nojs' })
return
}
await route.continue()
})

// no js
js = false
await page.goto(f.url())
await expect(page.getByTestId('use-action-state')).toContainText(
'test-useActionState: 0',
)
await page.getByTestId('use-action-state').click()
await expect(page.getByTestId('use-action-state')).toContainText(
'test-useActionState: 1',
)

// with js (hydration)
js = true
await page.getByTestId('use-action-state').click()
await waitForHydration(page)
await expect(page.getByTestId('use-action-state')).toContainText(
'test-useActionState: 2', // this becomes "0" without formState
)
})

async function testUseActionState(page: Page) {
await expect(page.getByTestId('use-action-state')).toContainText(
'test-useActionState: 0',
Expand Down
Loading