mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 01:11:36 +00:00
test(auto-reply): cover inbound timestamp guard
This commit is contained in:
@@ -145,6 +145,36 @@ describe("buildInboundUserContextPrefix", () => {
|
|||||||
expect(conversationInfo["sender"]).toBe("+15551234567");
|
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", () => {
|
it("includes message_id in conversation info", () => {
|
||||||
const text = buildInboundUserContextPrefix({
|
const text = buildInboundUserContextPrefix({
|
||||||
ChatType: "group",
|
ChatType: "group",
|
||||||
|
|||||||
Reference in New Issue
Block a user