import { describe, expect, it } from "vitest"; import type { FeishuMessageEvent } from "./bot.js"; import { isFeishuMessageFromSelf, parseFeishuMessageEvent } from "./bot.js"; describe("feishu self-authored message filtering", () => { it("recognizes events from the bot open id", () => { const event: FeishuMessageEvent = { sender: { sender_id: { open_id: "ou_bot" }, sender_type: "user", }, message: { message_id: "m1", chat_id: "c1", chat_type: "p2p", message_type: "text", content: JSON.stringify({ text: "own echo" }), }, }; const ctx = parseFeishuMessageEvent(event, "ou_bot"); expect(isFeishuMessageFromSelf(ctx, "ou_bot")).toBe(true); expect(isFeishuMessageFromSelf(ctx, "ou_other")).toBe(false); }); });