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

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
IT之家
IT之家
Y
Y Combinator Blog
T
Tailwind CSS Blog
B
Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
InfoQ
J
Java Code Geeks
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain 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
test: guard image understanding mock calls · openclaw/ope...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -48,12 +48,23 @@ type AuthRequestCall = {

4848

store?: unknown;

4949

};

505051-

function requireFirstMockCall(mock: { mock: { calls: unknown[][] } }, label: string): unknown[] {

52-

const [call] = mock.mock.calls;

51+

function requireMockCallAt<const Calls extends readonly unknown[][]>(

52+

mock: { mock: { calls: Calls } },

53+

index: number,

54+

label: string,

55+

): Calls[number] {

56+

const call = mock.mock.calls.at(index);

5357

if (!call) {

54-

throw new Error(`Expected ${label} call`);

58+

throw new Error(`Expected ${label} call ${index}`);

5559

}

56-

return call;

60+

return call as Calls[number];

61+

}

62+63+

function requireFirstMockCall<const Calls extends readonly unknown[][]>(

64+

mock: { mock: { calls: Calls } },

65+

label: string,

66+

): Calls[number] {

67+

return requireMockCallAt(mock, 0, label);

5768

}

58695970

function requireRecord(value: unknown, label: string): Record<string, unknown> {

@@ -163,7 +174,7 @@ describe("describeImageWithModel", () => {

163174

});

164175165176

function getApiKeyForModelCall(index = 0): AuthRequestCall {

166-

const call = (getApiKeyForModelMock.mock.calls as unknown[][])[index];

177+

const call = (getApiKeyForModelMock.mock.calls as unknown[][]).at(index);

167178

if (!call) {

168179

throw new Error(`Expected getApiKeyForModel call ${index}`);

169180

}

@@ -415,10 +426,7 @@ describe("describeImageWithModel", () => {

415426

model: "gpt-5.4",

416427

});

417428

expect(completeMock).toHaveBeenCalledOnce();

418-

const firstCall = completeMock.mock.calls[0];

419-

if (!firstCall) {

420-

throw new Error("Expected image completion call");

421-

}

429+

const firstCall = requireFirstMockCall(completeMock, "image completion");

422430

const [completionModel, context, options] = firstCall;

423431

expect(completionModel).toEqual({

424432

provider: "openai-codex",

@@ -483,10 +491,7 @@ describe("describeImageWithModel", () => {

483491

text: "openrouter ok",

484492

model: "google/gemini-2.5-flash",

485493

});

486-

const firstCall = completeMock.mock.calls[0];

487-

if (!firstCall) {

488-

throw new Error("Expected OpenRouter image completion call");

489-

}

494+

const firstCall = requireFirstMockCall(completeMock, "OpenRouter image completion");

490495

const [, context] = firstCall;

491496

expect(context.systemPrompt).toBeUndefined();

492497

const userMessage = context.messages[0];

@@ -606,10 +611,7 @@ describe("describeImageWithModel", () => {

606611

model: model.id,

607612

});

608613

expect(completeMock).toHaveBeenCalledTimes(2);

609-

const retryCall = completeMock.mock.calls[1];

610-

if (!retryCall) {

611-

throw new Error("Expected retry image completion call");

612-

}

614+

const retryCall = requireMockCallAt(completeMock, 1, "retry image completion");

613615

const [retryModel, , retryOptions] = retryCall;

614616

if (!retryOptions?.onPayload) {

615617

throw new Error("expected retry payload mapper");

@@ -654,10 +656,7 @@ describe("describeImageWithModel", () => {

654656

const assertion = expect(result).rejects.toThrow("image description timed out after 25ms");

655657

await vi.advanceTimersByTimeAsync(25);

656658

await assertion;

657-

const firstCall = completeMock.mock.calls[0];

658-

if (!firstCall) {

659-

throw new Error("Expected timed image completion call");

660-

}

659+

const firstCall = requireFirstMockCall(completeMock, "timed image completion");

661660

const [, , options] = firstCall;

662661

if (!options?.signal) {

663662

throw new Error("Expected image completion abort signal");