mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 19:00:43 +00:00
test: tighten web tool assertions
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user