





















@@ -63,6 +63,24 @@ describe("runHeartbeatOnce heartbeat response tool", () => {
6363};
6464}
656566+function expectTelegramSend(
67+sendTelegram: ReturnType<typeof vi.fn>,
68+params: { text: string; cfg: OpenClawConfig },
69+) {
70+expect(sendTelegram).toHaveBeenCalledTimes(1);
71+expect(sendTelegram.mock.calls).toEqual([
72+[
73+TELEGRAM_GROUP,
74+params.text,
75+{
76+verbose: false,
77+cfg: params.cfg,
78+accountId: undefined,
79+},
80+],
81+]);
82+}
83+6684async function runWithToolResponse(response: HeartbeatToolResponse) {
6785return await withTempTelegramHeartbeatSandbox(async ({ tmpDir, storePath, replySpy }) => {
6886const cfg = createConfig({ tmpDir, storePath });
@@ -79,7 +97,7 @@ describe("runHeartbeatOnce heartbeat response tool", () => {
7997deps: createDeps({ sendTelegram, getReplyFromConfig: replySpy }),
8098});
819982-return { result, sendTelegram, replySpy };
100+return { result, sendTelegram, replySpy, cfg };
83101});
84102}
85103@@ -154,20 +172,18 @@ describe("runHeartbeatOnce heartbeat response tool", () => {
154172});
155173156174it("delivers notificationText when notify=true", async () => {
157-const { sendTelegram } = await runWithToolResponse({
175+const { sendTelegram, cfg } = await runWithToolResponse({
158176outcome: "needs_attention",
159177notify: true,
160178summary: "Build is blocked.",
161179notificationText: "Build is blocked on missing credentials.",
162180priority: "high",
163181});
164182165-expect(sendTelegram).toHaveBeenCalledTimes(1);
166-expect(sendTelegram).toHaveBeenCalledWith(
167-TELEGRAM_GROUP,
168-"Build is blocked on missing credentials.",
169-expect.any(Object),
170-);
183+expectTelegramSend(sendTelegram, {
184+text: "Build is blocked on missing credentials.",
185+ cfg,
186+});
171187});
172188173189it("uses the heartbeat response tool prompt in message-tool mode", async () => {
@@ -215,12 +231,10 @@ describe("runHeartbeatOnce heartbeat response tool", () => {
215231};
216232expect(result.status).toBe("ran");
217233expect(calledOpts.sourceReplyDeliveryMode).toBe("message_tool_only");
218-expect(sendTelegram).toHaveBeenCalledTimes(1);
219-expect(sendTelegram).toHaveBeenCalledWith(
220-TELEGRAM_GROUP,
221-usageLimitMessage,
222-expect.any(Object),
223-);
234+expectTelegramSend(sendTelegram, {
235+text: usageLimitMessage,
236+ cfg,
237+});
224238});
225239});
226240此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。