refactor(deadcode): privatize core test seams (#108325)

* refactor(entry): privatize compile cache internals

* refactor(logging): privatize diagnostic test seams

* refactor(plugin-state): privatize store test seams

* refactor(skills): privatize lifecycle test seams

* refactor(node-host): privatize invoke test seam

* refactor(system-agent): privatize turn test seam

* chore(deadcode): shrink core test seam baseline
This commit is contained in:
Peter Steinberger
2026-07-15 06:37:40 -07:00
committed by GitHub
parent 20bf422cc7
commit 674dd37cd0
49 changed files with 500 additions and 101 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
/** Tests the built-in node-host MCP invocation command. */
import { describe, expect, it, vi } from "vitest";
import type { GatewayClient } from "../gateway/client.js";
import { handleInvoke, testing } from "./invoke.js";
import { handleInvoke } from "./invoke.js";
import { testing } from "./invoke.test-support.js";
import { NodeHostMcpError, type NodeHostMcpManager } from "./mcp.js";
async function invokeMcp(manager: NodeHostMcpManager, params: unknown) {
+1 -1
View File
@@ -2,7 +2,7 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { testing } from "./invoke.js";
import { testing } from "./invoke.test-support.js";
describe("runCommand", () => {
afterEach(() => {
+35
View File
@@ -0,0 +1,35 @@
import type { RunResult } from "./invoke-types.js";
import "./invoke.js";
type NodeHostInvokeTestApi = {
readonly MCP_TEXT_CONTENT_MAX_BYTES: number;
readonly MCP_INVOKE_PAYLOAD_MAX_BYTES: number;
clarifyNodeExecCwdSpawnError(error: NodeJS.ErrnoException, cwd: string | undefined): string;
runCommand(
argv: string[],
cwd: string | undefined,
env: Record<string, string> | undefined,
timeoutMs: number | undefined,
): Promise<RunResult>;
};
function getTestApi(): NodeHostInvokeTestApi {
return (globalThis as Record<PropertyKey, unknown>)[
Symbol.for("openclaw.nodeHostInvokeTestApi")
] as NodeHostInvokeTestApi;
}
export const testing: NodeHostInvokeTestApi = {
get MCP_TEXT_CONTENT_MAX_BYTES() {
return getTestApi().MCP_TEXT_CONTENT_MAX_BYTES;
},
get MCP_INVOKE_PAYLOAD_MAX_BYTES() {
return getTestApi().MCP_INVOKE_PAYLOAD_MAX_BYTES;
},
clarifyNodeExecCwdSpawnError(error, cwd) {
return getTestApi().clarifyNodeExecCwdSpawnError(error, cwd);
},
runCommand(argv, cwd, env, timeoutMs) {
return getTestApi().runCommand(argv, cwd, env, timeoutMs);
},
};
+6 -1
View File
@@ -1075,10 +1075,15 @@ async function sendNodeEvent(client: NodeHostClient, event: string, payload: unk
}
}
export const testing = {
const testing = {
MCP_TEXT_CONTENT_MAX_BYTES,
MCP_INVOKE_PAYLOAD_MAX_BYTES,
clarifyNodeExecCwdSpawnError,
runCommand,
} as const;
if (process.env.VITEST || process.env.NODE_ENV === "test") {
(globalThis as Record<PropertyKey, unknown>)[Symbol.for("openclaw.nodeHostInvokeTestApi")] =
testing;
}
/* oxlint-disable max-lines -- TODO: split this grandfathered oversized file. */