From 0f1df8b2e2d44fd9c97fbad7640710030a3b017f Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 15 May 2026 09:37:24 +0200 Subject: [PATCH] test(coding-agent): updated edit-diff guards to provide non-empty hashline bodies Commit d43655541 made splitHashlineInputs silently drop sections whose body has no operations, so '@\n' alone now yields zero sections and trips the 'exactly one hashline section' guard before reaching the no-op or local-URL checks the tests intended to exercise. - 'returns no-op error for unchanged content' now uses '= 1..1' with the existing line as payload (true no-op via formatLineHash). - 'returns a handled error when the source path is a local URL' appends '+ EOF\n' so the section is emitted and resolveToCwd surfaces the internal-scheme rejection. --- packages/coding-agent/test/edit-diff.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/coding-agent/test/edit-diff.test.ts b/packages/coding-agent/test/edit-diff.test.ts index 7fd399a1e..6a9c20a35 100644 --- a/packages/coding-agent/test/edit-diff.test.ts +++ b/packages/coding-agent/test/edit-diff.test.ts @@ -8,6 +8,7 @@ import { computeHashlineDiff, DEFAULT_FUZZY_THRESHOLD, findMatch, + formatLineHash, } from "@oh-my-pi/pi-coding-agent/edit"; import { HL_EDIT_SEP } from "@oh-my-pi/pi-coding-agent/hashline/hash"; @@ -233,9 +234,14 @@ describe("computeHashlineDiff", () => { test("returns no-op error for unchanged content when move is absent", async () => { const sourcePath = path.join(tempDir, "source.txt"); - await Bun.write(sourcePath, "unchanged content\n"); + const line = "unchanged content"; + await Bun.write(sourcePath, `${line}\n`); - const result = await computeHashlineDiff({ input: `@${sourcePath}\n` }, tempDir); + // `= 1..1` with the same line as payload is a true no-op: the + // edit fires through computeHashlineDiff but produces identical content. + const anchor = formatLineHash(1, line); + const input = `@${sourcePath}\n= ${anchor}..${anchor}\n${HL_EDIT_SEP}${line}\n`; + const result = await computeHashlineDiff({ input }, tempDir); expect("error" in result).toBe(true); if ("error" in result) { expect(result.error).toContain("No changes would be made"); @@ -253,7 +259,7 @@ describe("computeHashlineDiff", () => { } }); test("returns a handled error when the source path is a local URL", async () => { - const result = await computeHashlineDiff({ input: "@local://PLAN.md\n" }, tempDir); + const result = await computeHashlineDiff({ input: "@local://PLAN.md\n+ EOF\n" }, tempDir); expect("error" in result).toBe(true); if ("error" in result) {