From 62864fb22c9d9b8ed66581f8808f46def0bd72d6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 22 Apr 2026 06:42:50 +0100 Subject: [PATCH] test: reuse plugin auto-enable fixture environment --- src/config/plugin-auto-enable.core.test.ts | 56 ++++++++++--------- .../plugin-auto-enable.providers.test.ts | 30 +++++----- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/config/plugin-auto-enable.core.test.ts b/src/config/plugin-auto-enable.core.test.ts index 4c140ca02f5..c1e64e76ade 100644 --- a/src/config/plugin-auto-enable.core.test.ts +++ b/src/config/plugin-auto-enable.core.test.ts @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from "vitest"; +import { afterAll, describe, expect, it } from "vitest"; import { applyPluginAutoEnable, detectPluginAutoEnableCandidates, @@ -11,7 +11,9 @@ import { } from "./plugin-auto-enable.test-helpers.js"; import { validateConfigObject } from "./validation.js"; -afterEach(() => { +const env = makeIsolatedEnv(); + +afterAll(() => { resetPluginAutoEnableTestState(); }); @@ -21,7 +23,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { slack: { botToken: "x" } }, }, - env: makeIsolatedEnv(), + env, }); expect(candidates).toEqual([ @@ -46,7 +48,7 @@ describe("applyPluginAutoEnable core", () => { it("treats an undefined config as empty", () => { const result = applyPluginAutoEnable({ config: undefined, - env: makeIsolatedEnv(), + env, }); expect(result.config).toEqual({}); @@ -60,7 +62,7 @@ describe("applyPluginAutoEnable core", () => { channels: { slack: { botToken: "x" } }, plugins: { allow: ["telegram"] }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.channels?.slack?.enabled).toBe(true); @@ -77,7 +79,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { slack: { botToken: "x" } }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.channels?.slack?.enabled).toBe(true); @@ -89,7 +91,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { slack: { botToken: "x" } }, }, - env: makeIsolatedEnv(), + env, }); expect(Object.getPrototypeOf(result.autoEnabledReasons)).toBeNull(); @@ -105,7 +107,7 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.allow).toEqual(["telegram", "browser"]); @@ -123,7 +125,7 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.allow).toEqual(["telegram", "browser"]); @@ -138,7 +140,7 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.allow).toEqual(["telegram"]); @@ -160,7 +162,7 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([ { id: "evil-plugin", @@ -191,7 +193,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.firecrawl?.enabled).toBe(true); @@ -208,7 +210,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([{ id: "codex", channels: [], providers: ["codex"] }]), }); @@ -229,7 +231,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([ { id: "codex", @@ -281,7 +283,7 @@ describe("applyPluginAutoEnable core", () => { list: [{ id: "pi" }], }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config).toEqual({ @@ -309,7 +311,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.modelByChannel).toBeUndefined(); @@ -326,7 +328,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.channels?.whatsapp?.enabled).toBe(true); @@ -345,7 +347,7 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.channels?.whatsapp?.enabled).toBe(true); @@ -367,7 +369,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.allow).toEqual(["glueclaw", "discord"]); @@ -388,7 +390,7 @@ describe("applyPluginAutoEnable core", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.allow).toEqual(["glueclaw"]); @@ -407,12 +409,12 @@ describe("applyPluginAutoEnable core", () => { allow: ["telegram"], }, }, - env: makeIsolatedEnv(), + env, }); const second = applyPluginAutoEnable({ config: first.config, - env: makeIsolatedEnv(), + env, }); expect(first.changes).toHaveLength(1); @@ -426,7 +428,7 @@ describe("applyPluginAutoEnable core", () => { channels: { slack: { botToken: "x" } }, plugins: { entries: { slack: { enabled: false } } }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.slack?.enabled).toBe(false); @@ -438,7 +440,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { slack: { botToken: "x", enabled: false } }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.channels?.slack?.enabled).toBe(false); @@ -451,7 +453,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { matrix: { enabled: false } }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([{ id: "matrix", channels: ["matrix"] }]), }); @@ -478,7 +480,7 @@ describe("applyPluginAutoEnable core", () => { config: { channels: { apn: { someKey: "value" } }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([{ id: "apn-channel", channels: ["apn"] }]), }); @@ -492,7 +494,7 @@ describe("applyPluginAutoEnable core", () => { channels: { slack: { botToken: "x" } }, plugins: { enabled: false }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.slack?.enabled).toBeUndefined(); diff --git a/src/config/plugin-auto-enable.providers.test.ts b/src/config/plugin-auto-enable.providers.test.ts index f4208a9a787..92187a44e9a 100644 --- a/src/config/plugin-auto-enable.providers.test.ts +++ b/src/config/plugin-auto-enable.providers.test.ts @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from "vitest"; +import { afterAll, describe, expect, it } from "vitest"; import { applyPluginAutoEnable } from "./plugin-auto-enable.js"; import { makeIsolatedEnv, @@ -6,7 +6,9 @@ import { resetPluginAutoEnableTestState, } from "./plugin-auto-enable.test-helpers.js"; -afterEach(() => { +const env = makeIsolatedEnv(); + +afterAll(() => { resetPluginAutoEnableTestState(); }); @@ -23,7 +25,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.google?.enabled).toBe(true); @@ -44,7 +46,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.xai?.enabled).toBe(true); @@ -66,7 +68,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.xai?.enabled).toBe(true); @@ -89,7 +91,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.xai?.enabled).toBe(true); @@ -108,7 +110,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.minimax?.enabled).toBe(true); @@ -127,7 +129,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.minimax?.enabled).toBe(true); @@ -145,7 +147,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.openai).toBeUndefined(); @@ -164,7 +166,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([ { id: "acme", @@ -192,7 +194,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([ { id: "acme", @@ -224,7 +226,7 @@ describe("applyPluginAutoEnable providers", () => { }, }, }, - env: makeIsolatedEnv(), + env, manifestRegistry: makeRegistry([ { id: "acme", @@ -254,7 +256,7 @@ describe("applyPluginAutoEnable providers", () => { enabled: true, }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.acpx?.enabled).toBe(true); @@ -269,7 +271,7 @@ describe("applyPluginAutoEnable providers", () => { backend: "custom-runtime", }, }, - env: makeIsolatedEnv(), + env, }); expect(result.config.plugins?.entries?.acpx?.enabled).toBeUndefined();