diff --git a/src/infra/channel-summary.test.ts b/src/infra/channel-summary.test.ts index 01a4450a640..04e43866230 100644 --- a/src/infra/channel-summary.test.ts +++ b/src/infra/channel-summary.test.ts @@ -1,12 +1,9 @@ -import { describe, expect, it, vi } from "vitest"; -import { listChannelPlugins } from "../channels/plugins/index.js"; +import { afterEach, describe, expect, it } from "vitest"; import type { ChannelPlugin } from "../channels/plugins/types.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { buildChannelSummary } from "./channel-summary.js"; -vi.mock("../channels/plugins/index.js", () => ({ - listChannelPlugins: vi.fn(), -})); - function makeSlackHttpSummaryPlugin(): ChannelPlugin { return { id: "slack", @@ -207,8 +204,16 @@ function makeFallbackSummaryPlugin(params: { } describe("buildChannelSummary", () => { + afterEach(() => { + setActivePluginRegistry(createTestRegistry([])); + }); + it("preserves Slack HTTP signing-secret unavailable state from source config", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([makeSlackHttpSummaryPlugin()]); + setActivePluginRegistry( + createTestRegistry([ + { pluginId: "slack", plugin: makeSlackHttpSummaryPlugin(), source: "test" }, + ]), + ); const lines = await buildChannelSummary({ marker: "resolved", channels: {} } as never, { colorize: false, @@ -223,9 +228,15 @@ describe("buildChannelSummary", () => { }); it("shows disabled status without configured account detail lines", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeTelegramSummaryPlugin({ enabled: false, configured: false }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "telegram", + plugin: makeTelegramSummaryPlugin({ enabled: false, configured: false }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false, @@ -236,15 +247,21 @@ describe("buildChannelSummary", () => { }); it("includes linked summary metadata and truncates allow-from details", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeTelegramSummaryPlugin({ - enabled: true, - configured: true, - linked: true, - authAgeMs: 300_000, - allowFrom: ["alice", "bob", "carol"], - }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "telegram", + plugin: makeTelegramSummaryPlugin({ + enabled: true, + configured: true, + linked: true, + authAgeMs: 300_000, + allowFrom: ["alice", "bob", "carol"], + }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false, @@ -256,13 +273,19 @@ describe("buildChannelSummary", () => { }); it("shows not-linked status when linked metadata is explicitly false", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeTelegramSummaryPlugin({ - enabled: true, - configured: true, - linked: false, - }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "telegram", + plugin: makeTelegramSummaryPlugin({ + enabled: true, + configured: true, + linked: false, + }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false, @@ -274,9 +297,15 @@ describe("buildChannelSummary", () => { }); it("renders non-slack account detail fields for configured accounts", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeSignalSummaryPlugin({ enabled: false, configured: true }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "signal", + plugin: makeSignalSummaryPlugin({ enabled: false, configured: true }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false, @@ -290,14 +319,20 @@ describe("buildChannelSummary", () => { }); it("uses the channel label and default account id when no accounts exist", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeFallbackSummaryPlugin({ - enabled: true, - configured: true, - accountIds: [], - defaultAccountId: "fallback-account", - }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "fallback-plugin", + plugin: makeFallbackSummaryPlugin({ + enabled: true, + configured: true, + accountIds: [], + defaultAccountId: "fallback-account", + }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false, @@ -308,13 +343,19 @@ describe("buildChannelSummary", () => { }); it("shows not-configured status when enabled accounts exist without configured ones", async () => { - vi.mocked(listChannelPlugins).mockReturnValue([ - makeFallbackSummaryPlugin({ - enabled: true, - configured: false, - accountIds: ["fallback-account"], - }), - ]); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "fallback-plugin", + plugin: makeFallbackSummaryPlugin({ + enabled: true, + configured: false, + accountIds: ["fallback-account"], + }), + source: "test", + }, + ]), + ); const lines = await buildChannelSummary({ channels: {} } as never, { colorize: false,