mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:31:25 +00:00
test: consolidate sessions_spawn and guardrail helpers
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user