fix(browser): show saved screenshot path

This commit is contained in:
can1357
2026-03-26 19:12:51 +01:00
parent ead5e91c4e
commit e020c3cc63
3 changed files with 25 additions and 2 deletions
@@ -1,5 +1,7 @@
import { describe, expect, it } from "bun:test";
import { dedupeParseErrors, formatParseErrors } from "@oh-my-pi/pi-coding-agent/tools/render-utils";
import * as os from "node:os";
import * as path from "node:path";
import { dedupeParseErrors, formatParseErrors, formatSavedScreenshotLine } from "@oh-my-pi/pi-coding-agent/tools/render-utils";
describe("parse error formatting", () => {
it("deduplicates parse errors while preserving order", () => {
@@ -30,3 +32,19 @@ describe("parse error formatting", () => {
]);
});
});
describe("browser screenshot path formatting", () => {
it("shows home-relative saved paths with tilde shorthand", () => {
const filePath = path.join(os.homedir(), "screenshots", "capture.png");
expect(formatSavedScreenshotLine("image/png", 2048, filePath)).toBe(
"Saved: image/png (2.00 KB) to ~/screenshots/capture.png",
);
});
it("keeps non-home saved paths unchanged", () => {
expect(formatSavedScreenshotLine("image/png", 2048, "/tmp/capture.png")).toBe(
"Saved: image/png (2.00 KB) to /tmp/capture.png",
);
});
});