From f006e97caa589e8680b57768d7cf8a01d9073af6 Mon Sep 17 00:00:00 2001 From: Shakker Date: Tue, 12 May 2026 00:43:54 +0100 Subject: [PATCH] test: specify prompt image path refs --- .../pi-embedded-runner/run/images.test.ts | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/agents/pi-embedded-runner/run/images.test.ts b/src/agents/pi-embedded-runner/run/images.test.ts index b6b41ecd514..6d94b332839 100644 --- a/src/agents/pi-embedded-runner/run/images.test.ts +++ b/src/agents/pi-embedded-runner/run/images.test.ts @@ -50,24 +50,31 @@ describe("detectImageReferences", () => { it("detects relative paths starting with ./", () => { const ref = expectSingleImageReference("Look at ./images/photo.jpg"); - expect(ref?.raw).toBe("./images/photo.jpg"); - expect(ref?.type).toBe("path"); + expect(ref).toStrictEqual({ + raw: "./images/photo.jpg", + type: "path", + resolved: "./images/photo.jpg", + }); }); it("detects relative paths starting with ../", () => { const ref = expectSingleImageReference("The file is at ../screenshots/test.jpeg"); - expect(ref?.raw).toBe("../screenshots/test.jpeg"); - expect(ref?.type).toBe("path"); + expect(ref).toStrictEqual({ + raw: "../screenshots/test.jpeg", + type: "path", + resolved: "../screenshots/test.jpeg", + }); }); it("detects home directory paths starting with ~/", () => { const ref = expectSingleImageReference("My photo is at ~/Pictures/vacation.png"); - expect(ref?.raw).toBe("~/Pictures/vacation.png"); - expect(ref?.type).toBe("path"); - // Resolved path should expand ~ - expect(ref?.resolved?.startsWith("~")).toBe(false); + expect(ref).toStrictEqual({ + raw: "~/Pictures/vacation.png", + type: "path", + resolved: path.join(process.env.HOME ?? os.homedir(), "Pictures/vacation.png"), + }); }); it("detects multiple image references in a prompt", () => { @@ -80,7 +87,13 @@ describe("detectImageReferences", () => { 1, ); - expect(refs.map((ref) => ref.type)).toContain("path"); + expect(refs).toStrictEqual([ + { + raw: "/home/user/photo1.png", + type: "path", + resolved: "/home/user/photo1.png", + }, + ]); }); it("does not leak parser state between calls", () => {