mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 23:12:54 +00:00
Slack: add media block fallback text handling
This commit is contained in:
31
src/slack/blocks-fallback.test.ts
Normal file
31
src/slack/blocks-fallback.test.ts
Normal 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",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user