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

推荐订阅源

爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
U
Unit 42
B
Blog RSS Feed
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
腾讯CDC
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
博客园 - 聂微东
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta

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
test: guard media provider mock calls · openclaw/openclaw...
steipete · 2026-05-12 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -5,6 +5,14 @@ import {

55

transcribeElevenLabsAudio,

66

} from "./media-understanding-provider.js";

77
8+

function requireFirstFetchCall(fetchMock: ReturnType<typeof vi.fn>): [string, RequestInit] {

9+

const [call] = fetchMock.mock.calls;

10+

if (!call) {

11+

throw new Error("expected ElevenLabs media fetch call");

12+

}

13+

return call as [string, RequestInit];

14+

}

15+
816

describe("elevenLabsMediaUnderstandingProvider", () => {

917

let ssrfMock: { mockRestore: () => void } | undefined;

1018

@@ -42,8 +50,8 @@ describe("elevenLabsMediaUnderstandingProvider", () => {

4250
4351

expect(result).toEqual({ text: "hello", model: "scribe_v2" });

4452

expect(fetchMock).toHaveBeenCalledTimes(1);

45-

expect(fetchMock.mock.calls[0]?.[0]).toBe("https://api.elevenlabs.io/v1/speech-to-text");

46-

const init = fetchMock.mock.calls[0]?.[1] as RequestInit;

53+

const [url, init] = requireFirstFetchCall(fetchMock);

54+

expect(url).toBe("https://api.elevenlabs.io/v1/speech-to-text");

4755

expect(init.method).toBe("POST");

4856

const headers = new Headers(init.headers);

4957

expect(headers.get("xi-api-key")).toBe("eleven-key");

Original file line numberDiff line numberDiff line change

@@ -25,16 +25,24 @@ describe("elevenlabs tts diagnostics", () => {

2525

}

2626
2727

function getHeadersFromFirstFetchCall(fetchMock: ReturnType<typeof vi.fn>): Headers {

28-

const init = fetchMock.mock.calls[0]?.[1] as RequestInit | undefined;

29-

return new Headers(init?.headers);

28+

return new Headers(getInitFromFirstFetchCall(fetchMock).headers);

29+

}

30+
31+

function requireFirstFetchCall(fetchMock: ReturnType<typeof vi.fn>): [string | URL, RequestInit] {

32+

const [call] = fetchMock.mock.calls;

33+

if (!call) {

34+

throw new Error("expected ElevenLabs fetch call");

35+

}

36+

return call as [string | URL, RequestInit];

3037

}

3138
3239

function getInitFromFirstFetchCall(fetchMock: ReturnType<typeof vi.fn>): RequestInit {

33-

return (fetchMock.mock.calls[0] as unknown[])[1] as RequestInit;

40+

const [, init] = requireFirstFetchCall(fetchMock);

41+

return init;

3442

}

3543
3644

function getUrlFromFirstFetchCall(fetchMock: ReturnType<typeof vi.fn>): URL {

37-

const url = fetchMock.mock.calls[0]?.[0] as string | URL;

45+

const [url] = requireFirstFetchCall(fetchMock);

3846

return new URL(url.toString());

3947

}

4048
Original file line numberDiff line numberDiff line change

@@ -84,15 +84,28 @@ describe("fal video generation provider", () => {

8484

);

8585

}

8686
87+

function requireFetchGuardCall(callNumber: number): { init?: RequestInit; url?: string } {

88+

const call = fetchGuardMock.mock.calls[callNumber - 1];

89+

if (!call) {

90+

throw new Error(`expected fal fetch guard call ${callNumber}`);

91+

}

92+

const [request] = call;

93+

if (!request || typeof request !== "object" || Array.isArray(request)) {

94+

throw new Error(`expected fal fetch guard request ${callNumber}`);

95+

}

96+

return request as { init?: RequestInit; url?: string };

97+

}

98+
8799

function getSubmitBody(): Record<string, unknown> {

88-

return JSON.parse(String(fetchGuardMock.mock.calls[0]?.[0]?.init?.body ?? "{}")) as Record<

89-

string,

90-

unknown

91-

>;

100+

const body = requireFetchGuardCall(1).init?.body;

101+

if (typeof body !== "string") {

102+

throw new Error("expected fal submit JSON body");

103+

}

104+

return JSON.parse(body) as Record<string, unknown>;

92105

}

93106
94107

function fetchGuardUrl(callNumber: number): string | undefined {

95-

return (fetchGuardMock.mock.calls[callNumber - 1]?.[0] as { url?: string } | undefined)?.url;

108+

return requireFetchGuardCall(callNumber).url;

96109

}

97110
98111

afterEach(() => {

@@ -142,9 +155,7 @@ describe("fal video generation provider", () => {

142155

});

143156
144157

expect(fetchGuardUrl(1)).toBe("https://queue.fal.run/fal-ai/minimax/video-01-live");

145-

const submitBody = JSON.parse(

146-

String(fetchGuardMock.mock.calls[0]?.[0]?.init?.body ?? "{}"),

147-

) as Record<string, unknown>;

158+

const submitBody = getSubmitBody();

148159

expect(submitBody).toEqual({

149160

prompt: "A spaceship emerges from the clouds",

150161

});

Original file line numberDiff line numberDiff line change

@@ -54,6 +54,22 @@ describe("minimax image-generation provider", () => {

5454

expect(init?.method).toBe("POST");

5555

}

5656
57+

function requireFirstPostJsonRequest(mock: ReturnType<typeof vi.fn>): {

58+

body?: unknown;

59+

ssrfPolicy?: unknown;

60+

url?: string;

61+

} {

62+

const [call] = mock.mock.calls;

63+

if (!call) {

64+

throw new Error("expected MiniMax image request");

65+

}

66+

const [request] = call;

67+

if (!request || typeof request !== "object" || Array.isArray(request)) {

68+

throw new Error("expected MiniMax image request");

69+

}

70+

return request as { body?: unknown; url?: string };

71+

}

72+
5773

it("generates PNG buffers through the shared provider HTTP path", async () => {

5874

mockMinimaxApiKey();

5975

const fetchMock = mockSuccessfulMinimaxImageResponse();

@@ -117,10 +133,7 @@ describe("minimax image-generation provider", () => {

117133

});

118134
119135

expect(postJsonRequest).toHaveBeenCalledOnce();

120-

const request = postJsonRequest.mock.calls[0]?.[0];

121-

if (!request) {

122-

throw new Error("expected MiniMax image request");

123-

}

136+

const request = requireFirstPostJsonRequest(postJsonRequest);

124137

expect(request.url).toBe("https://api.minimax.io/v1/image_generation");

125138

expect(request.body).toEqual({

126139

model: "image-01",

Original file line numberDiff line numberDiff line change

@@ -10,6 +10,14 @@ vi.mock("openclaw/plugin-sdk/ssrf-runtime", () => ({

1010

fetchWithSsrFGuard: fetchWithSsrFGuardMock,

1111

}));

1212
13+

function requireFirstGuardedFetchCall(): unknown {

14+

const [call] = fetchWithSsrFGuardMock.mock.calls;

15+

if (!call) {

16+

throw new Error("expected Volcengine guarded fetch call");

17+

}

18+

return call[0];

19+

}

20+
1321

function makeProviderConfig(overrides?: Record<string, unknown>) {

1422

return {

1523

apiKey: "test-api-key",

@@ -148,7 +156,7 @@ describe("Volcengine speech provider", () => {

148156

expect(result.fileExtension).toBe(".opus");

149157

expect(result.voiceCompatible).toBe(true);

150158
151-

const call = fetchWithSsrFGuardMock.mock.calls[0]?.[0];

159+

const call = requireFirstGuardedFetchCall();

152160

expect(call).toEqual({

153161

url: "https://voice.ap-southeast-1.bytepluses.com/api/v3/tts/unidirectional",

154162

init: {