mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 11:41:08 +00:00
refactor: dedupe plugin test harnesses
This commit is contained in:
@@ -1,46 +1,19 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { getTaskFlowById, resetTaskFlowRegistryForTests } from "../../tasks/task-flow-registry.js";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { getTaskFlowById } from "../../tasks/task-flow-registry.js";
|
||||
import { getTaskById } from "../../tasks/task-registry.js";
|
||||
import {
|
||||
getTaskById,
|
||||
resetTaskRegistryDeliveryRuntimeForTests,
|
||||
resetTaskRegistryForTests,
|
||||
setTaskRegistryDeliveryRuntimeForTests,
|
||||
} from "../../tasks/task-registry.js";
|
||||
installRuntimeTaskDeliveryMock,
|
||||
resetRuntimeTaskTestState,
|
||||
} from "./runtime-task-test-harness.js";
|
||||
import { createRuntimeTaskFlow } from "./runtime-taskflow.js";
|
||||
|
||||
const hoisted = vi.hoisted(() => {
|
||||
const sendMessageMock = vi.fn();
|
||||
const cancelSessionMock = vi.fn();
|
||||
const killSubagentRunAdminMock = vi.fn();
|
||||
return {
|
||||
sendMessageMock,
|
||||
cancelSessionMock,
|
||||
killSubagentRunAdminMock,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../../acp/control-plane/manager.js", () => ({
|
||||
getAcpSessionManager: () => ({
|
||||
cancelSession: hoisted.cancelSessionMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../../agents/subagent-control.js", () => ({
|
||||
killSubagentRunAdmin: (params: unknown) => hoisted.killSubagentRunAdminMock(params),
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
resetTaskRegistryDeliveryRuntimeForTests();
|
||||
resetTaskRegistryForTests({ persist: false });
|
||||
resetTaskFlowRegistryForTests({ persist: false });
|
||||
vi.clearAllMocks();
|
||||
resetRuntimeTaskTestState({ persist: false });
|
||||
});
|
||||
|
||||
describe("runtime TaskFlow", () => {
|
||||
beforeEach(() => {
|
||||
setTaskRegistryDeliveryRuntimeForTests({
|
||||
sendMessage: hoisted.sendMessageMock,
|
||||
});
|
||||
installRuntimeTaskDeliveryMock();
|
||||
});
|
||||
|
||||
it("binds managed TaskFlow operations to a session key", () => {
|
||||
|
||||
Reference in New Issue
Block a user