rsnext/test/e2e/app-dir/actions/app-action-progressive-enhancement.test.ts
Sebastian Markbåge b095e9e980
Test Progressive Enhancement of Server Actions (#52062)
Adds a regression test for testing progressive enhancement of Server
Actions. Both when passed from a Server Component and when imported into
a Client Component.

#51723 landed a bit too early which broke this but it'll be fixed again
once React is upgraded.

Co-authored-by: Shu Ding <g@shud.in>
2023-07-06 18:21:59 +02:00

45 lines
1.4 KiB
TypeScript

/* eslint-disable jest/no-standalone-expect */
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
createNextDescribe(
'app-dir action progressive enhancement',
{
files: __dirname,
dependencies: {
react: 'latest',
nanoid: 'latest',
'react-dom': 'latest',
'server-only': 'latest',
},
},
({ next, isNextDev, isNextStart, isNextDeploy }) => {
it('should support formData and redirect without JS', async () => {
const browser = await next.browser('/server', {
disableJavaScript: true,
})
await browser.eval(`document.getElementById('name').value = 'test'`)
await browser.elementByCss('#submit').click()
await check(() => {
return browser.eval('window.location.pathname + window.location.search')
}, '/header?name=test&constructor=FormData&hidden-info=hi')
})
it('should support actions from client without JS', async () => {
const browser = await next.browser('/server', {
disableJavaScript: true,
})
await browser.eval(
`document.getElementById('client-name').value = 'test'`
)
await browser.elementByCss('#there').click()
await check(() => {
return browser.eval('window.location.pathname + window.location.search')
}, '/header?name=test&constructor=FormData&hidden-info=hi')
})
}
)