fix(FN-6587): stabilize test lanes under production env

Normalize spawned Vitest processes to NODE_ENV=test so React/jsdom lanes do not inherit release-shell production mode. Split the compound-engineering plugin Vitest projects so Node-only setup and teardown only run in Node lanes, and quarantine the remaining broad-lane CE timeout flakes under the deletion ratchet.
This commit is contained in:
gsxdsm
2026-06-17 17:10:55 -07:00
parent 01b80db603
commit 822d5d1872
4 changed files with 65 additions and 4 deletions

View File

@@ -6,6 +6,12 @@ import { computeMaxWorkers } from "../core/src/__test-utils__/vitest-workers";
const maxWorkers = computeMaxWorkers({ defaultCap: 3 });
/*
FNXC:DashboardTests 2026-06-17-17:02:
Dashboard tests must be insulated from release-oriented shells that export NODE_ENV=production. Force test mode before Vitest resolves React and Testing Library so jsdom projects keep React.act and do not fail after slow browser-environment startup.
*/
process.env.NODE_ENV = "test";
// Curated-gate skip-list (plan U2 / R7). Files listed here run in NO project on
// purpose (pre-existing failures discovered when the curated-gate hole was
// closed). The skip-list is the single source of truth shared with

View File

@@ -4,6 +4,12 @@ import { computeMaxWorkers } from "../../packages/core/src/__test-utils__/vitest
const maxWorkers = computeMaxWorkers();
/*
FNXC:CompoundEngineeringTests 2026-06-17-17:02:
Direct CE plugin test commands must behave like the central pnpm test runner even when the caller's shell exports NODE_ENV=production. Force test mode before Vitest resolves React Testing Library so jsdom tests use React's act-capable test path.
*/
process.env.NODE_ENV = "test";
const coreSetup = fileURLToPath(
new URL("../../packages/core/src/__test-utils__/vitest-setup.ts", import.meta.url),
);
@@ -12,10 +18,18 @@ const dashboardSetup = fileURLToPath(new URL("./src/dashboard/test-setup.ts", im
/*
FNXC:CompoundEngineeringTests 2026-06-17-12:35:
FN-6587 quarantines the CE broad-pnpm-test timeout flakes without timeout appeasement. Keep these excludes mirrored in scripts/lib/test-quarantine.json and remove or delete the files when the 14-day ratchet resolves.
FNXC:CompoundEngineeringTests 2026-06-17-17:18:
The CE broad package lane still times out in sync/work-bridge hooks under project concurrency while both files pass in isolation. Quarantine the files under the deletion ratchet instead of raising hook timeouts or serializing the whole plugin lane.
*/
const quarantinedCompoundEngineeringTests = [
"src/__tests__/orchestrator-flow.test.ts",
"src/__tests__/skill-wiring.test.ts",
"src/__tests__/sync.test.ts",
"src/__tests__/work-bridge.test.ts",
];
const nodeOnlyDashboardTests = [
"src/dashboard/__tests__/theme-tokens.test.ts",
];
export default defineConfig({
@@ -42,8 +56,6 @@ export default defineConfig({
],
},
test: {
// coreSetup runs for all projects via extends: true inheritance.
setupFiles: [coreSetup],
globalSetup: [fileURLToPath(new URL("../../packages/core/src/__test-utils__/vitest-teardown.ts", import.meta.url))],
pool: "threads",
maxWorkers,
@@ -55,7 +67,18 @@ export default defineConfig({
name: "compound-engineering-dashboard",
environment: "jsdom",
include: ["src/dashboard/**/__tests__/**/*.test.{ts,tsx}", "src/dashboard/**/*.test.{ts,tsx}"],
// jsdom-specific setup; coreSetup is inherited via extends: true.
exclude: nodeOnlyDashboardTests,
globalSetup: [],
/*
FNXC:CompoundEngineeringTests 2026-06-17-16:50:
Dashboard tests run in jsdom and must not inherit the core Node-only isolation setup. That setup imports node:module/node:worker_threads and makes Vite externalize built-ins during browser-style setup, which regressed the CE test lane into slow startup followed by ERR_UNKNOWN_BUILTIN_MODULE.
FNXC:CompoundEngineeringTests 2026-06-17-16:54:
File-inspection dashboard tests that read CSS from disk are Node tests even though they live beside React tests. Keep them out of the jsdom project so fs/path/url imports are not browser-externalized.
FNXC:CompoundEngineeringTests 2026-06-17-17:10:
Projects that do not run the core isolation setup must not inherit its global teardown. Otherwise a completed dashboard project can remove FUSION_TEST_WORKER_ROOT while the CE Node project is still redirecting tmpdir writes there.
*/
setupFiles: [dashboardSetup],
},
},
@@ -65,6 +88,7 @@ export default defineConfig({
name: "compound-engineering-node",
environment: "node",
include: ["src/**/__tests__/**/*.test.{ts,tsx}", "src/**/*.test.{ts,tsx}"],
setupFiles: [coreSetup],
exclude: [
"src/dashboard/**/__tests__/**/*.test.{ts,tsx}",
"src/dashboard/**/*.test.{ts,tsx}",
@@ -72,6 +96,16 @@ export default defineConfig({
],
},
},
{
extends: true,
test: {
name: "compound-engineering-dashboard-node",
environment: "node",
include: nodeOnlyDashboardTests,
globalSetup: [],
setupFiles: [],
},
},
],
},
});

View File

@@ -20,6 +20,16 @@
"file": "plugins/fusion-plugin-compound-engineering/src/__tests__/skill-wiring.test.ts",
"reason": "FN-6587 broad pnpm test investigation: this CE skill-wiring file was reported as timing out at Vitest's 5000ms test limit only in the broad pnpm test workflow; isolated two-file repro and loaded compound-engineering-node runs passed, and the broad command hit its external 900s workflow timeout before reproducing the named CE timeout. Quarantined per deletion-ratchet policy without timeout bumps, retries, or assertion loosening.",
"quarantinedAt": "2026-06-17"
},
{
"file": "plugins/fusion-plugin-compound-engineering/src/__tests__/sync.test.ts",
"reason": "CE broad package verification under NODE_ENV=production fix hit a 10000ms beforeEach hook timeout only in the full @fusion-plugin-examples/compound-engineering lane, while an immediate isolated compound-engineering-node run of sync.test.ts passed in 15.43s. Quarantined per deletion-ratchet policy without hookTimeout increases, retries, or assertion loosening.",
"quarantinedAt": "2026-06-17"
},
{
"file": "plugins/fusion-plugin-compound-engineering/src/__tests__/work-bridge.test.ts",
"reason": "CE broad package verification under NODE_ENV=production fix hit a 10000ms beforeEach hook timeout only in the full @fusion-plugin-examples/compound-engineering lane, while an immediate isolated compound-engineering-node run of work-bridge.test.ts passed in 10.96s. Quarantined per deletion-ratchet policy without hookTimeout increases, retries, or assertion loosening.",
"quarantinedAt": "2026-06-17"
}
]
}

View File

@@ -1184,8 +1184,19 @@ export function createIsolatedHomeEnv(env = process.env) {
return { env: nextEnv, isolatedHome };
}
export function createTestProcessEnv(env = process.env) {
/*
FNXC:TestInfrastructure 2026-06-17-17:02:
Developer shells and release scripts can export NODE_ENV=production, but Vitest must resolve React, Testing Library, and Vite transforms through their test/development paths. Normalize spawned test processes here so pnpm test cannot inherit production React test-utils and stall/fail jsdom lanes.
*/
return {
...env,
NODE_ENV: "test",
};
}
const fullSuiteEnv = {
...process.env,
...createTestProcessEnv(process.env),
FUSION_TEST_TOTAL_WORKERS: process.env.FUSION_TEST_TOTAL_WORKERS || String(totalWorkers),
FUSION_TEST_CONCURRENCY: process.env.FUSION_TEST_CONCURRENCY || String(concurrency),
};