Fix action failures due to state tree encoding (#53655)

fixes #53654

### Related PRs
- #51017
This commit is contained in:
yudai yamamoto 2023-08-07 19:02:48 +09:00 committed by GitHub
parent 78b04980be
commit b993afbf7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -52,7 +52,7 @@ async function fetchServerAction(
headers: {
Accept: RSC_CONTENT_TYPE_HEADER,
'Next-Action': actionId,
[NEXT_ROUTER_STATE_TREE]: JSON.stringify(state.tree),
[NEXT_ROUTER_STATE_TREE]: encodeURIComponent(JSON.stringify(state.tree)),
...(process.env.__NEXT_ACTIONS_DEPLOYMENT_ID &&
process.env.NEXT_DEPLOYMENT_ID
? {

View file

@ -393,6 +393,16 @@ createNextDescribe(
return newTestCookie !== currentTestCookie ? 'success' : 'failure'
}, 'success')
})
it('should handle unicode search params', async () => {
const browser = await next.browser('/server?name=名')
const cnt = await browser.elementByCss('h1').text()
expect(cnt).toBe('0')
await browser.elementByCss('#inc').click()
await check(() => browser.elementByCss('h1').text(), '1')
})
})
describe('fetch actions', () => {