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

@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { buildSlackBlocksFallbackText } from "./blocks-fallback.js";
describe("buildSlackBlocksFallbackText", () => {
it("prefers header text", () => {
expect(
buildSlackBlocksFallbackText([
{ type: "header", text: { type: "plain_text", text: "Deploy status" } },
] as never),
).toBe("Deploy status");
});
it("uses image alt text", () => {
expect(
buildSlackBlocksFallbackText([
{ type: "image", image_url: "https://example.com/image.png", alt_text: "Latency chart" },
] as never),
).toBe("Latency chart");
});
it("uses generic defaults for file and unknown blocks", () => {
expect(
buildSlackBlocksFallbackText([
{ type: "file", source: "remote", external_id: "F123" },
] as never),
).toBe("Shared a file");
expect(buildSlackBlocksFallbackText([{ type: "divider" }] as never)).toBe(
"Shared a Block Kit message",
);
});
});