Files
openclaw/src/config/markdown-tables.test.ts
Vincent Koc 54f7221465 fix(slack): restore table block mode seam (#57591)
* fix(slack): restore table block mode seam

Restore the shared markdown/config seam needed for Slack Block Kit table support, while coercing non-Slack block mode back to code.

* fix(slack): narrow table block seam defaults

Keep Slack table block mode opt-in in this seam-only PR, clamp collected placeholder offsets, and align fallback-table rendering with Slack block limits.

* fix(slack): bound table fallback rendering

Avoid spread-based maxima and bound Slack table fallback rendering by row, column, cell-width, and total-output limits to prevent resource exhaustion.

* fix(slack): keep block mode inactive in seam PR

Keep markdown table block mode schema-valid but runtime-resolved to code until the Slack send path is wired to emit table attachments.

* fix(slack): normalize configured block mode safely

Accept configured markdown table block mode at parse time, then normalize it back to code during runtime resolution so seam-only branches do not drop table content.
2026-03-30 19:25:01 +09:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { DEFAULT_TABLE_MODES, resolveMarkdownTableMode } from "./markdown-tables.js";
describe("DEFAULT_TABLE_MODES", () => {
it("mattermost mode is off", () => {
expect(DEFAULT_TABLE_MODES.get("mattermost")).toBe("off");
});
it("signal mode is bullets", () => {
expect(DEFAULT_TABLE_MODES.get("signal")).toBe("bullets");
});
it("whatsapp mode is bullets", () => {
expect(DEFAULT_TABLE_MODES.get("whatsapp")).toBe("bullets");
});
it("slack has no special default in this seam-only slice", () => {
expect(DEFAULT_TABLE_MODES.get("slack")).toBeUndefined();
});
});
describe("resolveMarkdownTableMode", () => {
it("defaults to code for slack", () => {
expect(resolveMarkdownTableMode({ channel: "slack" })).toBe("code");
});
it("coerces explicit block mode to code for slack", () => {
const cfg = { channels: { slack: { markdown: { tables: "block" as const } } } };
expect(resolveMarkdownTableMode({ cfg, channel: "slack" })).toBe("code");
});
it("coerces explicit block mode to code for non-slack channels", () => {
const cfg = { channels: { telegram: { markdown: { tables: "block" as const } } } };
expect(resolveMarkdownTableMode({ cfg, channel: "telegram" })).toBe("code");
});
});