惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
I
InfoQ
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
博客园 - Franky
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
月光博客
月光博客
罗磊的独立博客

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf(test): route speech provider registry through unit-f...
steipete · 2026-04-27 · via Recent Commits to openclaw:main

@@ -1,19 +1,10 @@

1-

import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

1+

import { beforeEach, describe, expect, it } from "vitest";

22

import type { OpenClawConfig } from "../config/types.js";

33

import type { SpeechProviderPlugin } from "../plugins/types.js";

4-5-

const resolvePluginCapabilityProviderMock = vi.hoisted(() => vi.fn());

6-

const resolvePluginCapabilityProvidersMock = vi.hoisted(() => vi.fn());

7-8-

vi.mock("../plugins/capability-provider-runtime.js", () => ({

9-

resolvePluginCapabilityProvider: resolvePluginCapabilityProviderMock,

10-

resolvePluginCapabilityProviders: resolvePluginCapabilityProvidersMock,

11-

}));

12-13-

let getSpeechProvider: typeof import("./provider-registry.js").getSpeechProvider;

14-

let listSpeechProviders: typeof import("./provider-registry.js").listSpeechProviders;

15-

let canonicalizeSpeechProviderId: typeof import("./provider-registry.js").canonicalizeSpeechProviderId;

16-

let normalizeSpeechProviderId: typeof import("./provider-registry.js").normalizeSpeechProviderId;

4+

import {

5+

createSpeechProviderRegistry,

6+

normalizeSpeechProviderId,

7+

} from "./provider-registry-core.js";

178189

function createSpeechProvider(id: string, aliases?: string[]): SpeechProviderPlugin {

1910

return {

@@ -31,59 +22,57 @@ function createSpeechProvider(id: string, aliases?: string[]): SpeechProviderPlu

3122

}

32233324

describe("speech provider registry", () => {

34-

beforeAll(async () => {

35-

vi.resetModules();

36-

({

37-

getSpeechProvider,

38-

listSpeechProviders,

39-

canonicalizeSpeechProviderId,

40-

normalizeSpeechProviderId,

41-

} = await import("./provider-registry.js"));

42-

});

25+

const getProviderCalls: Array<{ providerId: string; cfg?: OpenClawConfig }> = [];

26+

const listProvidersCalls: Array<{ cfg?: OpenClawConfig }> = [];

27+

let providers: SpeechProviderPlugin[] = [];

28+

let directProvider: SpeechProviderPlugin | undefined;

29+

let registry: ReturnType<typeof createSpeechProviderRegistry>;

43304431

beforeEach(() => {

45-

resolvePluginCapabilityProviderMock.mockReset();

46-

resolvePluginCapabilityProviderMock.mockReturnValue(undefined);

47-

resolvePluginCapabilityProvidersMock.mockReset();

48-

resolvePluginCapabilityProvidersMock.mockReturnValue([]);

32+

providers = [];

33+

directProvider = undefined;

34+

getProviderCalls.length = 0;

35+

listProvidersCalls.length = 0;

36+

registry = createSpeechProviderRegistry({

37+

getProvider: (providerId, cfg) => {

38+

getProviderCalls.push({ providerId, cfg });

39+

return directProvider;

40+

},

41+

listProviders: (cfg) => {

42+

listProvidersCalls.push({ cfg });

43+

return providers;

44+

},

45+

});

4946

});

50475148

it("lists providers from the speech capability runtime", () => {

5249

const cfg = {} as OpenClawConfig;

53-

resolvePluginCapabilityProvidersMock.mockReturnValue([createSpeechProvider("demo-speech")]);

50+

providers = [createSpeechProvider("demo-speech")];

545155-

expect(listSpeechProviders(cfg).map((provider) => provider.id)).toEqual(["demo-speech"]);

56-

expect(resolvePluginCapabilityProvidersMock).toHaveBeenCalledWith({

57-

key: "speechProviders",

58-

cfg,

59-

});

52+

expect(registry.listSpeechProviders(cfg).map((provider) => provider.id)).toEqual([

53+

"demo-speech",

54+

]);

55+

expect(listProvidersCalls).toEqual([{ cfg }]);

6056

});

61576258

it("gets providers by normalized id through the capability runtime", () => {

6359

const cfg = {} as OpenClawConfig;

64-

const provider = createSpeechProvider("microsoft", ["edge"]);

65-

resolvePluginCapabilityProviderMock.mockReturnValue(provider);

60+

directProvider = createSpeechProvider("microsoft", ["edge"]);

666167-

expect(getSpeechProvider(" MICROSOFT ", cfg)).toBe(provider);

68-

expect(resolvePluginCapabilityProviderMock).toHaveBeenCalledWith({

69-

key: "speechProviders",

70-

providerId: "microsoft",

71-

cfg,

72-

});

62+

expect(registry.getSpeechProvider(" MICROSOFT ", cfg)).toBe(directProvider);

63+

expect(getProviderCalls).toEqual([{ providerId: "microsoft", cfg }]);

7364

});

74657566

it("canonicalizes aliases from listed providers when direct lookup misses", () => {

76-

resolvePluginCapabilityProvidersMock.mockReturnValue([

77-

createSpeechProvider("microsoft", ["edge"]),

78-

]);

67+

providers = [createSpeechProvider("microsoft", ["edge"])];

79688069

expect(normalizeSpeechProviderId("edge")).toBe("edge");

81-

expect(canonicalizeSpeechProviderId("edge")).toBe("microsoft");

70+

expect(registry.canonicalizeSpeechProviderId("edge")).toBe("microsoft");

8271

});

83728473

it("returns empty results when the capability runtime has no speech providers", () => {

85-

expect(listSpeechProviders()).toEqual([]);

86-

expect(getSpeechProvider("demo-speech")).toBeUndefined();

87-

expect(canonicalizeSpeechProviderId("demo-speech")).toBe("demo-speech");

74+

expect(registry.listSpeechProviders()).toEqual([]);

75+

expect(registry.getSpeechProvider("demo-speech")).toBeUndefined();

76+

expect(registry.canonicalizeSpeechProviderId("demo-speech")).toBe("demo-speech");

8877

});

8978

});