mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
e0966df114
## Summary - migrate Cache Components, PPR, prefetching, prerendering, revalidation, and SSG deployment exclusions to `@force-gate` - remove the corresponding `skipDeployment` options and `skipped` control flow while preserving each suite's rationale This keeps caching-related exclusions together so their deployed semantics can be reviewed by the same owners. ## Verification - verified on the combined top-of-stack tree with `pnpm typescript` - compared ordinary-mode collection before and after: all 4,670 existing test names matched - collected all 510 affected files in deploy mode: 4,578 skipped tests, zero failures <!-- NEXT_JS_LLM -->
116 lines
3.4 KiB
TypeScript
116 lines
3.4 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
const stackStart = /\s+at /
|
|
|
|
function createExpectError(cliOutput: string) {
|
|
let cliIndex = 0
|
|
return function expectError(
|
|
containing: string,
|
|
withStackContaining?: string
|
|
) {
|
|
const initialCliIndex = cliIndex
|
|
let lines = cliOutput.slice(cliIndex).split('\n')
|
|
|
|
let i = 0
|
|
while (i < lines.length) {
|
|
let line = lines[i++] + '\n'
|
|
cliIndex += line.length
|
|
if (line.includes(containing)) {
|
|
if (typeof withStackContaining !== 'string') {
|
|
return
|
|
} else {
|
|
while (i < lines.length) {
|
|
let stackLine = lines[i++] + '\n'
|
|
if (!stackStart.test(stackLine)) {
|
|
expect(stackLine).toContain(withStackContaining)
|
|
}
|
|
if (stackLine.includes(withStackContaining)) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
expect(cliOutput.slice(initialCliIndex)).toContain(containing)
|
|
}
|
|
}
|
|
|
|
describe(`Request Promises`, () => {
|
|
describe('On Prerender Completion', () => {
|
|
const { next, isNextDev } = nextTestSetup({
|
|
files: __dirname + '/fixtures/reject-hanging-promises-static',
|
|
skipStart: true,
|
|
})
|
|
|
|
if (isNextDev) {
|
|
it('does not run in dev', () => {})
|
|
return
|
|
}
|
|
|
|
it('should reject request APIs after the prerender is complete when it finishes naturally', async () => {
|
|
try {
|
|
await next.start()
|
|
} catch {
|
|
throw new Error('expected build not to fail for fully static project')
|
|
}
|
|
const expectError = createExpectError(next.cliOutput)
|
|
|
|
expectError(
|
|
'Error: During prerendering, `searchParams` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `params` rejects when the prerender is complete'
|
|
)
|
|
|
|
expectError(
|
|
'Error: During prerendering, `connection()` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `cookies()` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `headers()` rejects when the prerender is complete'
|
|
)
|
|
})
|
|
})
|
|
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
|
|
// It likely asserts local CLI or runtime output that deploy tests do not expose.
|
|
// @force-gate !deploy
|
|
describe('On Prerender Interruption', () => {
|
|
const { next, isNextDev } = nextTestSetup({
|
|
files: __dirname + '/fixtures/reject-hanging-promises-dynamic',
|
|
skipStart: true,
|
|
})
|
|
|
|
if (isNextDev) {
|
|
it('does not run in dev', () => {})
|
|
return
|
|
}
|
|
|
|
it('should reject request APIs after the prerender is interrupted with synchronously dynamic APIs', async () => {
|
|
try {
|
|
await next.start()
|
|
} catch {}
|
|
const expectError = createExpectError(next.cliOutput)
|
|
|
|
expectError(
|
|
'Error: During prerendering, `searchParams` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `params` rejects when the prerender is complete'
|
|
)
|
|
|
|
expectError(
|
|
'Error: During prerendering, `cookies()` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `headers()` rejects when the prerender is complete'
|
|
)
|
|
expectError(
|
|
'Error: During prerendering, `connection()` rejects when the prerender is complete'
|
|
)
|
|
})
|
|
})
|
|
})
|