test(FN-000): address follow-up review feedback

This commit is contained in:
Aron Prins
2026-05-07 18:08:08 +02:00
parent 7357a75a6a
commit 0b4a7bbe4e
5 changed files with 29 additions and 24 deletions

View File

@@ -180,12 +180,20 @@ describe("PR checks workflow (.github/workflows/pr-checks.yml)", () => {
it("keeps build coverage as an explicit PR gate", () => { it("keeps build coverage as an explicit PR gate", () => {
const buildSteps = workflow.jobs?.build?.steps ?? []; const buildSteps = workflow.jobs?.build?.steps ?? [];
expect(buildSteps.some((step: any) => step.name === "Build" && step.run === "pnpm build")).toBe(true); expect(
buildSteps.some(
(step: any) => step.name === "Build" && typeof step.run === "string" && step.run.includes("pnpm build"),
),
).toBe(true);
}); });
it("does not spend PR action minutes on a pre-test workspace build", () => { it("does not spend PR action minutes on a pre-test workspace build", () => {
const testSteps = workflow.jobs?.["test-shards"]?.steps ?? []; const testSteps = workflow.jobs?.["test-shards"]?.steps ?? [];
expect(testSteps.some((step: any) => step.name === "Build" || step.run === "pnpm build")).toBe(false); expect(
testSteps.some(
(step: any) => step.name === "Build" || (typeof step.run === "string" && step.run.includes("pnpm build")),
),
).toBe(false);
}); });
}); });

View File

@@ -22,6 +22,11 @@ function loadRootPackageJson(): any {
return JSON.parse(readFileSync(path, "utf-8")); return JSON.parse(readFileSync(path, "utf-8"));
} }
function hasProjectArg(script: string | undefined, project: string): boolean {
const parts = script?.trim().split(/\s+/) ?? [];
return parts.some((part, index) => part === "--project" && parts[index + 1] === project);
}
describe("CLI package.json publishing config", () => { describe("CLI package.json publishing config", () => {
const pkg = loadPackageJson("cli"); const pkg = loadPackageJson("cli");
@@ -249,10 +254,18 @@ describe("Workspace bootstrap script contract", () => {
}); });
it("keeps dashboard's default test lane curated with explicit deep coverage", () => { it("keeps dashboard's default test lane curated with explicit deep coverage", () => {
expect(dashboardPkg.scripts?.test).toContain("--project dashboard-app-quality"); const defaultTest = dashboardPkg.scripts?.test;
expect(dashboardPkg.scripts?.test).toContain("--project dashboard-api-quality"); const deepTest = dashboardPkg.scripts?.["test:deep"];
expect(dashboardPkg.scripts?.["test:deep"]).toContain("--project dashboard-app");
expect(dashboardPkg.scripts?.["test:deep"]).toContain("--project dashboard-api"); expect(hasProjectArg(defaultTest, "dashboard-app-quality")).toBe(true);
expect(hasProjectArg(defaultTest, "dashboard-api-quality")).toBe(true);
expect(hasProjectArg(defaultTest, "dashboard-app")).toBe(false);
expect(hasProjectArg(defaultTest, "dashboard-api")).toBe(false);
expect(hasProjectArg(deepTest, "dashboard-app")).toBe(true);
expect(hasProjectArg(deepTest, "dashboard-api")).toBe(true);
expect(hasProjectArg(deepTest, "dashboard-app-quality")).toBe(false);
expect(hasProjectArg(deepTest, "dashboard-api-quality")).toBe(false);
}); });
}); });

View File

@@ -67,16 +67,6 @@ const DEFAULT_TEST_SUBPROCESS_TIMEOUT_MS = Math.max(
const BLOCKED_TEST_CLI_PATTERN = const BLOCKED_TEST_CLI_PATTERN =
/(^|[\s"'\\/])(?:claude|droid|paperclipai|hermes|openclaw)(?:\.(?:cmd|bat|ps1|exe))?(?=$|[\s"'\\/])/i; /(^|[\s"'\\/])(?:claude|droid|paperclipai|hermes|openclaw)(?:\.(?:cmd|bat|ps1|exe))?(?=$|[\s"'\\/])/i;
const originalEmitWarning = process.emitWarning.bind(process);
process.emitWarning = ((warning: string | Error, ...args: unknown[]) => {
const message = typeof warning === "string" ? warning : warning?.message ?? "";
const type = typeof args[0] === "string" ? args[0] : (args[0] as { type?: string } | undefined)?.type;
if (type === "ExperimentalWarning" && message.includes("SQLite is an experimental feature")) {
return;
}
return (originalEmitWarning as (...a: unknown[]) => void)(warning, ...args);
}) as typeof process.emitWarning;
const originalCwd = process.cwd.bind(process); const originalCwd = process.cwd.bind(process);
function ensureValidCwd(): string { function ensureValidCwd(): string {

View File

@@ -18,6 +18,5 @@ export default defineConfig({
globalSetup: [fileURLToPath(new URL("../../packages/core/src/__test-utils__/vitest-teardown.ts", import.meta.url))], globalSetup: [fileURLToPath(new URL("../../packages/core/src/__test-utils__/vitest-teardown.ts", import.meta.url))],
pool: "threads", pool: "threads",
maxWorkers, maxWorkers,
poolOptions: { threads: { minThreads: 1, maxThreads: maxWorkers } },
}, },
}); });

View File

@@ -54,12 +54,7 @@ function hasSharedIsolation(config) {
} }
function hasSharedWorkerBudget(config) { function hasSharedWorkerBudget(config) {
return ( return /computeMaxWorkers/.test(config) && /\bmaxWorkers\b/.test(config);
/computeMaxWorkers/.test(config) &&
/\bmaxWorkers\b/.test(config) &&
/\bpoolOptions\b/.test(config) &&
/\bmax(?:Threads|Forks)\s*:\s*maxWorkers\b/.test(config)
);
} }
test("workspace packages with test scripts use shared Vitest governance", () => { test("workspace packages with test scripts use shared Vitest governance", () => {
@@ -89,7 +84,7 @@ test("workspace packages with test scripts use shared Vitest governance", () =>
failures.push(`${manifest.name}: missing shared vitest setup/teardown isolation`); failures.push(`${manifest.name}: missing shared vitest setup/teardown isolation`);
} }
if (!hasSharedWorkerBudget(config)) { if (!hasSharedWorkerBudget(config)) {
failures.push(`${manifest.name}: missing shared computeMaxWorkers/maxWorkers poolOptions budget`); failures.push(`${manifest.name}: missing shared computeMaxWorkers/maxWorkers budget`);
} }
} }