From c836fd22d023b52fbfa1c0f6610f573d09dc698e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 05:54:36 +0100 Subject: [PATCH] test: narrow plugin auto-enable manifest coverage --- .../plugin-auto-enable.channels.test.ts | 43 ++++++++----------- src/config/plugin-auto-enable.core.test.ts | 21 ++------- 2 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/config/plugin-auto-enable.channels.test.ts b/src/config/plugin-auto-enable.channels.test.ts index ffa244d6731..11fb2bcb2f5 100644 --- a/src/config/plugin-auto-enable.channels.test.ts +++ b/src/config/plugin-auto-enable.channels.test.ts @@ -1,7 +1,10 @@ import fs from "node:fs"; import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; -import { applyPluginAutoEnable } from "./plugin-auto-enable.js"; +import { + applyPluginAutoEnable, + materializePluginAutoEnableCandidates, +} from "./plugin-auto-enable.js"; import { makeApnChannelConfig, makeBluebubblesAndImessageChannels, @@ -9,7 +12,6 @@ import { makeRegistry, makeTempDir, resetPluginAutoEnableTestState, - writePluginManifestFixture, } from "./plugin-auto-enable.test-helpers.js"; function applyWithApnChannelConfig(extra?: { @@ -71,13 +73,25 @@ describe("applyPluginAutoEnable channels", () => { "utf-8", ); - const result = applyPluginAutoEnable({ + const result = materializePluginAutoEnableCandidates({ config: { channels: { "env-primary": { token: "primary" }, "env-secondary": { token: "secondary" }, }, }, + candidates: [ + { + pluginId: "env-primary", + kind: "channel-configured", + channelId: "env-primary", + }, + { + pluginId: "env-secondary", + kind: "channel-configured", + channelId: "env-secondary", + }, + ], env: { ...makeIsolatedEnv(), OPENCLAW_STATE_DIR: stateDir, @@ -212,28 +226,5 @@ describe("applyPluginAutoEnable channels", () => { expect(result.config.channels?.imessage?.enabled).toBe(true); expect(result.changes.join("\n")).toContain("iMessage configured, enabled automatically."); }); - - it("uses the provided env when loading installed plugin manifests", () => { - const stateDir = makeTempDir(); - const pluginDir = path.join(stateDir, "extensions", "apn-channel"); - writePluginManifestFixture({ - rootDir: pluginDir, - id: "apn-channel", - channels: ["apn"], - }); - - const result = applyPluginAutoEnable({ - config: makeApnChannelConfig(), - env: { - ...makeIsolatedEnv(), - OPENCLAW_HOME: undefined, - OPENCLAW_STATE_DIR: stateDir, - OPENCLAW_BUNDLED_PLUGINS_DIR: "/nonexistent/bundled/plugins", - }, - }); - - expect(result.config.plugins?.entries?.["apn-channel"]?.enabled).toBe(true); - expect(result.config.plugins?.entries?.apn).toBeUndefined(); - }); }); }); diff --git a/src/config/plugin-auto-enable.core.test.ts b/src/config/plugin-auto-enable.core.test.ts index 5e27ccc1ca3..8b34762ab8e 100644 --- a/src/config/plugin-auto-enable.core.test.ts +++ b/src/config/plugin-auto-enable.core.test.ts @@ -1,4 +1,3 @@ -import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; import { applyPluginAutoEnable, @@ -8,9 +7,7 @@ import { import { makeIsolatedEnv, makeRegistry, - makeTempDir, resetPluginAutoEnableTestState, - writePluginManifestFixture, } from "./plugin-auto-enable.test-helpers.js"; import { WhatsAppConfigSchema } from "./zod-schema.providers-whatsapp.js"; @@ -425,25 +422,13 @@ describe("applyPluginAutoEnable core", () => { expect(result.changes.join("\n")).toContain("IRC configured, enabled automatically."); }); - it("uses the provided env when loading plugin manifests automatically", () => { - const stateDir = makeTempDir(); - const pluginDir = path.join(stateDir, "extensions", "apn-channel"); - writePluginManifestFixture({ - rootDir: pluginDir, - id: "apn-channel", - channels: ["apn"], - }); - + it("uses the provided manifest registry for plugin channel ids", () => { const result = applyPluginAutoEnable({ config: { channels: { apn: { someKey: "value" } }, }, - env: { - ...makeIsolatedEnv(), - OPENCLAW_HOME: undefined, - OPENCLAW_STATE_DIR: stateDir, - OPENCLAW_BUNDLED_PLUGINS_DIR: "/nonexistent/bundled/plugins", - }, + env: makeIsolatedEnv(), + manifestRegistry: makeRegistry([{ id: "apn-channel", channels: ["apn"] }]), }); expect(result.config.plugins?.entries?.["apn-channel"]?.enabled).toBe(true);