Tests: mock channel registry bundled fallback

Keep the registry fallback unit test on a minimal bundled fixture instead of loading the real Google Chat plugin. Doctor capability metadata remains covered by the doctor channel capability tests.
This commit is contained in:
Gustavo Madeira Santana
2026-04-17 13:35:25 -04:00
parent a464f5926b
commit 2b08233a3e

View File

@@ -1,9 +1,19 @@
import { afterEach, describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import { createEmptyPluginRegistry } from "../../plugins/registry-empty.js";
import type { PluginRegistry } from "../../plugins/registry.js";
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js";
import { getChannelPlugin, listChannelPlugins } from "./registry.js";
vi.mock("./bundled.js", () => ({
getBundledChannelPlugin: (id: string) =>
id === "fallback"
? {
id: "fallback",
meta: { label: "fallback" },
}
: undefined,
}));
function withMalformedChannels(registry: PluginRegistry): PluginRegistry {
const malformed = { ...registry } as PluginRegistry;
(malformed as { channels?: unknown }).channels = undefined;
@@ -25,11 +35,7 @@ describe("listChannelPlugins", () => {
it("falls back to bundled channel plugins for direct lookups before registry bootstrap", () => {
setActivePluginRegistry(createEmptyPluginRegistry());
expect(getChannelPlugin("googlechat")?.doctor).toMatchObject({
dmAllowFromMode: "nestedOnly",
groupAllowFromFallbackToAllowFrom: false,
warnOnEmptyGroupSenderAllowlist: false,
});
expect(getChannelPlugin("fallback")?.meta.label).toBe("fallback");
});
it("rebuilds channel lookups when the active registry object changes without a version bump", () => {