





















@@ -395,7 +395,7 @@ describe("feishuPlugin actions", () => {
395395expect(details.chatId).toBe("oc_group_1");
396396});
397397398-it("renders presentation button labels into the card fallback", async () => {
398+it("renders presentation buttons as native Feishu card buttons", async () => {
399399sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_card", chatId: "oc_group_1" });
400400401401await feishuPlugin.actions?.handleAction?.({
@@ -421,10 +421,97 @@ describe("feishuPlugin actions", () => {
421421"send card args",
422422);
423423const card = requireRecord(sendCardArgs.card, "card");
424+const elements = requireArray(requireRecord(card.body, "card body").elements, "card elements");
425+expect(elements).toEqual([
426+{
427+tag: "button",
428+text: { tag: "plain_text", content: "Run help" },
429+type: "default",
430+behaviors: [
431+{
432+type: "callback",
433+value: {
434+oc: "ocf1",
435+k: "quick",
436+a: "feishu.payload.button",
437+q: "feishu.quick_actions.help",
438+},
439+},
440+],
441+},
442+]);
443+expect(
444+elements.some((element) => requireRecord(element, "card element").tag === "action"),
445+).toBe(false);
446+});
447+448+it("renders legacy web_app presentation buttons as native Feishu link buttons", async () => {
449+sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_card", chatId: "oc_group_1" });
450+451+await feishuPlugin.actions?.handleAction?.({
452+action: "send",
453+params: {
454+to: "chat:oc_group_1",
455+presentation: {
456+blocks: [
457+{
458+type: "buttons",
459+buttons: [{ label: "Open app", web_app: { url: "https://example.com/app" } }],
460+},
461+],
462+},
463+},
464+ cfg,
465+accountId: undefined,
466+toolContext: {},
467+} as never);
468+469+const sendCardArgs = requireRecord(
470+mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
471+"send card args",
472+);
473+const card = requireRecord(sendCardArgs.card, "card");
474+const elements = requireArray(requireRecord(card.body, "card body").elements, "card elements");
475+expect(elements).toEqual([
476+{
477+tag: "button",
478+text: { tag: "plain_text", content: "Open app" },
479+type: "default",
480+behaviors: [{ type: "open_url", default_url: "https://example.com/app" }],
481+},
482+]);
483+});
484+485+it("does not duplicate title-only presentation cards in the body fallback", async () => {
486+sendCardFeishuMock.mockResolvedValueOnce({ messageId: "om_card", chatId: "oc_group_1" });
487+488+await feishuPlugin.actions?.handleAction?.({
489+action: "send",
490+params: {
491+to: "chat:oc_group_1",
492+presentation: {
493+title: "Status",
494+blocks: [],
495+},
496+},
497+ cfg,
498+accountId: undefined,
499+toolContext: {},
500+} as never);
501+502+const sendCardArgs = requireRecord(
503+mockCallArg(sendCardFeishuMock, 0, 0, "sendCardFeishu"),
504+"send card args",
505+);
506+const card = requireRecord(sendCardArgs.card, "card");
507+expect(card.header).toEqual({
508+title: { tag: "plain_text", content: "Status" },
509+template: "blue",
510+});
424511expect(requireRecord(card.body, "card body").elements).toEqual([
425512{
426513tag: "markdown",
427-content: "- Run help",
514+content: "",
428515},
429516]);
430517});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。