Files
openclaw/extensions/imessage/src/monitor/parse-notification.test.ts
Peter Steinberger fe79d85ae0 feat(imessage): add native imsg message actions
Adds native iMessage private-API message actions, lightweight message-tool discovery, bridge capability cache sharing, execution-time action gates, target alias coverage, and regression tests.
2026-05-08 05:34:22 +01:00

64 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { parseIMessageNotification } from "./parse-notification.js";
describe("parseIMessageNotification", () => {
it("strips a length-delimited field wrapper from text and reply_to_text", () => {
const wrappedText = `${String.fromCharCode(0x0a, 11)}hello world`;
const wrappedReply = `${String.fromCharCode(0x0a, 5)}quote`;
const raw = {
message: {
id: 1,
guid: "g",
chat_id: 2,
sender: "+10000000000",
destination_caller_id: null,
is_from_me: false,
text: wrappedText,
reply_to_id: null,
reply_to_text: wrappedReply,
reply_to_sender: null,
created_at: null,
attachments: null,
chat_identifier: null,
chat_guid: null,
chat_name: null,
participants: null,
is_group: false,
},
};
const parsed = parseIMessageNotification(raw);
expect(parsed?.text).toBe("hello world");
expect(parsed?.reply_to_text).toBe("quote");
});
it("preserves reaction event metadata", () => {
const parsed = parseIMessageNotification({
message: {
id: 1,
guid: "reaction-guid",
chat_id: 2,
sender: "+10000000000",
destination_caller_id: null,
is_from_me: false,
text: "",
is_reaction: true,
reaction_type: "like",
reaction_emoji: "👍",
is_reaction_add: true,
reacted_to_guid: "target-guid",
attachments: null,
chat_identifier: null,
chat_guid: null,
chat_name: null,
participants: null,
is_group: false,
},
});
expect(parsed?.is_reaction).toBe(true);
expect(parsed?.reaction_emoji).toBe("👍");
expect(parsed?.reacted_to_guid).toBe("target-guid");
});
});