From 002f158da639a1fa1189f1c3e762d3351bc7be18 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 18 Feb 2026 23:37:03 +0000 Subject: [PATCH] test: merge empty-id sanitize mode checks --- ...helpers.sanitizeuserfacingtext.e2e.test.ts | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/agents/pi-embedded-helpers.sanitizeuserfacingtext.e2e.test.ts b/src/agents/pi-embedded-helpers.sanitizeuserfacingtext.e2e.test.ts index 4d9817f59f6..ee24dac096d 100644 --- a/src/agents/pi-embedded-helpers.sanitizeuserfacingtext.e2e.test.ts +++ b/src/agents/pi-embedded-helpers.sanitizeuserfacingtext.e2e.test.ts @@ -191,9 +191,6 @@ describe("sanitizeToolCallId", () => { it("strips invalid characters", () => { expect(sanitizeToolCallId("call_abc|item:456")).toBe("callabcitem456"); }); - it("returns default for empty IDs", () => { - expect(sanitizeToolCallId("")).toBe("defaulttoolid"); - }); }); describe("strict mode (alphanumeric only)", () => { @@ -204,9 +201,6 @@ describe("sanitizeToolCallId", () => { "whatsapplogin17687998415271", ); }); - it("returns default for empty IDs", () => { - expect(sanitizeToolCallId("", "strict")).toBe("defaulttoolid"); - }); }); describe("strict9 mode (Mistral tool call IDs)", () => { @@ -214,9 +208,26 @@ describe("sanitizeToolCallId", () => { const out = sanitizeToolCallId("call_abc|item:456", "strict9"); expect(out).toMatch(/^[a-zA-Z0-9]{9}$/); }); - it("returns default for empty IDs", () => { - expect(sanitizeToolCallId("", "strict9")).toMatch(/^[a-zA-Z0-9]{9}$/); - }); + }); + + it.each([ + { + modeLabel: "default", + run: () => sanitizeToolCallId(""), + assert: (value: string) => expect(value).toBe("defaulttoolid"), + }, + { + modeLabel: "strict", + run: () => sanitizeToolCallId("", "strict"), + assert: (value: string) => expect(value).toBe("defaulttoolid"), + }, + { + modeLabel: "strict9", + run: () => sanitizeToolCallId("", "strict9"), + assert: (value: string) => expect(value).toMatch(/^[a-zA-Z0-9]{9}$/), + }, + ])("returns default for empty IDs in $modeLabel mode", ({ run, assert }) => { + assert(run()); }); });