feat(FN-3758): align web fetch test coverage and documentation

Aligns web fetch tool test coverage across multiple test suites and updates the agents documentation, with a patch changeset for `@runfusion/fusion`.

Fusion-Task-Id: FN-3758
This commit is contained in:
Fusion
2026-05-08 18:47:58 -07:00
committed by gsxdsm
parent ccefdd2c52
commit e04af96d9c
18 changed files with 633 additions and 72 deletions

View File

@@ -0,0 +1,43 @@
import { describe, expect, it, vi } from "vitest";
const fetchWebContentMock = vi.hoisted(() => vi.fn());
vi.mock("@fusion/engine", () => ({
fetchWebContent: fetchWebContentMock,
}));
import kbExtension from "../extension.js";
describe("extension fn_web_fetch", () => {
it("registers and executes fn_web_fetch", async () => {
const tools = new Map<string, any>();
const api = {
registerTool(def: any) {
tools.set(def.name, def);
},
registerCommand: vi.fn(),
registerShortcut: vi.fn(),
registerFlag: vi.fn(),
on: vi.fn(),
} as any;
fetchWebContentMock.mockResolvedValue({
finalUrl: "https://example.com/final",
status: 200,
contentType: "text/plain",
title: "Example",
content: "hello world",
truncated: false,
bytesRead: 11,
});
kbExtension(api);
const tool = tools.get("fn_web_fetch");
expect(tool).toBeTruthy();
const result = await tool.execute("id", { url: "https://example.com" }, undefined, undefined, { cwd: process.cwd() });
expect(fetchWebContentMock).toHaveBeenCalledWith("https://example.com", { timeoutMs: undefined, maxBytes: undefined });
expect(result.content[0].text).toContain("https://example.com/final");
expect(result.details.status).toBe(200);
});
});