From 7d94802e440e130bc912227588f312b0cb59db8e Mon Sep 17 00:00:00 2001 From: protosphinx <133899485+protosphinx@users.noreply.github.com> Date: Mon, 11 May 2026 16:10:43 +0000 Subject: [PATCH] test(fix,report): cover notes content, info-severity handling, multi-file fix, and info label Three gaps in fix.test.ts: - applyFixes outcome.notes is never asserted; add a case that verifies it contains "name-drift" and the corrected name - info-severity diagnostics are silently ignored (not counted as skipped) per the code, but no test pinned that contract - fixing name-drift on multiple files in one call was untested One gap in report.test.ts: - the info branch of the per-line severity label (pc.cyan("info ")) was exercised only by the footer-count test, not by a line-content check --- test/fix.test.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++ test/report.test.ts | 9 +++++++ 2 files changed, 69 insertions(+) diff --git a/test/fix.test.ts b/test/fix.test.ts index 8f1e7b9..be52e76 100644 --- a/test/fix.test.ts +++ b/test/fix.test.ts @@ -115,4 +115,64 @@ describe("applyFixes", () => { const written = await readFile(file, "utf8"); expect(written).toBe(original); }); + + it("populates notes with a human-readable description for each applied fix", async () => { + const file = await writeSkill( + "summarizer.md", + `---\nname: summariser\ndescription: x\n---\nbody\n`, + ); + const parsed = await parseSkillFile(file); + const outcome = await applyFixes( + [parsed], + [{ severity: "warn", rule: "name-drift", message: "", file }], + ); + expect(outcome.notes).toHaveLength(1); + expect(outcome.notes[0]).toContain("name-drift"); + expect(outcome.notes[0]).toContain("summarizer"); + }); + + it("does not count info-severity diagnostics as skipped", async () => { + const file = await writeSkill( + "x.md", + `---\nname: x\ndescription: y\n---\n`, + ); + const parsed = await parseSkillFile(file); + const outcome = await applyFixes( + [parsed], + [{ severity: "info", rule: "some-info-rule", message: "", file }], + ); + expect(outcome.fixed).toBe(0); + expect(outcome.skipped).toBe(0); + expect(outcome.filesChanged).toEqual([]); + }); + + it("fixes name-drift across multiple files in a single call", async () => { + const f1 = await writeSkill( + "alpha.md", + `---\nname: wrong\ndescription: x\n---\nbody\n`, + ); + const f2 = await writeSkill( + "beta.md", + `---\nname: wrong\ndescription: y\n---\nbody\n`, + ); + const [p1, p2] = await Promise.all([ + parseSkillFile(f1), + parseSkillFile(f2), + ]); + const outcome = await applyFixes( + [p1, p2], + [ + { severity: "warn", rule: "name-drift", message: "", file: f1 }, + { severity: "warn", rule: "name-drift", message: "", file: f2 }, + ], + ); + expect(outcome.fixed).toBe(2); + expect(outcome.filesChanged).toHaveLength(2); + const [c1, c2] = await Promise.all([ + readFile(f1, "utf8"), + readFile(f2, "utf8"), + ]); + expect(c1).toContain("name: alpha"); + expect(c2).toContain("name: beta"); + }); }); diff --git a/test/report.test.ts b/test/report.test.ts index 6a3c580..18e71c8 100644 --- a/test/report.test.ts +++ b/test/report.test.ts @@ -88,6 +88,15 @@ describe("reportText — grouping and counts", () => { expect(out).toContain("1 error,"); expect(out).not.toContain("1 errors"); }); + + it("renders 'info' label for info-severity diagnostic lines", () => { + const out = reportText( + [diag({ severity: "info", message: "just noting" })], + "/repo", + ); + expect(out).toContain("info"); + expect(out).toContain("just noting"); + }); }); describe("reportJson — wire format", () => {