import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; const loadPluginManifestRegistry = vi.hoisted(() => vi.fn()); vi.mock("./runtime-manifest.runtime.js", () => ({ loadPluginManifestRegistry, })); function asConfig(value: unknown): OpenClawConfig { return value as OpenClawConfig; } let clearConfigCache: typeof import("../config/config.js").clearConfigCache; let clearRuntimeConfigSnapshot: typeof import("../config/config.js").clearRuntimeConfigSnapshot; let clearSecretsRuntimeSnapshot: typeof import("./runtime.js").clearSecretsRuntimeSnapshot; let prepareSecretsRuntimeSnapshot: typeof import("./runtime.js").prepareSecretsRuntimeSnapshot; describe("prepareSecretsRuntimeSnapshot loadable plugin origins", () => { beforeAll(async () => { ({ clearConfigCache, clearRuntimeConfigSnapshot } = await import("../config/config.js")); ({ clearSecretsRuntimeSnapshot, prepareSecretsRuntimeSnapshot } = await import("./runtime.js")); }); afterEach(() => { loadPluginManifestRegistry.mockReset(); clearSecretsRuntimeSnapshot(); clearRuntimeConfigSnapshot(); clearConfigCache(); }); it("skips manifest registry loading when plugin entries are absent", async () => { await prepareSecretsRuntimeSnapshot({ config: asConfig({ models: { providers: { openai: { apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" }, models: [{ id: "gpt-5.4", name: "gpt-5.4" }], }, }, }, }), env: { OPENAI_API_KEY: "sk-test" }, includeAuthStoreRefs: false, }); expect(loadPluginManifestRegistry).not.toHaveBeenCalled(); }); });