mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Fixes a few failing deployment tests that weren't validated when landed last week. - next.cliOutput is not available when deployed because it's part of runtime logs - status code changes on Vercel because POSTing to a static 404 page is treated differently.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('app-dir - no server actions', () => {
|
|
const { next, isNextDeploy } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should error when triggering a fetch action on an app with no server actions', async () => {
|
|
const res = await next.fetch('/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Next-Action': 'abc123',
|
|
},
|
|
})
|
|
|
|
expect(res.status).toBe(404)
|
|
expect(res.headers.get('x-nextjs-action-not-found')).toBe('1')
|
|
|
|
// Runtime logs and custom headers are not forwarded to the client when deployed.
|
|
if (!isNextDeploy) {
|
|
expect(next.cliOutput).toContain(
|
|
'Failed to find Server Action "abc123". This request might be from an older or newer deployment.\nRead more: https://nextjs.org/docs/messages/failed-to-find-server-action'
|
|
)
|
|
}
|
|
})
|
|
|
|
it('should error when triggering an MPA action on an app with no server actions', async () => {
|
|
const formData = new FormData()
|
|
formData.append('test', 'value')
|
|
|
|
const res = await next.fetch('/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data; boundary=test',
|
|
},
|
|
// @ts-expect-error: node-fetch types don't seem to like FormData
|
|
body: formData,
|
|
})
|
|
|
|
expect(res.status).toBe(404)
|
|
expect(res.headers.get('x-nextjs-action-not-found')).toBe('1')
|
|
|
|
// Runtime logs are not available when deployed.
|
|
if (!isNextDeploy) {
|
|
expect(next.cliOutput).toContain(
|
|
'Failed to find Server Action. This request might be from an older or newer deployment.\nRead more: https://nextjs.org/docs/messages/failed-to-find-server-action'
|
|
)
|
|
}
|
|
})
|
|
})
|