Unverified Commit 71de7e6a authored by Jamiboy Mohammad's avatar Jamiboy Mohammad Committed by GitHub

test: migrate and explain root-inference deploy exclusions (#99012)

## Summary

Base this PR directly on #98430 and migrate the six workspace-root
inference suites from `skipDeployment` to `@force-gate !deploy`,
including removal of their `skipped` early returns. This PR now contains
its own conversions and no longer depends on the migration in #98156.

Retain the deployment exclusions with concrete explanations: Vercel’s
builder supplies `NEXT_PRIVATE_OUTPUT_TRACE_ROOT`, bypassing automatic
workspace-root inference. Diagnostic assertions would not exercise that
path, while successful imports and absent warnings would not establish
that workspace detection worked. The home-directory boundary tests also
change `HOME` for a locally managed Next.js process.

## Verification

- Formatting and ESLint passed for all six files.
- All 24 gate pragma-transform unit tests passed, including
`describe.each` support.
- Verified all six force-gates attach successfully and test logic
matches #98430 after removing only the legacy deployment skip machinery.
Final file contents match the previously reviewed PR head.
- Deployment-mode collection and gate-runtime tests were blocked by
missing `node-fetch` in the local installation; no deployments ran.
- Bootstrap and watch builds were attempted but stalled without output
and were stopped.

<!-- NEXT_JS_LLM -->
parent a28f7acf
......@@ -2,8 +2,12 @@ import { join } from 'path'
import { FileRef, nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// This test checks automatic workspace-root inference from multiple lockfiles.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference
// and the warning asserted here.
// @force-gate !deploy
describe('multiple-lockfiles', () => {
const { next, skipped, isTurbopack } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: {
app: new FileRef(join(__dirname, 'app')),
// Write a package-lock.json file to the parent directory to simulate
......@@ -21,16 +25,11 @@ describe('multiple-lockfiles', () => {
},
// So that ../package-lock.json doesn't leave the isolated testDir
subDir: 'test',
skipDeployment: true,
// The workspace file would be treated as the root and suppress the
// warning.
deleteWorkspaceFile: true,
})
if (skipped) {
return
}
it('should have multiple lockfiles warnings', async () => {
await retry(async () => {
expect(next.cliOutput).toMatch(
......
import { nextTestSetup } from 'e2e-utils'
// This test checks workspace-root inference from pnpm-workspace.yaml.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference.
// Successful imports and absent warnings would not verify workspace detection.
// @force-gate !deploy
describe('pnpm-workspace-root', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
'app/layout.tsx': `
import { ReactNode } from 'react'
......@@ -44,13 +48,8 @@ describe('pnpm-workspace-root', () => {
},
// So that parent files don't leave the isolated testDir
subDir: 'test',
skipDeployment: true,
})
if (skipped) {
return
}
it('should detect root directory from pnpm-workspace.yaml and allow imports from outside app dir', async () => {
// The app should start successfully when pnpm-workspace.yaml is present
// and correctly resolve imports from outside the Next.js app directory
......
......@@ -8,8 +8,12 @@ import { packageJson, packageLock } from './test-utils'
// ├── .git/
// ├── package-lock.json
// └── app/ the Next.js app
// This test checks that workspace-root inference stops at a Git boundary.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference
// and the boundary diagnostics asserted here.
// @force-gate !deploy
describe('root-detection - git repository boundary', () => {
const { next, skipped, isTurbopack } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: {
app: new FileRef(join(__dirname, 'app')),
// a `.git` directory makes the parent directory a repository root.
......@@ -21,16 +25,11 @@ describe('root-detection - git repository boundary', () => {
},
// So that the files written above don't leave the isolated testDir
subDir: 'repo/app',
skipDeployment: true,
// The workspace file would stop the search before the Git boundary does,
// so the test wouldn't be exercising the boundary.
deleteWorkspaceFile: true,
})
if (skipped) {
return
}
it('should not select a root above the repository', async () => {
const repoDir = dirname(next.testDir)
const aboveRepoDir = dirname(repoDir)
......
......@@ -13,8 +13,12 @@ import {
// ├── .git a file pointing at the Git directory
// ├── package-lock.json
// └── app/ the Next.js app
// This test checks that workspace-root inference stops at a Git worktree boundary.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference
// and the root-selection diagnostics asserted here.
// @force-gate !deploy
describe('root-detection - git worktree boundary', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
app: new FileRef(join(__dirname, 'app')),
'../.git': 'gitdir: ../repo/.git/worktrees/worktree\n',
......@@ -28,16 +32,11 @@ describe('root-detection - git worktree boundary', () => {
},
// So that the files written above don't leave the isolated testDir
subDir: 'worktree/app',
skipDeployment: true,
// The workspace file would stop the search before the worktree boundary
// does, so the test wouldn't be exercising the boundary.
deleteWorkspaceFile: true,
})
if (skipped) {
return
}
it('should not select a root above the worktree', async () => {
const worktreeDir = dirname(next.testDir)
......
......@@ -41,10 +41,15 @@ const cases: Array<{
},
]
// This test checks workspace-root inference at a home directory boundary.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference
// and the boundary diagnostics asserted here.
// It also changes HOME for a locally managed Next.js process.
// @force-gate !deploy
describe.each(cases)(
'root-detection - home directory boundary ($name)',
({ getHome, getRoot, getRootLockFile }) => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
app: new FileRef(join(__dirname, 'app')),
'../package.json': packageJson('project'),
......@@ -54,7 +59,6 @@ describe.each(cases)(
},
// So that the files written above don't leave the isolated testDir
subDir: 'project/app',
skipDeployment: true,
// The workspace file would stop the search before the home directory
// boundary does, so the test wouldn't be exercising the boundary.
deleteWorkspaceFile: true,
......@@ -64,10 +68,6 @@ describe.each(cases)(
startCommand: `${nextBin} ${isNextDev ? 'dev' : 'start'}`,
})
if (skipped) {
return
}
beforeAll(async () => {
const home = getHome(next.testDir)
next.env.HOME = home
......
......@@ -15,8 +15,12 @@ import {
// ├── package-lock.json
// ├── shared/utils.ts imported by the app
// └── test/ the Next.js app, with a lockfile of its own
// This test checks workspace-root inference from package.json workspaces.
// Vercel's builder sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT, bypassing that inference.
// Successful imports and absent warnings would not verify workspace detection.
// @force-gate !deploy
describe('root-detection - package.json workspaces', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
app: new FileRef(join(__dirname, 'workspace-app')),
'../package.json': packageJson('workspace-root', {
......@@ -28,16 +32,11 @@ describe('root-detection - package.json workspaces', () => {
},
// So that the files written above don't leave the isolated testDir
subDir: 'test',
skipDeployment: true,
// The workspace file would make the app directory a workspace root of its
// own, so the test wouldn't be exercising the `workspaces` field.
deleteWorkspaceFile: true,
})
if (skipped) {
return
}
it('should select the workspace root as the root', async () => {
// the app imports a file from the workspace root, which is only reachable
// when the root includes it.
......
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