import { describe, expect, it, vi } from "vitest"; import type { ChannelPlugin } from "../channels/plugins/types.js"; vi.mock("../channels/plugins/index.js", () => ({ listChannelPlugins: vi.fn(), })); const { buildChannelSummary } = await import("./channel-summary.js"); const { listChannelPlugins } = await import("../channels/plugins/index.js"); function makeSlackHttpSummaryPlugin(): ChannelPlugin { return { id: "slack", meta: { id: "slack", label: "Slack", selectionLabel: "Slack", docsPath: "/channels/slack", blurb: "test", }, capabilities: { chatTypes: ["direct"] }, config: { listAccountIds: () => ["primary"], defaultAccountId: () => "primary", inspectAccount: (cfg) => (cfg as { marker?: string }).marker === "source" ? { accountId: "primary", name: "Primary", enabled: true, configured: true, mode: "http", botToken: "xoxb-http", signingSecret: "", botTokenSource: "config", signingSecretSource: "config", // pragma: allowlist secret botTokenStatus: "available", signingSecretStatus: "configured_unavailable", // pragma: allowlist secret } : { accountId: "primary", name: "Primary", enabled: true, configured: false, mode: "http", botToken: "xoxb-http", botTokenSource: "config", botTokenStatus: "available", }, resolveAccount: () => ({ accountId: "primary", name: "Primary", enabled: true, configured: false, mode: "http", botToken: "xoxb-http", botTokenSource: "config", botTokenStatus: "available", }), isConfigured: (account) => Boolean((account as { configured?: boolean }).configured), isEnabled: () => true, }, actions: { listActions: () => ["send"], }, }; } describe("buildChannelSummary", () => { it("preserves Slack HTTP signing-secret unavailable state from source config", async () => { vi.mocked(listChannelPlugins).mockReturnValue([makeSlackHttpSummaryPlugin()]); const lines = await buildChannelSummary({ marker: "resolved", channels: {} } as never, { colorize: false, includeAllowFrom: false, sourceConfig: { marker: "source", channels: {} } as never, }); expect(lines).toContain("Slack: configured"); expect(lines).toContain( " - primary (Primary) (bot:config, signing:config, secret unavailable in this command path)", ); }); });