Slack: add media block fallback text handling

This commit is contained in:
Colin
2026-02-16 14:02:27 -05:00
committed by Peter Steinberger
parent 7aaf1547df
commit ce973332f6
6 changed files with 243 additions and 4 deletions

View File

@@ -42,12 +42,68 @@ describe("editSlackMessage blocks", () => {
expect.objectContaining({
channel: "C123",
ts: "171234.567",
text: " ",
text: "Shared a Block Kit message",
blocks: [{ type: "divider" }],
}),
);
});
it("uses image block text as edit fallback", async () => {
const client = createClient();
await editSlackMessage("C123", "171234.567", "", {
token: "xoxb-test",
client,
blocks: [{ type: "image", image_url: "https://example.com/a.png", alt_text: "Chart" }],
});
expect(client.chat.update).toHaveBeenCalledWith(
expect.objectContaining({
text: "Chart",
}),
);
});
it("uses video block title as edit fallback", async () => {
const client = createClient();
await editSlackMessage("C123", "171234.567", "", {
token: "xoxb-test",
client,
blocks: [
{
type: "video",
title: { type: "plain_text", text: "Walkthrough" },
video_url: "https://example.com/demo.mp4",
thumbnail_url: "https://example.com/thumb.jpg",
alt_text: "demo",
},
],
});
expect(client.chat.update).toHaveBeenCalledWith(
expect.objectContaining({
text: "Walkthrough",
}),
);
});
it("uses generic file fallback text for file blocks", async () => {
const client = createClient();
await editSlackMessage("C123", "171234.567", "", {
token: "xoxb-test",
client,
blocks: [{ type: "file", source: "remote", external_id: "F123" }],
});
expect(client.chat.update).toHaveBeenCalledWith(
expect.objectContaining({
text: "Shared a file",
}),
);
});
it("rejects empty blocks arrays", async () => {
const client = createClient();