From 16ca1f4d7491e7ca93533b7e883dba6830e0e1fc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 3 Apr 2026 11:29:27 +0100 Subject: [PATCH] test: route extension boundary inventory off unit --- test/extension-test-boundary.test.ts | 20 +++++++++++++- test/scripts/test-planner.test.ts | 39 +++++++++++++++------------- test/vitest-unit-paths.test.ts | 1 + vitest.unit-paths.mjs | 1 + 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/test/extension-test-boundary.test.ts b/test/extension-test-boundary.test.ts index 98a9b931bd3..65f759d9b80 100644 --- a/test/extension-test-boundary.test.ts +++ b/test/extension-test-boundary.test.ts @@ -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([ "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 { diff --git a/test/scripts/test-planner.test.ts b/test/scripts/test-planner.test.ts index 011241020d2..52df0c9e46d 100644 --- a/test/scripts/test-planner.test.ts +++ b/test/scripts/test-planner.test.ts @@ -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({}); diff --git a/test/vitest-unit-paths.test.ts b/test/vitest-unit-paths.test.ts index d936d1c7062..6501a469a9b 100644 --- a/test/vitest-unit-paths.test.ts +++ b/test/vitest-unit-paths.test.ts @@ -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); diff --git a/vitest.unit-paths.mjs b/vitest.unit-paths.mjs index 10fcc87c386..779ba86ebf8 100644 --- a/vitest.unit-paths.mjs +++ b/vitest.unit-paths.mjs @@ -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",