mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-04 16:36:42 +02:00
test: route extension boundary inventory off unit
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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({});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user