test: route extension boundary inventory off unit

This commit is contained in:
Peter Steinberger
2026-04-03 11:29:27 +01:00
parent b406b7d2e4
commit 16ca1f4d74
4 changed files with 42 additions and 19 deletions

View File

@@ -1,9 +1,13 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES } from "../src/plugins/public-artifacts.js";
import { BUNDLED_PLUGIN_PATH_PREFIX } from "./helpers/bundled-plugin-paths.js";
const repoRoot = path.resolve(import.meta.dirname, "..");
const ALLOWED_EXTENSION_PUBLIC_SURFACE_BASENAMES = new Set(
GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES,
);
const allowedNonExtensionTests = new Set<string>([
"src/agents/pi-embedded-runner-extraparams.test.ts",
@@ -44,6 +48,20 @@ function findPluginSdkImports(source: string): string[] {
].map((match) => match[1]);
}
function getImportBasename(importPath: string): string {
return importPath.split("/").at(-1) ?? importPath;
}
function isAllowedCoreContractSuite(file: string, imports: readonly string[]): boolean {
return (
file.startsWith("src/channels/plugins/contracts/") &&
file.endsWith(".contract.test.ts") &&
imports.every((entry) =>
ALLOWED_EXTENSION_PUBLIC_SURFACE_BASENAMES.has(getImportBasename(entry)),
)
);
}
describe("non-extension test boundaries", () => {
it("keeps plugin-owned behavior suites under the bundled plugin tree", () => {
const testFiles = [
@@ -64,7 +82,7 @@ describe("non-extension test boundaries", () => {
if (imports.length === 0) {
return null;
}
if (allowedNonExtensionTests.has(file)) {
if (allowedNonExtensionTests.has(file) || isAllowedCoreContractSuite(file, imports)) {
return null;
}
return {

View File

@@ -524,25 +524,28 @@ describe("test planner", () => {
artifacts.cleanupTempArtifacts();
});
it("routes targeted boundary inventories through the lean boundary config", () => {
const artifacts = createExecutionArtifacts({});
const plan = buildExecutionPlan(
{
mode: "local",
surfaces: [],
passthroughArgs: ["test/web-search-provider-boundary.test.ts"],
},
{
env: {},
writeTempJsonArtifact: artifacts.writeTempJsonArtifact,
},
);
it.each(["test/extension-test-boundary.test.ts", "test/web-search-provider-boundary.test.ts"])(
"routes targeted boundary inventories through the lean boundary config: %s",
(file) => {
const artifacts = createExecutionArtifacts({});
const plan = buildExecutionPlan(
{
mode: "local",
surfaces: [],
passthroughArgs: [file],
},
{
env: {},
writeTempJsonArtifact: artifacts.writeTempJsonArtifact,
},
);
expect(plan.targetedUnits).toHaveLength(1);
expect(plan.targetedUnits[0]?.surface).toBe("unit");
expect(plan.targetedUnits[0]?.args).toContain("vitest.boundary.config.ts");
artifacts.cleanupTempArtifacts();
});
expect(plan.targetedUnits).toHaveLength(1);
expect(plan.targetedUnits[0]?.surface).toBe("unit");
expect(plan.targetedUnits[0]?.args).toContain("vitest.boundary.config.ts");
artifacts.cleanupTempArtifacts();
},
);
it("normalizes --bail=0 into collect-all failure policy", () => {
const artifacts = createExecutionArtifacts({});

View File

@@ -19,6 +19,7 @@ describe("isUnitConfigTestFile", () => {
expect(isUnitConfigTestFile("src/infra/matrix-plugin-helper.test.ts")).toBe(false);
expect(isUnitConfigTestFile("src/plugin-sdk/facade-runtime.test.ts")).toBe(false);
expect(isUnitConfigTestFile("src/plugins/loader.test.ts")).toBe(false);
expect(isUnitConfigTestFile("test/extension-test-boundary.test.ts")).toBe(false);
expect(isUnitConfigTestFile("src/agents/pi-embedded-runner.test.ts")).toBe(false);
expect(isUnitConfigTestFile("src/commands/onboard.test.ts")).toBe(false);
expect(isUnitConfigTestFile("ui/src/ui/views/other.test.ts")).toBe(false);

View File

@@ -17,6 +17,7 @@ export const unitTestIncludePatterns = [
export const boundaryTestFiles = [
"test/extension-plugin-sdk-boundary.test.ts",
"test/extension-test-boundary.test.ts",
"test/plugin-extension-import-boundary.test.ts",
"test/web-fetch-provider-boundary.test.ts",
"test/web-search-provider-boundary.test.ts",