From 3dbd6b6f02aea7cd7b8313f2ef68ecd32d2603a2 Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 12 Feb 2026 20:32:13 +0100 Subject: [PATCH] fix(coding-agent): make tool tests format-agnostic for hashline output --- packages/coding-agent/test/tools.test.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/coding-agent/test/tools.test.ts b/packages/coding-agent/test/tools.test.ts index 76c5da102..328fba108 100644 --- a/packages/coding-agent/test/tools.test.ts +++ b/packages/coding-agent/test/tools.test.ts @@ -83,7 +83,10 @@ describe("Coding Agent Tools", () => { const result = await readTool.execute("test-call-1", { path: testFile }); - expect(getTextOutput(result)).toBe(content); + const output = getTextOutput(result); + expect(output).toContain("Hello, world!"); + expect(output).toContain("Line 2"); + expect(output).toContain("Line 3"); // No truncation message since file fits within limits expect(getTextOutput(result)).not.toContain("Use offset="); expect(result.details?.truncation).toBeUndefined(); @@ -487,7 +490,7 @@ function b() { const output = getTextOutput(result); expect(output).toContain("1. example.txt:2"); - expect(output).toContain(">>2|match line"); + expect(output).toMatch(/>>\s*2.*\|match line/); }); it("should respect global limit and include context lines", async () => { @@ -505,9 +508,9 @@ function b() { const output = getTextOutput(result); expect(output).toContain("1. context.txt:2"); - expect(output).toContain(" 1|before"); - expect(output).toContain(">>2|match one"); - expect(output).toContain(" 3|after"); + expect(output).toMatch(/\b1.*\|before/); + expect(output).toMatch(/>>\s*2.*\|match one/); + expect(output).toMatch(/\b3.*\|after/); expect(output).toContain("[1 matches limit reached. Use limit=2 for more]"); // Ensure second match is not present expect(output).not.toContain("match two");