From 93d829b7f669be73f67478c9c03381cfa6b272b4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 17 Mar 2026 07:46:46 +0000 Subject: [PATCH] refactor(image-tests): share empty ref assertions --- src/agents/pi-embedded-runner/run/images.test.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/agents/pi-embedded-runner/run/images.test.ts b/src/agents/pi-embedded-runner/run/images.test.ts index 305290df323..c6d50cda57d 100644 --- a/src/agents/pi-embedded-runner/run/images.test.ts +++ b/src/agents/pi-embedded-runner/run/images.test.ts @@ -16,6 +16,11 @@ function expectNoPromptImages(result: { detectedRefs: unknown[]; images: unknown expect(result.images).toHaveLength(0); } +function expectNoImageReferences(prompt: string) { + const refs = detectImageReferences(prompt); + expect(refs).toHaveLength(0); +} + describe("detectImageReferences", () => { it("detects absolute file paths with common extensions", () => { const prompt = "Check this image /path/to/screenshot.png and tell me what you see"; @@ -99,17 +104,11 @@ describe("detectImageReferences", () => { }); it("returns empty array when no images found", () => { - const prompt = "Just some text without any image references"; - const refs = detectImageReferences(prompt); - - expect(refs).toHaveLength(0); + expectNoImageReferences("Just some text without any image references"); }); it("ignores non-image file extensions", () => { - const prompt = "Check /path/to/document.pdf and /code/file.ts"; - const refs = detectImageReferences(prompt); - - expect(refs).toHaveLength(0); + expectNoImageReferences("Check /path/to/document.pdf and /code/file.ts"); }); it("handles paths inside quotes (without spaces)", () => {