























@@ -217,6 +217,17 @@ function expectReplyCall(
217217}
218218}
219219220+function replyBody(
221+replySpy: ReturnType<typeof vi.fn>,
222+index = 0,
223+): { Body?: string; ForceSenderIsOwnerFalse?: boolean; Provider?: string } {
224+return requireRecord(replySpy.mock.calls.at(index)?.at(0), `reply call ${index} body`) as {
225+Body?: string;
226+ForceSenderIsOwnerFalse?: boolean;
227+Provider?: string;
228+};
229+}
230+220231beforeAll(async () => {
221232previousRegistry = getActivePluginRegistry();
222233@@ -1470,7 +1481,7 @@ describe("runHeartbeatOnce", () => {
14701481expect(res.status).toBe("ran");
14711482expect(sendWhatsApp).toHaveBeenCalledTimes(1);
14721483expect(replySpy).toHaveBeenCalledTimes(1);
1473-const calledCtx = replySpy.mock.calls[0]?.[0] as { Body?: string };
1484+const calledCtx = replyBody(replySpy);
14741485const expectedPath = path.join(workspaceDir, "HEARTBEAT.md").replace(/\\/g, "/");
14751486expect(calledCtx.Body).toContain(`use workspace file ${expectedPath} (exact case)`);
14761487expect(calledCtx.Body).toContain("Do not read docs/heartbeat.md.");
@@ -1541,7 +1552,7 @@ Some global directive after tasks.
1541155215421553expect(res.status).toBe("ran");
15431554expect(replySpy).toHaveBeenCalledTimes(1);
1544-const calledCtx = replySpy.mock.calls[0]?.[0] as { Body?: string };
1555+const calledCtx = replyBody(replySpy);
15451556expect(calledCtx.Body).toContain("- inbox: Check urgent inbox items");
15461557expect(calledCtx.Body).toContain("- calendar: Check calendar changes");
15471558expect(calledCtx.Body).toContain("Additional context from HEARTBEAT.md");
@@ -1612,7 +1623,7 @@ tasks:
1612162316131624expect(res.status).toBe("ran");
16141625expect(replySpy).toHaveBeenCalledTimes(1);
1615-const calledCtx = replySpy.mock.calls[0]?.[0] as { Body?: string };
1626+const calledCtx = replyBody(replySpy);
16161627expect(calledCtx.Body).toContain("- inbox: Check urgent inbox items");
16171628expect(calledCtx.Body).toContain("- calendar: Check calendar changes");
16181629expect(calledCtx.Body).toContain("Additional context from HEARTBEAT.md");
@@ -1750,7 +1761,7 @@ tasks:
17501761expect(replySpy, name).toHaveBeenCalledTimes(expectedReplyCalls);
17511762expect(sendWhatsApp, name).toHaveBeenCalledTimes(expectedSendCalls);
17521763if (expectCronContext) {
1753-const calledCtx = replySpy.mock.calls[0]?.[0] as { Provider?: string; Body?: string };
1764+const calledCtx = replyBody(replySpy);
17541765expect(calledCtx.Provider, name).toBe("cron-event");
17551766expect(calledCtx.Body, name).toContain("scheduled reminder has been triggered");
17561767}
@@ -1808,7 +1819,7 @@ tasks:
18081819});
18091820expect(res.status).toBe("ran");
18101821expect(sendWhatsApp).toHaveBeenCalledTimes(0);
1811-const calledCtx = replySpy.mock.calls[0]?.[0] as { Provider?: string; Body?: string };
1822+const calledCtx = replyBody(replySpy);
18121823expect(calledCtx.Provider).toBe("cron-event");
18131824expect(calledCtx.Body).toContain("Handle this reminder internally");
18141825expect(calledCtx.Body).not.toContain("Please relay this reminder to the user");
@@ -1865,11 +1876,7 @@ tasks:
18651876});
18661877expect(res.status).toBe("ran");
18671878expect(sendWhatsApp).toHaveBeenCalledTimes(0);
1868-const calledCtx = replySpy.mock.calls[0]?.[0] as {
1869-Provider?: string;
1870-Body?: string;
1871-ForceSenderIsOwnerFalse?: boolean;
1872-};
1879+const calledCtx = replyBody(replySpy);
18731880expect(calledCtx.Provider).toBe("exec-event");
18741881expect(calledCtx.ForceSenderIsOwnerFalse).toBe(true);
18751882expect(calledCtx.Body).toContain("Handle the result internally");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。