test: consolidate sessions_spawn and guardrail helpers

This commit is contained in:
Peter Steinberger
2026-02-22 12:34:39 +01:00
parent 59191474eb
commit a4607277a9
9 changed files with 299 additions and 229 deletions

View File

@@ -1,7 +1,9 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import "./test-helpers/fast-core-tools.js";
import {
findGatewayRequest,
getCallGatewayMock,
getGatewayMethods,
getSessionsSpawnTool,
setSessionsSpawnConfigOverride,
} from "./openclaw-tools.subagents.sessions-spawn.test-harness.js";
@@ -46,21 +48,6 @@ vi.mock("../plugins/hook-runner-global.js", () => ({
})),
}));
type GatewayRequest = { method?: string; params?: Record<string, unknown> };
function getGatewayRequests(): GatewayRequest[] {
const callGatewayMock = getCallGatewayMock();
return callGatewayMock.mock.calls.map((call: [unknown]) => call[0] as GatewayRequest);
}
function getGatewayMethods(): Array<string | undefined> {
return getGatewayRequests().map((request) => request.method);
}
function findGatewayRequest(method: string): GatewayRequest | undefined {
return getGatewayRequests().find((request) => request.method === method);
}
function expectSessionsDeleteWithoutAgentStart() {
const methods = getGatewayMethods();
expect(methods).toContain("sessions.delete");