mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 11:10:26 +00:00
Plugins: reuse compatible registries for runtime providers
This commit is contained in:
@@ -5,10 +5,14 @@ import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plug
|
||||
import type { SpeechProviderPlugin } from "../plugins/types.js";
|
||||
|
||||
const loadOpenClawPluginsMock = vi.fn();
|
||||
const getCompatibleActivePluginRegistryMock = vi.fn();
|
||||
|
||||
vi.mock("../plugins/loader.js", () => ({
|
||||
loadOpenClawPlugins: (...args: Parameters<typeof loadOpenClawPluginsMock>) =>
|
||||
loadOpenClawPluginsMock(...args),
|
||||
getCompatibleActivePluginRegistry: (
|
||||
...args: Parameters<typeof getCompatibleActivePluginRegistryMock>
|
||||
) => getCompatibleActivePluginRegistryMock(...args),
|
||||
}));
|
||||
|
||||
let getSpeechProvider: typeof import("./provider-registry.js").getSpeechProvider;
|
||||
@@ -37,6 +41,8 @@ describe("speech provider registry", () => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
loadOpenClawPluginsMock.mockReset();
|
||||
loadOpenClawPluginsMock.mockReturnValue(createEmptyPluginRegistry());
|
||||
getCompatibleActivePluginRegistryMock.mockReset();
|
||||
getCompatibleActivePluginRegistryMock.mockReturnValue(undefined);
|
||||
({
|
||||
getSpeechProvider,
|
||||
listSpeechProviders,
|
||||
@@ -60,7 +66,16 @@ describe("speech provider registry", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
getCompatibleActivePluginRegistryMock.mockReturnValue({
|
||||
...createEmptyPluginRegistry(),
|
||||
speechProviders: [
|
||||
{
|
||||
pluginId: "test-demo-speech",
|
||||
source: "test",
|
||||
provider: createSpeechProvider("demo-speech"),
|
||||
},
|
||||
],
|
||||
});
|
||||
const providers = listSpeechProviders();
|
||||
|
||||
expect(providers.map((provider) => provider.id)).toEqual(["demo-speech"]);
|
||||
@@ -112,6 +127,16 @@ describe("speech provider registry", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
getCompatibleActivePluginRegistryMock.mockReturnValue({
|
||||
...createEmptyPluginRegistry(),
|
||||
speechProviders: [
|
||||
{
|
||||
pluginId: "test-microsoft",
|
||||
source: "test",
|
||||
provider: createSpeechProvider("microsoft", ["edge"]),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(normalizeSpeechProviderId("edge")).toBe("edge");
|
||||
expect(canonicalizeSpeechProviderId("edge")).toBe("microsoft");
|
||||
|
||||
Reference in New Issue
Block a user