fix: sync built-in channel enablement across config paths

This commit is contained in:
Peter Steinberger
2026-02-23 19:40:32 +00:00
parent 69b17a37e8
commit 87603b5c45
10 changed files with 213 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { normalizePluginsConfig } from "./config-state.js";
import { normalizePluginsConfig, resolveEffectiveEnableState } from "./config-state.js";
describe("normalizePluginsConfig", () => {
it("uses default memory slot when not specified", () => {
@@ -48,3 +48,48 @@ describe("normalizePluginsConfig", () => {
expect(result.slots.memory).toBe("memory-core");
});
});
describe("resolveEffectiveEnableState", () => {
it("enables bundled channels when channels.<id>.enabled=true", () => {
const normalized = normalizePluginsConfig({
enabled: true,
});
const state = resolveEffectiveEnableState({
id: "telegram",
origin: "bundled",
config: normalized,
rootConfig: {
channels: {
telegram: {
enabled: true,
},
},
},
});
expect(state).toEqual({ enabled: true });
});
it("keeps explicit plugin-level disable authoritative", () => {
const normalized = normalizePluginsConfig({
enabled: true,
entries: {
telegram: {
enabled: false,
},
},
});
const state = resolveEffectiveEnableState({
id: "telegram",
origin: "bundled",
config: normalized,
rootConfig: {
channels: {
telegram: {
enabled: true,
},
},
},
});
expect(state).toEqual({ enabled: false, reason: "disabled in config" });
});
});