mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 06:20:21 +00:00
fix(plugins): guard runtime facade activation (#59412)
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
||||
const loadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../plugin-sdk/facade-runtime.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../plugin-sdk/facade-runtime.js")>();
|
||||
return {
|
||||
...actual,
|
||||
loadActivatedBundledPluginPublicSurfaceModuleSync,
|
||||
loadBundledPluginPublicSurfaceModuleSync,
|
||||
};
|
||||
});
|
||||
@@ -14,6 +16,7 @@ describe("tts runtime facade", () => {
|
||||
let ttsModulePromise: Promise<typeof import("./tts.js")> | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockReset();
|
||||
});
|
||||
|
||||
@@ -30,15 +33,15 @@ describe("tts runtime facade", () => {
|
||||
|
||||
it("loads speech-core lazily on first runtime access", async () => {
|
||||
const buildTtsSystemPromptHint = vi.fn().mockReturnValue("hint");
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockReturnValue({
|
||||
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReturnValue({
|
||||
buildTtsSystemPromptHint,
|
||||
});
|
||||
|
||||
const tts = await importTtsModule();
|
||||
|
||||
expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
||||
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
||||
expect(tts.buildTtsSystemPromptHint({} as never)).toBe("hint");
|
||||
expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledTimes(1);
|
||||
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledTimes(1);
|
||||
expect(buildTtsSystemPromptHint).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user