From b2da21abe11ac43a4cc24b233bd52ce10995e4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=A1=89?= <161032298+014-code@users.noreply.github.com> Date: Sun, 11 Oct 2026 19:58:55 +0800 Subject: [PATCH] test(evidence): cover workflow question whitespace normalization (#1739) --- src/application/WorkflowEvidence.test.ts | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/application/WorkflowEvidence.test.ts b/src/application/WorkflowEvidence.test.ts index 5ca63d15e9..dab61a79c1 100644 --- a/src/application/WorkflowEvidence.test.ts +++ b/src/application/WorkflowEvidence.test.ts @@ -46,6 +46,63 @@ describe("workflow residual question retention", () => { ]); }); + it.each([ + ["spaces", " Which boundary? "], + ["line feed and tab", "\nWhich boundary?\t"], + ["byte order mark", "\uFEFFWhich boundary?\uFEFF"], + ])( + "normalizes edge whitespace from %s without changing workflow Evidence", + (_, question) => { + const records = new InvestigationRecords(); + const result = { residual_unknowns: [question] }; + const evidence = createWorkflowEvidence({ + target: undefined, + operation: "inspect_native_api", + parameters: {}, + result, + upstreamProfile: undefined, + }); + + expect(records.recordEvidence(evidence).ok).toBe(true); + expect( + recordWorkflowUnknowns({ + name: "inspect_native_api", + result, + evidenceId: evidence.evidence_id, + recordUnknown: (unknown) => records.recordUnknown(unknown), + }).ok, + ).toBe(true); + expect(records.listUnknowns()).toMatchObject([ + { question: "Which boundary?" }, + ]); + expect(evidence.normalized_result).toEqual(result); + }, + ); + + it("rejects questions that are empty after whitespace normalization", () => { + const records = new InvestigationRecords(); + const result = { residual_unknowns: [" \n\t "] }; + const evidence = createWorkflowEvidence({ + target: undefined, + operation: "inspect_native_api", + parameters: {}, + result, + upstreamProfile: undefined, + }); + + expect(records.recordEvidence(evidence).ok).toBe(true); + expect( + recordWorkflowUnknowns({ + name: "inspect_native_api", + result, + evidenceId: evidence.evidence_id, + recordUnknown: (unknown) => records.recordUnknown(unknown), + }).ok, + ).toBe(false); + expect(records.listUnknowns()).toEqual([]); + expect(evidence.normalized_result).toEqual(result); + }); + it("preserves registry failures rather than presenting a completed workflow", () => { const error = new UnknownRegistryError("limit"); expect(