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

推荐订阅源

V
V2EX
Y
Y Combinator Blog
博客园_首页
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
B
Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
WordPress大学
WordPress大学
L
LangChain Blog
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Help Net Security

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: tighten image generation assertions · openclaw/open...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -73,6 +73,15 @@ function requireFirstRequestHeaders(mock: ReturnType<typeof vi.fn>): Headers {

7373

return headers;

7474

}

757576+

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

77+

const call = (mock.mock.calls as unknown as Array<[unknown] | undefined>)[0];

78+

const arg = call?.[0];

79+

if (!arg) {

80+

throw new Error("expected mock call argument");

81+

}

82+

return arg;

83+

}

84+7685

function createProvider(overrides: Partial<OpenAiCompatibleImageProviderOptions> = {}) {

7786

return createOpenAiCompatibleImageGenerationProvider({

7887

id: "sample",

@@ -179,33 +188,36 @@ describe("OpenAI-compatible image provider helper", () => {

179188

},

180189

} as never);

181190182-

expect(resolveApiKeyForProviderMock).toHaveBeenCalledWith(

183-

expect.objectContaining({ provider: "sample" }),

184-

);

191+

const apiKeyParams = requireFirstCallArg(resolveApiKeyForProviderMock) as { provider?: string };

192+

expect(apiKeyParams.provider).toBe("sample");

185193

expect(sanitizeConfiguredModelProviderRequestMock).toHaveBeenCalledWith({

186194

allowPrivateNetwork: true,

187195

});

188-

expect(postJsonRequestMock).toHaveBeenCalledWith(

189-

expect.objectContaining({

190-

url: "https://sample.example/v1/images/generations",

191-

allowPrivateNetwork: true,

192-

ssrfPolicy: { allowRfc2544BenchmarkRange: true },

193-

dispatcherPolicy: { request: { allowPrivateNetwork: true } },

194-

body: {

195-

model: "custom-image",

196-

prompt: "draw a square",

197-

n: 2,

198-

size: "512x512",

199-

response_format: "b64_json",

200-

},

201-

}),

202-

);

203-

const headers = requireFirstRequestHeaders(postJsonRequestMock);

204-

expect(headers.get("Content-Type")).toBe("application/json");

205-

expect(result).toMatchObject({

196+

const jsonRequest = requireFirstCallArg(postJsonRequestMock) as {

197+

url?: string;

198+

allowPrivateNetwork?: boolean;

199+

ssrfPolicy?: unknown;

200+

dispatcherPolicy?: unknown;

201+

body?: unknown;

202+

};

203+

expect(jsonRequest.url).toBe("https://sample.example/v1/images/generations");

204+

expect(jsonRequest.allowPrivateNetwork).toBe(true);

205+

expect(jsonRequest.ssrfPolicy).toEqual({ allowRfc2544BenchmarkRange: true });

206+

expect(jsonRequest.dispatcherPolicy).toEqual({ request: { allowPrivateNetwork: true } });

207+

expect(jsonRequest.body).toEqual({

206208

model: "custom-image",

207-

images: [{ mimeType: "image/png", fileName: "image-1.png", revisedPrompt: "revised" }],

209+

prompt: "draw a square",

210+

n: 2,

211+

size: "512x512",

212+

response_format: "b64_json",

208213

});

214+

const headers = requireFirstRequestHeaders(postJsonRequestMock);

215+

expect(headers.get("Content-Type")).toBe("application/json");

216+

expect(result.model).toBe("custom-image");

217+

expect(result.images).toHaveLength(1);

218+

expect(result.images[0]?.mimeType).toBe("image/png");

219+

expect(result.images[0]?.fileName).toBe("image-1.png");

220+

expect(result.images[0]?.revisedPrompt).toBe("revised");

209221

expect(release).toHaveBeenCalledOnce();

210222

});

211223

@@ -221,12 +233,12 @@ describe("OpenAI-compatible image provider helper", () => {

221233

cfg: {} as never,

222234

});

223235224-

expect(postMultipartRequestMock).toHaveBeenCalledWith(

225-

expect.objectContaining({

226-

url: "https://sample.example/v1/images/edits",

227-

body: expect.any(FormData),

228-

}),

229-

);

236+

const multipartRequest = requireFirstCallArg(postMultipartRequestMock) as {

237+

url?: string;

238+

body?: unknown;

239+

};

240+

expect(multipartRequest.url).toBe("https://sample.example/v1/images/edits");

241+

expect(multipartRequest.body).toBeInstanceOf(FormData);

230242

const headers = requireFirstRequestHeaders(postMultipartRequestMock);

231243

expect(headers.has("Content-Type")).toBe(false);

232244

});

@@ -259,8 +271,7 @@ describe("OpenAI-compatible image provider helper", () => {

259271

deadline: { timeoutMs: 123, label: "Sample image generation" },

260272

defaultTimeoutMs: 60_000,

261273

});

262-

expect(postJsonRequestMock).toHaveBeenCalledWith(

263-

expect.objectContaining({ timeoutMs: 60_000 }),

264-

);

274+

const timeoutRequest = requireFirstCallArg(postJsonRequestMock) as { timeoutMs?: number };

275+

expect(timeoutRequest.timeoutMs).toBe(60_000);

265276

});

266277

});