Unverified Commit 9dd33e01 authored by Jamiboy Mohammad's avatar Jamiboy Mohammad Committed by GitHub

test: capture deployment experimental flags in config (#99534)

## Summary

Capture the partial-prefetching and cached-navigation test flags in
deployed configs through the shared helper introduced in #99533,
matching Cache Components. The helper owns the static list of
experimental flags; the deploy harness no longer sends or translates the
corresponding `NEXT_PRIVATE_EXPERIMENTAL_*` aliases. The fixed
`NEXT_PRIVATE_TEST_MODE=e2e` mode setup is retained.

This is the second layer of the stack. The monorepo fixtures in #99395
will use the same helper for their copied nested configs.

## Verification

- Executed generated assignments for all three flags, covering
enabled/disabled values, omitted values, string escaping, and capture
timing. Together with the existing deployment lifecycle suite: 41/41
unit tests passed.
- Real Vercel deployments of
`test/e2e/app-dir/hello-world/hello-world.test.ts` against
`16.4.0-canary.55`: 4/4 assertions passed with flags unset and 4/4 with
all three flags enabled. The enabled build explicitly reported Cache
Components and cached navigations enabled.
- Full bootstrap (18/18 tasks), formatting, and ESLint passed.

<!-- NEXT_JS_LLM -->
parent dfb6e044
const deploymentTestFlags = ['__NEXT_CACHE_COMPONENTS'] const deploymentTestFlags = [
'__NEXT_CACHE_COMPONENTS',
'__NEXT_PARTIAL_PREFETCHING',
'__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS',
]
/** /**
* Capture test flags in the deployed config because Vercel environment variable * Capture test flags in the deployed config because Vercel environment variable
......
...@@ -546,14 +546,6 @@ export class NextInstance { ...@@ -546,14 +546,6 @@ export class NextInstance {
if (process.env.NEXT_PRIVATE_TEST_MODE) { if (process.env.NEXT_PRIVATE_TEST_MODE) {
process.env.__NEXT_TEST_MODE = process.env.NEXT_PRIVATE_TEST_MODE process.env.__NEXT_TEST_MODE = process.env.NEXT_PRIVATE_TEST_MODE
} }
// alias experimental feature flags for deployment compatibility
if (process.env.NEXT_PRIVATE_EXPERIMENTAL_PARTIAL_PREFETCHING) {
process.env.__NEXT_PARTIAL_PREFETCHING = process.env.NEXT_PRIVATE_EXPERIMENTAL_PARTIAL_PREFETCHING
}
if (process.env.NEXT_PRIVATE_EXPERIMENTAL_CACHED_NAVIGATIONS) {
process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS = process.env.NEXT_PRIVATE_EXPERIMENTAL_CACHED_NAVIGATIONS
}
` `
) )
......
...@@ -493,18 +493,6 @@ export class NextDeployInstance extends NextInstance { ...@@ -493,18 +493,6 @@ export class NextDeployInstance extends NextInstance {
) )
} }
// Add experimental feature flags
if (process.env.__NEXT_PARTIAL_PREFETCHING) {
additionalEnv.push(
`NEXT_PRIVATE_EXPERIMENTAL_PARTIAL_PREFETCHING=${process.env.__NEXT_PARTIAL_PREFETCHING}`
)
}
if (process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS) {
additionalEnv.push(
`NEXT_PRIVATE_EXPERIMENTAL_CACHED_NAVIGATIONS=${process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS}`
)
}
if (process.env.IS_TURBOPACK_TEST) { if (process.env.IS_TURBOPACK_TEST) {
additionalEnv.push(`IS_TURBOPACK_TEST=1`) additionalEnv.push(`IS_TURBOPACK_TEST=1`)
} }
......
import { runInNewContext } from 'vm' import { runInNewContext } from 'vm'
import { getDeploymentTestEnvAssignments } from '../../lib/e2e-utils/deployment-test-env' import { getDeploymentTestEnvAssignments } from '../../lib/e2e-utils/deployment-test-env'
describe.each(['__NEXT_CACHE_COMPONENTS'])( describe.each([
'deployment capture of %s', '__NEXT_CACHE_COMPONENTS',
(flag) => { '__NEXT_PARTIAL_PREFETCHING',
'__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS',
])('deployment capture of %s', (flag) => {
beforeEach(() => { beforeEach(() => {
jest.replaceProperty(process, 'env', { jest.replaceProperty(process, 'env', {
...process.env, ...process.env,
__NEXT_CACHE_COMPONENTS: '', __NEXT_CACHE_COMPONENTS: '',
__NEXT_PARTIAL_PREFETCHING: '',
__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS: '',
}) })
}) })
...@@ -50,8 +54,7 @@ describe.each(['__NEXT_CACHE_COMPONENTS'])( ...@@ -50,8 +54,7 @@ describe.each(['__NEXT_CACHE_COMPONENTS'])(
expect(env[flag]).toBe('true') expect(env[flag]).toBe('true')
}) })
} })
)
it('does not copy unrelated environment variables into the config', () => { it('does not copy unrelated environment variables into the config', () => {
jest.replaceProperty(process, 'env', { jest.replaceProperty(process, 'env', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment