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

推荐订阅源

T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
雷峰网
雷峰网
罗磊的独立博客
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
博客园 - 司徒正美
Last Week in AI
Last Week in AI
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
宝玉的分享
宝玉的分享

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: dedupe brave fetch mock calls · openclaw/openclaw@6...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -72,6 +72,22 @@ function readHeader(init: unknown, name: string): string | null {

7272

return new Headers(headers).get(name);

7373

}

747475+

function fetchCall(mockFetch: { mock: { calls: Array<Array<unknown>> } }, index = 0) {

76+

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

77+

if (!call) {

78+

throw new Error(`Expected fetch call ${index + 1}`);

79+

}

80+

return call;

81+

}

82+83+

function fetchRequestUrl(mockFetch: { mock: { calls: Array<Array<unknown>> } }, index = 0) {

84+

return new URL(String(fetchCall(mockFetch, index)[0]));

85+

}

86+87+

function fetchRequestInit(mockFetch: { mock: { calls: Array<Array<unknown>> } }, index = 0) {

88+

return fetchCall(mockFetch, index)[1];

89+

}

90+7591

describe("brave web search provider", () => {

7692

const priorFetch = global.fetch;

7793

@@ -220,7 +236,7 @@ describe("brave web search provider", () => {

220236221237

await tool.execute({ query: "latest ai news" });

222238223-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

239+

const requestUrl = fetchRequestUrl(mockFetch);

224240

expect(requestUrl.origin).toBe("https://api.search.brave.com");

225241

expect(requestUrl.pathname).toBe("/proxy/res/v1/web/search");

226242

});

@@ -245,7 +261,7 @@ describe("brave web search provider", () => {

245261246262

await tool.execute({ query: "latest ai news" });

247263248-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

264+

const requestUrl = fetchRequestUrl(mockFetch);

249265

expect(requestUrl.pathname).toBe("/proxy/res/v1/llm/context");

250266

});

251267

@@ -288,12 +304,8 @@ describe("brave web search provider", () => {

288304

await secondTool.execute({ query: "base url cache identity" });

289305290306

expect(mockFetch).toHaveBeenCalledTimes(2);

291-

expect(new URL(String(mockFetch.mock.calls[0]?.[0])).pathname).toBe(

292-

"/proxy-one/res/v1/web/search",

293-

);

294-

expect(new URL(String(mockFetch.mock.calls[1]?.[0])).pathname).toBe(

295-

"/proxy-two/res/v1/web/search",

296-

);

307+

expect(fetchRequestUrl(mockFetch).pathname).toBe("/proxy-one/res/v1/web/search");

308+

expect(fetchRequestUrl(mockFetch, 1).pathname).toBe("/proxy-two/res/v1/web/search");

297309

});

298310299311

it("rejects invalid Brave mode values in the plugin config schema", () => {

@@ -393,7 +405,7 @@ describe("brave web search provider", () => {

393405394406

await tool.execute({ query: "latest ai news", freshness: "week" });

395407396-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

408+

const requestUrl = fetchRequestUrl(mockFetch);

397409

expect(requestUrl.pathname).toBe("/res/v1/llm/context");

398410

expect(requestUrl.searchParams.get("freshness")).toBe("pw");

399411

});

@@ -422,10 +434,10 @@ describe("brave web search provider", () => {

422434423435

await tool.execute({ query: "latest ai news" });

424436425-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

437+

const requestUrl = fetchRequestUrl(mockFetch);

426438

expect(requestUrl.searchParams.get("apikey")).toBeNull();

427439

expect(requestUrl.searchParams.get("key")).toBeNull();

428-

expect(readHeader(mockFetch.mock.calls[0]?.[1], "X-Subscription-Token")).toBe("brave-test-key");

440+

expect(readHeader(fetchRequestInit(mockFetch), "X-Subscription-Token")).toBe("brave-test-key");

429441

});

430442431443

it("sends Brave llm-context auth in the X-Subscription-Token header", async () => {

@@ -445,10 +457,10 @@ describe("brave web search provider", () => {

445457446458

await tool.execute({ query: "latest ai news" });

447459448-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

460+

const requestUrl = fetchRequestUrl(mockFetch);

449461

expect(requestUrl.searchParams.get("apikey")).toBeNull();

450462

expect(requestUrl.searchParams.get("key")).toBeNull();

451-

expect(readHeader(mockFetch.mock.calls[0]?.[1], "X-Subscription-Token")).toBe("brave-test-key");

463+

expect(readHeader(fetchRequestInit(mockFetch), "X-Subscription-Token")).toBe("brave-test-key");

452464

});

453465454466

it("passes bounded date ranges to Brave llm-context endpoint", async () => {

@@ -472,7 +484,7 @@ describe("brave web search provider", () => {

472484

date_before: "2025-01-31",

473485

});

474486475-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

487+

const requestUrl = fetchRequestUrl(mockFetch);

476488

expect(requestUrl.pathname).toBe("/res/v1/llm/context");

477489

expect(requestUrl.searchParams.get("freshness")).toBe("2025-01-01to2025-01-31");

478490

});

@@ -495,7 +507,7 @@ describe("brave web search provider", () => {

495507

await tool.execute({ query: "latest ai news", date_after: "2025-01-01" });

496508497509

const today = new Date().toISOString().slice(0, 10);

498-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

510+

const requestUrl = fetchRequestUrl(mockFetch);

499511

expect(requestUrl.pathname).toBe("/res/v1/llm/context");

500512

expect(requestUrl.searchParams.get("freshness")).toBe(`2025-01-01to${today}`);

501513

});

@@ -584,7 +596,7 @@ describe("brave web search provider", () => {

584596

country: "VN",

585597

});

586598587-

const requestUrl = new URL(String(mockFetch.mock.calls[0]?.[0]));

599+

const requestUrl = fetchRequestUrl(mockFetch);

588600

expect(requestUrl.searchParams.get("country")).toBe("ALL");

589601

});

590602