test(auto-reply): cover inbound timestamp guard

This commit is contained in:
Shakker
2026-02-26 16:37:18 +00:00
committed by Shakker
parent c596658b8d
commit fe842b5f14

View File

@@ -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",