From f7719ae975d889156d67a8a29d585cbcd8177e15 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 16:02:31 +0100 Subject: [PATCH] test: tighten web tool assertions --- src/agents/tools/web-search.redirect.test.ts | 17 +++++++++-------- src/agents/tools/web-tools.readability.test.ts | 14 +++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/agents/tools/web-search.redirect.test.ts b/src/agents/tools/web-search.redirect.test.ts index 4ded0dd0139..0531baac569 100644 --- a/src/agents/tools/web-search.redirect.test.ts +++ b/src/agents/tools/web-search.redirect.test.ts @@ -30,14 +30,15 @@ describe("web_search redirect resolution hardening", () => { const resolved = await resolveCitationRedirectUrl("https://example.com/start"); expect(resolved).toBe("https://example.com/final"); - expect(withStrictWebToolsEndpointMock).toHaveBeenCalledWith( - expect.objectContaining({ - url: "https://example.com/start", - timeoutMs: 5000, - init: { method: "HEAD" }, - }), - expect.any(Function), - ); + expect(withStrictWebToolsEndpointMock).toHaveBeenCalledTimes(1); + const [params, run] = withStrictWebToolsEndpointMock.mock.calls[0] as [ + { url?: unknown; timeoutMs?: unknown; init?: { method?: unknown } }, + unknown, + ]; + expect(params.url).toBe("https://example.com/start"); + expect(params.timeoutMs).toBe(5000); + expect(params.init?.method).toBe("HEAD"); + expect(typeof run).toBe("function"); }); it("falls back to the original URL when guarded resolution fails", async () => { diff --git a/src/agents/tools/web-tools.readability.test.ts b/src/agents/tools/web-tools.readability.test.ts index 0ad4ce4928f..6ab7fffa72e 100644 --- a/src/agents/tools/web-tools.readability.test.ts +++ b/src/agents/tools/web-tools.readability.test.ts @@ -34,11 +34,9 @@ describe("web fetch readability", () => { extractMode: "text", config: {}, }); - expect(result).toMatchObject({ - extractor: "readability", - text: "extracted text", - title: "Extracted", - }); + expect(result?.extractor).toBe("readability"); + expect(result?.text).toBe("extracted text"); + expect(result?.title).toBe("Extracted"); }); it("reuses extractor resolution for repeated calls with the same config object", async () => { @@ -114,10 +112,8 @@ describe("web fetch readability", () => { extractMode: "text", config: {}, }); - expect(result).toMatchObject({ - extractor: "readability", - text: "fallback text", - }); + expect(result?.extractor).toBe("readability"); + expect(result?.text).toBe("fallback text"); }); it("returns null when extractor loading throws", async () => {