From e058eb696afb6f5ee75dd6de5256cd7f0a7bad62 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 8 Jun 2026 14:57:38 +0000 Subject: [PATCH] fix(frontend/test): add missing escapeHtmlAttr stub to utils mock plans-range-validation.test.ts used a closed mock factory for ../utils that listed every util function explicitly but omitted escapeHtmlAttr, which was added to utils.ts after the test was written. The missing stub caused a "not a function" TypeError whenever plans.ts called escapeHtmlAttr during renderPlannedPurchaseRow / renderPlanCard, making the entire plans-range-validation suite fail in CI. Added the stub with a faithful HTML-attribute escape implementation (mirrors the real utils.ts implementation) so the closed factory remains exhaustive. Closes #1115 --- frontend/src/__tests__/plans-range-validation.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/__tests__/plans-range-validation.test.ts b/frontend/src/__tests__/plans-range-validation.test.ts index 6e1bb0b6f..2eb66f9de 100644 --- a/frontend/src/__tests__/plans-range-validation.test.ts +++ b/frontend/src/__tests__/plans-range-validation.test.ts @@ -76,6 +76,15 @@ jest.mock('../utils', () => ({ formatRampSchedule: jest.fn((v) => v ?? ''), getStatusBadge: jest.fn(() => ({ class: 'active', label: 'Active' })), escapeHtml: jest.fn((s) => s ?? ''), + escapeHtmlAttr: jest.fn((str: string | null | undefined) => { + if (str == null) return ''; + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + }), formatCurrency: jest.fn((v) => `$${v}`), populateAccountFilter: jest.fn(() => Promise.resolve()), }));