import { describe, expect, it } from "vitest"; import { applyPluginAutoEnable } from "./plugin-auto-enable.js"; describe("applyPluginAutoEnable", () => { it("enables configured channel plugins and updates allowlist", () => { const result = applyPluginAutoEnable({ config: { channels: { slack: { botToken: "x" } }, plugins: { allow: ["telegram"] }, }, env: {}, }); expect(result.config.plugins?.entries?.slack?.enabled).toBe(true); expect(result.config.plugins?.allow).toEqual(["telegram", "slack"]); expect(result.changes.join("\n")).toContain('Enabled plugin "slack"'); }); it("respects explicit disable", () => { const result = applyPluginAutoEnable({ config: { channels: { slack: { botToken: "x" } }, plugins: { entries: { slack: { enabled: false } } }, }, env: {}, }); expect(result.config.plugins?.entries?.slack?.enabled).toBe(false); expect(result.changes).toEqual([]); }); it("enables provider auth plugins when profiles exist", () => { const result = applyPluginAutoEnable({ config: { auth: { profiles: { "google-antigravity:default": { provider: "google-antigravity", mode: "oauth", }, }, }, }, env: {}, }); expect(result.config.plugins?.entries?.["google-antigravity-auth"]?.enabled).toBe(true); }); it("skips when plugins are globally disabled", () => { const result = applyPluginAutoEnable({ config: { channels: { slack: { botToken: "x" } }, plugins: { enabled: false }, }, env: {}, }); expect(result.config.plugins?.entries?.slack?.enabled).toBeUndefined(); expect(result.changes).toEqual([]); }); });