mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 00:52:10 -06:00
3d76a4af92
* refactor(sessions): privatize runtime test seams * refactor(commitments): privatize extraction test seams * refactor(flows): privatize doctor health seams * refactor(tasks): privatize registry test seams * build(commitments): bundle Docker test support * chore(deadcode): shrink runtime export baseline
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
// Runtime task test harness helpers build mocked plugin runtimes for task-flow tests.
|
|
import { vi } from "vitest";
|
|
import {
|
|
resetDetachedTaskLifecycleRuntimeForTests,
|
|
resetTaskFlowRegistryForTests,
|
|
resetTaskRegistryControlRuntimeForTests,
|
|
resetTaskRegistryDeliveryRuntimeForTests,
|
|
resetTaskRegistryForTests,
|
|
setTaskRegistryControlRuntimeForTests,
|
|
setTaskRegistryDeliveryRuntimeForTests,
|
|
} from "../../tasks/task-runtime.test-helpers.js";
|
|
|
|
const runtimeTaskMocks = vi.hoisted(() => ({
|
|
sendMessageMock: vi.fn(),
|
|
cancelSessionMock: vi.fn(),
|
|
killSubagentRunAdminMock: vi.fn(),
|
|
}));
|
|
|
|
export function getRuntimeTaskMocks() {
|
|
return runtimeTaskMocks;
|
|
}
|
|
|
|
export function installRuntimeTaskDeliveryMock(): void {
|
|
setTaskRegistryDeliveryRuntimeForTests({
|
|
sendMessage: runtimeTaskMocks.sendMessageMock,
|
|
});
|
|
setTaskRegistryControlRuntimeForTests({
|
|
cancelActiveCronTaskRun: () => false,
|
|
getAcpSessionManager: () => ({
|
|
cancelSession: runtimeTaskMocks.cancelSessionMock,
|
|
}),
|
|
killSubagentRunAdmin: (params: unknown) => runtimeTaskMocks.killSubagentRunAdminMock(params),
|
|
});
|
|
}
|
|
|
|
export function resetRuntimeTaskTestState(
|
|
taskRegistryOptions?: Parameters<typeof resetTaskRegistryForTests>[0],
|
|
): void {
|
|
resetDetachedTaskLifecycleRuntimeForTests();
|
|
resetTaskRegistryControlRuntimeForTests();
|
|
resetTaskRegistryDeliveryRuntimeForTests();
|
|
resetTaskRegistryForTests(taskRegistryOptions);
|
|
resetTaskFlowRegistryForTests({ persist: false });
|
|
vi.clearAllMocks();
|
|
}
|