

























@@ -4,6 +4,7 @@ import {
44hasReplyContent,
55hasReplyPayloadContent,
66normalizeInteractiveReply,
7+presentationToInteractiveControlsReply,
78presentationToInteractiveReply,
89renderMessagePresentationFallbackText,
910resolveInteractiveTextFallback,
@@ -130,4 +131,66 @@ describe("interactive payload helpers", () => {
130131"- Docs: https://example.com/docs",
131132);
132133});
134+135+it("converts only presentation controls for native component renderers", () => {
136+const presentation = {
137+title: "Deploy approval",
138+blocks: [
139+{ type: "text" as const, text: "Canary is ready." },
140+{ type: "divider" as const },
141+{
142+type: "buttons" as const,
143+buttons: [{ label: "Approve", value: "approve", style: "success" as const }],
144+},
145+{
146+type: "select" as const,
147+placeholder: "Rollback target",
148+options: [{ label: "Previous", value: "previous" }],
149+},
150+],
151+};
152+153+expect(presentationToInteractiveReply(presentation)).toEqual({
154+blocks: [
155+{ type: "text", text: "Deploy approval" },
156+{ type: "text", text: "Canary is ready." },
157+{
158+type: "buttons",
159+buttons: [{ label: "Approve", value: "approve", style: "success" }],
160+},
161+{
162+type: "select",
163+placeholder: "Rollback target",
164+options: [{ label: "Previous", value: "previous" }],
165+},
166+],
167+});
168+expect(presentationToInteractiveControlsReply(presentation)).toEqual({
169+blocks: [
170+{
171+type: "buttons",
172+buttons: [{ label: "Approve", value: "approve", style: "success" }],
173+},
174+{
175+type: "select",
176+placeholder: "Rollback target",
177+options: [{ label: "Previous", value: "previous" }],
178+},
179+],
180+});
181+});
182+183+it("keeps divider-only fallback empty unless a send transport fallback is requested", () => {
184+const presentation = {
185+blocks: [{ type: "divider" as const }],
186+};
187+188+expect(renderMessagePresentationFallbackText({ presentation })).toBe("");
189+expect(
190+renderMessagePresentationFallbackText({
191+ presentation,
192+emptyFallback: "---",
193+}),
194+).toBe("---");
195+});
133196});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。