mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
Merged via squash.
Prepared head SHA: a6f48309fd
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { vi } from "vitest";
|
|
import type { OpenClawPluginApi } from "../runtime-api.js";
|
|
|
|
export type BoundTaskFlow = ReturnType<
|
|
NonNullable<OpenClawPluginApi["runtime"]>["taskFlow"]["bindSession"]
|
|
>;
|
|
|
|
export function createFakeTaskFlow(overrides?: Partial<BoundTaskFlow>): BoundTaskFlow {
|
|
const baseFlow = {
|
|
flowId: "flow-1",
|
|
revision: 1,
|
|
syncMode: "managed" as const,
|
|
controllerId: "tests/lobster",
|
|
ownerKey: "agent:main:main",
|
|
status: "running" as const,
|
|
goal: "Run Lobster workflow",
|
|
};
|
|
|
|
return {
|
|
sessionKey: "agent:main:main",
|
|
createManaged: vi.fn().mockReturnValue(baseFlow),
|
|
get: vi.fn(),
|
|
list: vi.fn().mockReturnValue([]),
|
|
findLatest: vi.fn(),
|
|
resolve: vi.fn(),
|
|
getTaskSummary: vi.fn(),
|
|
setWaiting: vi.fn().mockImplementation((input) => ({
|
|
applied: true,
|
|
flow: { ...baseFlow, revision: input.expectedRevision + 1, status: "waiting" as const },
|
|
})),
|
|
resume: vi.fn().mockImplementation((input) => ({
|
|
applied: true,
|
|
flow: { ...baseFlow, revision: input.expectedRevision + 1, status: "running" as const },
|
|
})),
|
|
finish: vi.fn().mockImplementation((input) => ({
|
|
applied: true,
|
|
flow: { ...baseFlow, revision: input.expectedRevision + 1, status: "completed" as const },
|
|
})),
|
|
fail: vi.fn().mockImplementation((input) => ({
|
|
applied: true,
|
|
flow: { ...baseFlow, revision: input.expectedRevision + 1, status: "failed" as const },
|
|
})),
|
|
requestCancel: vi.fn(),
|
|
cancel: vi.fn(),
|
|
runTask: vi.fn(),
|
|
...overrides,
|
|
};
|
|
}
|