Article Title
+This is the main content of the article. It contains important information.
+Second paragraph with more details about the topic.
+diff --git a/src/tools/builtin/web-fetch.test.ts b/src/tools/builtin/web-fetch.test.ts index 9705e84..1b3dc80 100644 --- a/src/tools/builtin/web-fetch.test.ts +++ b/src/tools/builtin/web-fetch.test.ts @@ -1,34 +1,142 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { webFetchTool } from './web-fetch.js'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { webFetchTool, _clearCache, _MAX_CONTENT_LENGTH } from './web-fetch.js'; +// --------------------------------------------------------------------------- // Mock global fetch +// --------------------------------------------------------------------------- + const mockFetch = vi.fn(); vi.stubGlobal('fetch', mockFetch); +// --------------------------------------------------------------------------- +// HTML fixture used by extraction tests +// --------------------------------------------------------------------------- + +const SAMPLE_HTML = ` +
This is the main content of the article. It contains important information.
+Second paragraph with more details about the topic.
+World
', + text: async () => SAMPLE_HTML, headers: new Headers({ 'content-type': 'text/html' }), }); const result = await webFetchTool.execute({ url: 'https://example.com' }); expect(result.success).toBe(true); expect(result.output).toBeTruthy(); + // Should contain markdown-ish content (heading or paragraph text) + expect(result.output).toContain('Article Title'); + // Should NOT contain raw HTML tags + expect(result.output).not.toContain('