From fe842b5f1446760907ce2d7a7e2ab81ce1f40716 Mon Sep 17 00:00:00 2001 From: Shakker Date: Thu, 26 Feb 2026 16:37:18 +0000 Subject: [PATCH] test(auto-reply): cover inbound timestamp guard --- src/auto-reply/reply/inbound-meta.test.ts | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/auto-reply/reply/inbound-meta.test.ts b/src/auto-reply/reply/inbound-meta.test.ts index a85cbadab..613fe934b 100644 --- a/src/auto-reply/reply/inbound-meta.test.ts +++ b/src/auto-reply/reply/inbound-meta.test.ts @@ -145,6 +145,36 @@ describe("buildInboundUserContextPrefix", () => { expect(conversationInfo["sender"]).toBe("+15551234567"); }); + it("includes formatted timestamp in conversation info when provided", () => { + const text = buildInboundUserContextPrefix({ + ChatType: "group", + MessageSid: "msg-with-ts", + Timestamp: Date.UTC(2026, 1, 15, 13, 35), + } as TemplateContext); + + const conversationInfo = parseConversationInfoPayload(text); + expect(conversationInfo["timestamp"]).toEqual(expect.any(String)); + }); + + it("omits invalid timestamps instead of throwing", () => { + expect(() => + buildInboundUserContextPrefix({ + ChatType: "group", + MessageSid: "msg-with-bad-ts", + Timestamp: 1e20, + } as TemplateContext), + ).not.toThrow(); + + const text = buildInboundUserContextPrefix({ + ChatType: "group", + MessageSid: "msg-with-bad-ts", + Timestamp: 1e20, + } as TemplateContext); + + const conversationInfo = parseConversationInfoPayload(text); + expect(conversationInfo["timestamp"]).toBeUndefined(); + }); + it("includes message_id in conversation info", () => { const text = buildInboundUserContextPrefix({ ChatType: "group",