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

推荐订阅源

Google DeepMind News
Google DeepMind News
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
罗磊的独立博客
Last Week in AI
Last Week in AI
B
Blog
IT之家
IT之家
S
SegmentFault 最新的问题
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
博客园 - 聂微东
U
Unit 42
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
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
test: tighten pdf tool assertions · openclaw/openclaw@49c...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -80,6 +80,15 @@ function withDefaultModel(primary: string): OpenClawConfig {

8080

} as OpenClawConfig;

8181

}

828283+

function expectFields(value: unknown, expected: Record<string, unknown>): void {

84+

expect(value).toBeTypeOf("object");

85+

expect(value).not.toBeNull();

86+

const record = value as Record<string, unknown>;

87+

for (const [key, expectedValue] of Object.entries(expected)) {

88+

expect(record[key], key).toEqual(expectedValue);

89+

}

90+

}

91+8392

async function stubPdfToolInfra(

8493

agentDir: string,

8594

params?: {

@@ -257,9 +266,7 @@ describe("createPdfTool", () => {

257266

await withConfiguredPdfTool(async (tool) => {

258267

const manyPdfs = Array.from({ length: 15 }, (_, i) => `/tmp/doc${i}.pdf`);

259268

const result = await tool.execute("t1", { prompt: "test", pdfs: manyPdfs });

260-

expect(result).toMatchObject({

261-

details: { error: "too_many_pdfs" },

262-

});

269+

expectFields(result.details, { error: "too_many_pdfs" });

263270

});

264271

});

265272

@@ -297,9 +304,7 @@ describe("createPdfTool", () => {

297304

prompt: "test",

298305

pdf: "ftp://example.com/doc.pdf",

299306

});

300-

expect(result).toMatchObject({

301-

details: { error: "unsupported_pdf_reference" },

302-

});

307+

expectFields(result.details, { error: "unsupported_pdf_reference" });

303308

});

304309

});

305310

@@ -326,15 +331,13 @@ describe("createPdfTool", () => {

326331

pdf: `media://inbound/${mediaId}`,

327332

});

328333329-

expect(loadSpy).toHaveBeenCalledWith(

330-

`media://inbound/${mediaId}`,

331-

expect.objectContaining({

332-

localRoots: [],

333-

}),

334-

);

335-

expect(result).toMatchObject({

336-

content: [{ type: "text", text: "native summary" }],

337-

details: { native: true, model: ANTHROPIC_PDF_MODEL },

334+

const [loadRef, loadOptions] = loadSpy.mock.calls[0] ?? [];

335+

expect(loadRef).toBe(`media://inbound/${mediaId}`);

336+

expectFields(loadOptions, { localRoots: [] });

337+

expect(result.content).toEqual([{ type: "text", text: "native summary" }]);

338+

expectFields(result.details, {

339+

native: true,

340+

model: ANTHROPIC_PDF_MODEL,

338341

});

339342

});

340343

});

@@ -364,12 +367,11 @@ describe("createPdfTool", () => {

364367

pdf: "http://198.18.0.153/doc.pdf",

365368

});

366369367-

expect(loadSpy).toHaveBeenCalledWith(

368-

"http://198.18.0.153/doc.pdf",

369-

expect.objectContaining({

370-

ssrfPolicy: { allowRfc2544BenchmarkRange: true },

371-

}),

372-

);

370+

const [loadRef, loadOptions] = loadSpy.mock.calls[0] ?? [];

371+

expect(loadRef).toBe("http://198.18.0.153/doc.pdf");

372+

expectFields(loadOptions, {

373+

ssrfPolicy: { allowRfc2544BenchmarkRange: true },

374+

});

373375

});

374376

});

375377

@@ -396,7 +398,9 @@ describe("createPdfTool", () => {

396398

pdf: mediaPath,

397399

});

398400399-

expect(loadSpy).toHaveBeenCalledWith(mediaPath, expect.any(Object));

401+

const [loadRef, loadOptions] = loadSpy.mock.calls[0] ?? [];

402+

expect(loadRef).toBe(mediaPath);

403+

expect(loadOptions).toBeTypeOf("object");

400404

});

401405

});

402406

});

@@ -417,21 +421,22 @@ describe("createPdfTool", () => {

417421

pdf: "/tmp/doc.pdf",

418422

});

419423420-

expect(modelsConfig.ensureOpenClawModelsJson).toHaveBeenCalledWith(

421-

expect.objectContaining({

422-

agents: expect.objectContaining({

423-

defaults: expect.objectContaining({

424-

pdfModel: { primary: ANTHROPIC_PDF_MODEL },

425-

}),

426-

}),

427-

}),

428-

agentDir,

429-

{ workspaceDir },

424+

const ensureModelsJsonMock = vi.mocked(modelsConfig.ensureOpenClawModelsJson);

425+

const [modelsConfigArg, modelsAgentDir, modelsOptions] =

426+

ensureModelsJsonMock.mock.calls[0] ?? [];

427+

expectFields(

428+

(modelsConfigArg as { agents?: { defaults?: unknown } } | undefined)?.agents?.defaults,

429+

{

430+

pdfModel: { primary: ANTHROPIC_PDF_MODEL },

431+

},

430432

);

433+

expect(modelsAgentDir).toBe(agentDir);

434+

expect(modelsOptions).toEqual({ workspaceDir });

431435

expect(extractSpy).not.toHaveBeenCalled();

432-

expect(result).toMatchObject({

433-

content: [{ type: "text", text: "native summary" }],

434-

details: { native: true, model: ANTHROPIC_PDF_MODEL },

436+

expect(result.content).toEqual([{ type: "text", text: "native summary" }]);

437+

expectFields(result.details, {

438+

native: true,

439+

model: ANTHROPIC_PDF_MODEL,

435440

});

436441

});

437442

});

@@ -474,9 +479,10 @@ describe("createPdfTool", () => {

474479

});

475480476481

expect(extractSpy).toHaveBeenCalledTimes(1);

477-

expect(result).toMatchObject({

478-

content: [{ type: "text", text: "fallback summary" }],

479-

details: { native: false, model: OPENAI_PDF_MODEL },

482+

expect(result.content).toEqual([{ type: "text", text: "fallback summary" }]);

483+

expectFields(result.details, {

484+

native: false,

485+

model: OPENAI_PDF_MODEL,

480486

});

481487

const [, context] = completeMock.mock.calls[0] ?? [];

482488

expect(context?.systemPrompt).toBeUndefined();

@@ -510,9 +516,10 @@ describe("createPdfTool", () => {

510516

pdf: "/tmp/doc.pdf",

511517

});

512518513-

expect(result).toMatchObject({

514-

content: [{ type: "text", text: "codex summary" }],

515-

details: { native: false, model: CODEX_PDF_MODEL },

519+

expect(result.content).toEqual([{ type: "text", text: "codex summary" }]);

520+

expectFields(result.details, {

521+

native: false,

522+

model: CODEX_PDF_MODEL,

516523

});

517524

expect(completeMock).toHaveBeenCalledTimes(1);

518525

const [, context] = completeMock.mock.calls[0] ?? [];

@@ -547,9 +554,10 @@ describe("createPdfTool", () => {

547554

pdf: "/tmp/doc.pdf",

548555

});

549556550-

expect(result).toMatchObject({

551-

content: [{ type: "text", text: "codex summary" }],

552-

details: { native: false, model: CODEX_PDF_MODEL },

557+

expect(result.content).toEqual([{ type: "text", text: "codex summary" }]);

558+

expectFields(result.details, {

559+

native: false,

560+

model: CODEX_PDF_MODEL,

553561

});

554562

expect(completeMock).toHaveBeenCalledTimes(1);

555563

const [, context] = completeMock.mock.calls[0] ?? [];