mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 02:22:25 +00:00
* 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
48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
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,
|
|
};
|
|
});
|
|
|
|
describe("tts runtime facade", () => {
|
|
let ttsModulePromise: Promise<typeof import("./tts.js")> | undefined;
|
|
|
|
beforeEach(() => {
|
|
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
|
|
loadBundledPluginPublicSurfaceModuleSync.mockReset();
|
|
});
|
|
|
|
function importTtsModule() {
|
|
ttsModulePromise ??= import("./tts.js");
|
|
return ttsModulePromise;
|
|
}
|
|
|
|
it("does not load speech-core on module import", async () => {
|
|
await importTtsModule();
|
|
|
|
expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("loads speech-core lazily on first runtime access", async () => {
|
|
const buildTtsSystemPromptHint = vi.fn().mockReturnValue("hint");
|
|
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReturnValue({
|
|
buildTtsSystemPromptHint,
|
|
});
|
|
|
|
const tts = await importTtsModule();
|
|
|
|
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
|
expect(tts.buildTtsSystemPromptHint({} as never)).toBe("hint");
|
|
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledTimes(1);
|
|
expect(buildTtsSystemPromptHint).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|