


























@@ -82,6 +82,93 @@ describe("cron method validation", () => {
8282getRuntimeConfig.mockReset().mockReturnValue({} as OpenClawConfig);
8383});
848485+it("accepts threadId on announce delivery add params", async () => {
86+getRuntimeConfig.mockReturnValue({
87+channels: {
88+telegram: {
89+botToken: "telegram-token",
90+},
91+},
92+plugins: {
93+entries: {
94+telegram: { enabled: true },
95+},
96+},
97+} as OpenClawConfig);
98+99+const { context, respond } = await invokeCronAdd({
100+name: "topic announce add",
101+enabled: true,
102+schedule: { kind: "every", everyMs: 60_000 },
103+sessionTarget: "isolated",
104+wakeMode: "next-heartbeat",
105+payload: { kind: "agentTurn", message: "hello" },
106+delivery: {
107+mode: "announce",
108+channel: "telegram",
109+to: "-1001234567890",
110+threadId: 123,
111+},
112+});
113+114+expect(context.cron.add).toHaveBeenCalledWith(
115+expect.objectContaining({
116+delivery: expect.objectContaining({
117+mode: "announce",
118+channel: "telegram",
119+to: "-1001234567890",
120+threadId: 123,
121+}),
122+}),
123+);
124+expect(respond).toHaveBeenCalledWith(true, { id: "cron-1" }, undefined);
125+});
126+127+it("accepts threadId on announce delivery update params", async () => {
128+getRuntimeConfig.mockReturnValue({
129+channels: {
130+telegram: {
131+botToken: "telegram-token",
132+},
133+},
134+plugins: {
135+entries: {
136+telegram: { enabled: true },
137+},
138+},
139+} as OpenClawConfig);
140+141+const { context, respond } = await invokeCronUpdate(
142+{
143+id: "cron-1",
144+patch: {
145+delivery: {
146+mode: "announce",
147+channel: "telegram",
148+to: "-1001234567890",
149+threadId: "456",
150+},
151+},
152+},
153+createCronJob({
154+delivery: { mode: "announce", channel: "telegram", to: "-1001234567890" },
155+}),
156+);
157+158+expect(context.cron.update).toHaveBeenCalledWith(
159+"cron-1",
160+expect.objectContaining({
161+delivery: expect.objectContaining({
162+mode: "announce",
163+channel: "telegram",
164+to: "-1001234567890",
165+threadId: "456",
166+}),
167+}),
168+);
169+expect(respond).toHaveBeenCalledWith(true, { id: "cron-1" }, undefined);
170+});
171+85172it("rejects ambiguous announce delivery on add when multiple channels are configured", async () => {
86173getRuntimeConfig.mockReturnValue({
87174session: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。