mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:20:44 +00:00
test(tasks): add control runtime override seam
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { vi } from "vitest";
|
||||
import {
|
||||
resetTaskRegistryControlRuntimeForTests,
|
||||
resetTaskRegistryDeliveryRuntimeForTests,
|
||||
resetTaskRegistryForTests,
|
||||
setTaskRegistryControlRuntimeForTests,
|
||||
setTaskRegistryDeliveryRuntimeForTests,
|
||||
} from "../../tasks/runtime-internal.js";
|
||||
import { resetTaskFlowRegistryForTests } from "../../tasks/task-flow-runtime-internal.js";
|
||||
@@ -12,13 +14,6 @@ const runtimeTaskMocks = vi.hoisted(() => ({
|
||||
killSubagentRunAdminMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../tasks/task-registry-control.runtime.js", () => ({
|
||||
getAcpSessionManager: () => ({
|
||||
cancelSession: runtimeTaskMocks.cancelSessionMock,
|
||||
}),
|
||||
killSubagentRunAdmin: (params: unknown) => runtimeTaskMocks.killSubagentRunAdminMock(params),
|
||||
}));
|
||||
|
||||
export function getRuntimeTaskMocks() {
|
||||
return runtimeTaskMocks;
|
||||
}
|
||||
@@ -27,11 +22,18 @@ export function installRuntimeTaskDeliveryMock(): void {
|
||||
setTaskRegistryDeliveryRuntimeForTests({
|
||||
sendMessage: runtimeTaskMocks.sendMessageMock,
|
||||
});
|
||||
setTaskRegistryControlRuntimeForTests({
|
||||
getAcpSessionManager: () => ({
|
||||
cancelSession: runtimeTaskMocks.cancelSessionMock,
|
||||
}),
|
||||
killSubagentRunAdmin: (params: unknown) => runtimeTaskMocks.killSubagentRunAdminMock(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function resetRuntimeTaskTestState(
|
||||
taskRegistryOptions?: Parameters<typeof resetTaskRegistryForTests>[0],
|
||||
): void {
|
||||
resetTaskRegistryControlRuntimeForTests();
|
||||
resetTaskRegistryDeliveryRuntimeForTests();
|
||||
resetTaskRegistryForTests(taskRegistryOptions);
|
||||
resetTaskFlowRegistryForTests({ persist: false });
|
||||
|
||||
Reference in New Issue
Block a user