From 48241afcc49b28b5ca45a8d028ec5968df3ad29b Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 17 Jul 2026 22:16:21 +0200 Subject: [PATCH] test(coding-agent): dropped stale URL read-cache assertions - 33d66643d removed the process-local URL response cache (#5803) but left two fetch-kagi-toggle tests asserting the old reuse contract. - Deleted the obsolete repeated-read reuse test (refetch behavior is covered by fetch-raw-mode and search-url-paths regressions) and kept the offset/limit selector contract without the no-network assertion. --- .../test/tools/fetch-kagi-toggle.test.ts | 40 ++----------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/packages/coding-agent/test/tools/fetch-kagi-toggle.test.ts b/packages/coding-agent/test/tools/fetch-kagi-toggle.test.ts index 63f4707d2..e0104bcc9 100644 --- a/packages/coding-agent/test/tools/fetch-kagi-toggle.test.ts +++ b/packages/coding-agent/test/tools/fetch-kagi-toggle.test.ts @@ -558,35 +558,11 @@ describe("read tool URL handling", () => { expect(htmlToMarkdownSpy).not.toHaveBeenCalled(); }); - it("reuses cached output for repeated plain URL reads", async () => { - const session = createSession(); - const tool = new ReadTool(session); - const pageUrl = "https://example.com/repeated-read-cache"; - const loadPageSpy = vi.spyOn(scrapers, "loadPage").mockResolvedValue({ - ok: true, - status: 200, - contentType: "text/plain", - finalUrl: pageUrl, - content: "Cached line 1\nCached line 2", - }); - - const firstResult = await tool.execute("fetch-cache-first", { path: pageUrl }); - const secondResult = await tool.execute("fetch-cache-second", { path: pageUrl }); - const firstText = firstResult.content.find(content => content.type === "text"); - const secondText = secondResult.content.find(content => content.type === "text"); - - expect(firstText?.type).toBe("text"); - expect(firstText?.text).toContain("Cached line 1"); - expect(secondText?.type).toBe("text"); - expect(secondText?.text).toContain("Cached line 1"); - expect(loadPageSpy).toHaveBeenCalledTimes(1); - }); - - it("supports offset and limit for URL reads using cached output", async () => { + it("supports offset and limit selectors on URL reads", async () => { const session = createSession(); const tool = new ReadTool(session); const pageUrl = "https://example.com/offset-test"; - const loadPageSpy = vi.spyOn(scrapers, "loadPage").mockResolvedValue({ + vi.spyOn(scrapers, "loadPage").mockResolvedValue({ ok: true, status: 200, contentType: "text/plain", @@ -594,27 +570,17 @@ describe("read tool URL handling", () => { content: "Line 1\nLine 2\nLine 3\nLine 4", }); - const firstResult = await tool.execute("fetch-offset-prime", { path: pageUrl }); - const firstText = firstResult.content.find(content => content.type === "text"); - expect(firstText?.type).toBe("text"); - expect(firstText?.text).toContain("Line 1"); - expect(loadPageSpy).toHaveBeenCalledTimes(1); - - loadPageSpy.mockClear(); - loadPageSpy.mockRejectedValue(new Error("network should not be hit")); - const pagedResult = await tool.execute("fetch-offset-page", { path: `${pageUrl}:7-8`, }); const pagedText = pagedResult.content.find(content => content.type === "text"); expect(pagedText?.type).toBe("text"); - // `:7-8` selects 2 lines starting at offset 7 of the wrapped cached + // `:7-8` selects 2 lines starting at offset 7 of the wrapped URL // output. Read tool widens the window by ±3 unanchored context lines // so anchors at the boundary stay fresh, so adjacent content lines are // also visible. expect(pagedText?.text).toContain("Line 1"); expect(pagedText?.text).toContain("Line 2"); - expect(loadPageSpy).not.toHaveBeenCalled(); expect(fs.readdirSync(path.join(testDir, "session")).some(file => file.endsWith(".read.log"))).toBe(true); }); });