mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 08:02:56 +00:00
test(channels): cover suppressed group progress callbacks
This commit is contained in:
@@ -2026,6 +2026,70 @@ describe("dispatchReplyFromConfig", () => {
|
||||
expect(dispatcher.sendFinalReply).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("forwards channel-owned group progress callbacks while source delivery is suppressed", async () => {
|
||||
setNoAbort();
|
||||
sessionStoreMocks.currentEntry = {
|
||||
verboseLevel: "off",
|
||||
};
|
||||
const cfg = automaticGroupReplyConfig;
|
||||
const dispatcher = createDispatcher();
|
||||
const ctx = buildTestCtx({
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
ChatType: "group",
|
||||
From: "telegram:group:-100123",
|
||||
SessionKey: "agent:main:telegram:group:-100123",
|
||||
});
|
||||
const onToolStart = vi.fn();
|
||||
const onItemEvent = vi.fn();
|
||||
const onCommandOutput = vi.fn();
|
||||
const onToolResult = vi.fn();
|
||||
|
||||
const replyResolver = async (
|
||||
_ctx: MsgContext,
|
||||
opts?: GetReplyOptions,
|
||||
_cfg?: OpenClawConfig,
|
||||
) => {
|
||||
await opts?.onToolStart?.({ name: "exec", phase: "start" });
|
||||
await opts?.onItemEvent?.({ itemId: "1", kind: "tool", progressText: "running exec" });
|
||||
await opts?.onCommandOutput?.({ phase: "end", name: "exec", status: "ok", exitCode: 0 });
|
||||
await opts?.onToolResult?.({ text: "exec: ok" });
|
||||
return { text: "done" } satisfies ReplyPayload;
|
||||
};
|
||||
|
||||
await dispatchReplyFromConfig({
|
||||
ctx,
|
||||
cfg,
|
||||
dispatcher,
|
||||
replyResolver,
|
||||
replyOptions: {
|
||||
sourceReplyDeliveryMode: "message_tool_only",
|
||||
suppressDefaultToolProgressMessages: true,
|
||||
allowProgressCallbacksWhenSourceDeliverySuppressed: true,
|
||||
onToolStart,
|
||||
onItemEvent,
|
||||
onCommandOutput,
|
||||
onToolResult,
|
||||
},
|
||||
});
|
||||
|
||||
expect(onToolStart).toHaveBeenCalledWith({ name: "exec", phase: "start" });
|
||||
expect(onItemEvent).toHaveBeenCalledWith({
|
||||
itemId: "1",
|
||||
kind: "tool",
|
||||
progressText: "running exec",
|
||||
});
|
||||
expect(onCommandOutput).toHaveBeenCalledWith({
|
||||
phase: "end",
|
||||
name: "exec",
|
||||
status: "ok",
|
||||
exitCode: 0,
|
||||
});
|
||||
expect(onToolResult).not.toHaveBeenCalled();
|
||||
expect(dispatcher.sendToolResult).not.toHaveBeenCalled();
|
||||
expect(dispatcher.sendFinalReply).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("exposes live tool-summary state to reply_dispatch hooks", () => {
|
||||
let shouldSendToolSummaries = false;
|
||||
const event = dispatchFromConfigTesting.createReplyDispatchEvent({
|
||||
|
||||
Reference in New Issue
Block a user