webFetchPresentation.test.ts 1.1 KB

123456789101112131415161718192021222324
  1. import { describe, expect, it } from "vitest";
  2. import { getZCodeToolFamilyForName } from "@zcode/shared";
  3. import { resolveToolCallIdentity } from "@/lib/toolIdentity.js";
  4. import { getWebFetchPrimaryText } from "@/ToolCallBlocks/renderers/web-fetch.js";
  5. describe("WebFetch presentation", () => {
  6. it("separates fetching from searching", () => {
  7. expect(getZCodeToolFamilyForName("WebFetch")).toBe("web-fetch");
  8. for (const kind of ["fetch", "web_fetch", "webfetch"]) {
  9. expect(resolveToolCallIdentity({ kind }).family).toBe("web-fetch");
  10. expect(resolveToolCallIdentity({ toolName: kind, kind: "other" }).family).toBe("web-fetch");
  11. }
  12. for (const kind of ["WebSearch", "Grep", "Glob"]) {
  13. expect(resolveToolCallIdentity({ kind }).family).toBe("search");
  14. }
  15. });
  16. it("shows only a URL and tolerates incomplete streaming input", () => {
  17. expect(
  18. getWebFetchPrimaryText({ url: " https://example.com/paper ", prompt: "extract details" }),
  19. ).toBe("https://example.com/paper");
  20. expect(getWebFetchPrimaryText({ prompt: "extract details" })).toBe("");
  21. expect(getWebFetchPrimaryText(undefined)).toBe("");
  22. });
  23. });