test: tighten web tool assertions

This commit is contained in:
Peter Steinberger
2026-05-09 16:02:31 +01:00
parent 0ca5e45aff
commit f7719ae975
2 changed files with 14 additions and 17 deletions

View File

@@ -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 () => {

View File

@@ -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 () => {