mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 12:03:34 +00:00
fix(feishu): harden routing, parsing, and media delivery
This commit is contained in:
@@ -68,4 +68,101 @@ describe("getMessageFeishu", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("extracts text content from post messages", async () => {
|
||||
mockClientGet.mockResolvedValueOnce({
|
||||
code: 0,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
message_id: "om_post",
|
||||
chat_id: "oc_post",
|
||||
msg_type: "post",
|
||||
body: {
|
||||
content: JSON.stringify({
|
||||
zh_cn: {
|
||||
title: "Summary",
|
||||
content: [[{ tag: "text", text: "post body" }]],
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await getMessageFeishu({
|
||||
cfg: {} as ClawdbotConfig,
|
||||
messageId: "om_post",
|
||||
});
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
messageId: "om_post",
|
||||
chatId: "oc_post",
|
||||
contentType: "post",
|
||||
content: "Summary\n\npost body",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns text placeholder instead of raw JSON for unsupported message types", async () => {
|
||||
mockClientGet.mockResolvedValueOnce({
|
||||
code: 0,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
message_id: "om_file",
|
||||
chat_id: "oc_file",
|
||||
msg_type: "file",
|
||||
body: {
|
||||
content: JSON.stringify({ file_key: "file_v3_123" }),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await getMessageFeishu({
|
||||
cfg: {} as ClawdbotConfig,
|
||||
messageId: "om_file",
|
||||
});
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
messageId: "om_file",
|
||||
chatId: "oc_file",
|
||||
contentType: "file",
|
||||
content: "[file message]",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("supports single-object response shape from Feishu API", async () => {
|
||||
mockClientGet.mockResolvedValueOnce({
|
||||
code: 0,
|
||||
data: {
|
||||
message_id: "om_single",
|
||||
chat_id: "oc_single",
|
||||
msg_type: "text",
|
||||
body: {
|
||||
content: JSON.stringify({ text: "single payload" }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = await getMessageFeishu({
|
||||
cfg: {} as ClawdbotConfig,
|
||||
messageId: "om_single",
|
||||
});
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
messageId: "om_single",
|
||||
chatId: "oc_single",
|
||||
contentType: "text",
|
||||
content: "single payload",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user