From a62889f6c2955b99e7cbfa22d0de4e432b1cfa9e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 13:14:50 +0100 Subject: [PATCH] test: tighten commitment chain assertions --- ...commitments-full-chain.integration.test.ts | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/commitments/commitments-full-chain.integration.test.ts b/src/commitments/commitments-full-chain.integration.test.ts index 97401227a60..d09608500fc 100644 --- a/src/commitments/commitments-full-chain.integration.test.ts +++ b/src/commitments/commitments-full-chain.integration.test.ts @@ -112,14 +112,12 @@ describe("commitments full-chain integration", () => { if (!pendingCommitment) { throw new Error("Expected pending commitment"); } - expect(pendingCommitment).toMatchObject({ - status: "pending", - agentId: "main", - sessionKey, - channel: "telegram", - to: "155462274", - suggestedText: "How did the interview go?", - }); + expect(pendingCommitment.status).toBe("pending"); + expect(pendingCommitment.agentId).toBe("main"); + expect(pendingCommitment.sessionKey).toBe(sessionKey); + expect(pendingCommitment.channel).toBe("telegram"); + expect(pendingCommitment.to).toBe("155462274"); + expect(pendingCommitment.suggestedText).toBe("How did the interview go?"); expect(pendingCommitment.dueWindow.earliestMs).toBe(dueMs); expect(pendingCommitment).not.toHaveProperty("sourceUserText"); expect(pendingCommitment).not.toHaveProperty("sourceAssistantText"); @@ -161,21 +159,22 @@ describe("commitments full-chain integration", () => { }); expect(result.status).toBe("ran"); - expect(sendTelegram).toHaveBeenCalledWith( - "155462274", - "How did the interview go?", - expect.objectContaining({ accountId: "primary" }), - ); + expect(sendTelegram).toHaveBeenCalledOnce(); + const sendCall = sendTelegram.mock.calls[0]; + if (!sendCall) { + throw new Error("Expected Telegram send call"); + } + expect(sendCall[0]).toBe("155462274"); + expect(sendCall[1]).toBe("How did the interview go?"); + expect(sendCall[2]?.accountId).toBe("primary"); const deliveredStore = await loadCommitmentStore(); const [deliveredCommitment] = deliveredStore.commitments; if (!deliveredCommitment) { throw new Error("Expected delivered commitment"); } - expect(deliveredCommitment).toMatchObject({ - status: "sent", - attempts: 1, - sentAtMs: dueMs + 60_000, - }); + expect(deliveredCommitment.status).toBe("sent"); + expect(deliveredCommitment.attempts).toBe(1); + expect(deliveredCommitment.sentAtMs).toBe(dueMs + 60_000); }); }); });