forked from bai/curriculum-project-hub
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { readFeishuContext } from "../../src/feishu/read.js";
|
|
import type { FeishuRuntime } from "../../src/feishu/client.js";
|
|
|
|
describe("readFeishuContext", () => {
|
|
it("compacts Feishu message.get replies with parent_id, thread_id, and body.content", async () => {
|
|
const rt = {
|
|
client: {
|
|
im: {
|
|
v1: {
|
|
message: {
|
|
get: async () => ({
|
|
data: {
|
|
items: [
|
|
{
|
|
message_id: "m-child",
|
|
root_id: "m-root",
|
|
parent_id: "m-parent",
|
|
thread_id: "thread-1",
|
|
msg_type: "text",
|
|
body: { content: JSON.stringify({ text: "parent text" }) },
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
list: async () => ({ data: { items: [] } }),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
logger: { warn() {}, info() {}, error() {}, debug() {} },
|
|
} as unknown as FeishuRuntime;
|
|
|
|
const raw = await readFeishuContext(
|
|
{ chat_id: "chat-1", anchor: "reply", id: "m-child" },
|
|
{ runId: "run-1", projectId: "proj-1", boundChatId: "chat-1", workspaceDir: "/tmp/proj-1" },
|
|
rt,
|
|
);
|
|
|
|
expect(JSON.parse(raw)).toMatchObject({
|
|
message_id: "m-child",
|
|
content: JSON.stringify({ text: "parent text" }),
|
|
parent_id: "m-parent",
|
|
parent_message_id: "m-parent",
|
|
root_id: "m-root",
|
|
thread_id: "thread-1",
|
|
});
|
|
});
|
|
});
|