From 7a60e64a8429e0f0b87c15d234758dfa0a38e1f2 Mon Sep 17 00:00:00 2001 From: robbond Date: Thu, 9 Apr 2026 15:06:41 +0100 Subject: [PATCH] test(breadcrumbs): assert strict null on non-exact route map lookups --- memory-bank/change-log.md | 30 +++++++++++ .../breadcrumb-route-maps-helper.test.cjs | 50 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index 124e7eec..f303f84e 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -754,6 +754,36 @@ Follow-ups: - Next smaller slice candidate: add focused helper test for strict null behavior on empty-string/whitespace/non-exact path keys. - Next larger slice candidate: evaluate extractability of `/myportal/representation` back-link states via explicit callback injection, only if questionnaire/submit side-effects remain parity-safe and readable. +### CL-22541-X: breadcrumbs smaller slice — strict null lookup guard coverage (empty/whitespace/non-exact paths) + +date: 2026-04-09 +author: Cline +scope: `tests/phase22/breadcrumb-route-maps-helper.test.cjs` +type: change +rationale: Execute the queued smaller follow-up slice by hardening helper regression coverage for strict exact-match route lookup semantics. +impact: Test-only hardening; no runtime route/auth/session/API/EN-CY/a11y behavior change. +status: completed + +Summary: + +- Added focused helper-level test case in `tests/phase22/breadcrumb-route-maps-helper.test.cjs`: + - `resolveMappedRouteRenderer returns null for empty, whitespace, and non-exact path variants` +- New assertions verify resolver returns `null` for: + - empty path (`""`) + - whitespace-only path (`" "`) + - trailing/leading whitespace variants (`"/known "`, `" /known"`) + - case-variant non-exact key (`"/KNOWN"`) +- Confirms route-map resolver remains strict/exact and does not auto-trim or case-normalize lookup keys. + +Validation: + +- `npx eslint tests/phase22/breadcrumb-route-maps-helper.test.cjs tests/phase22/index.test.cjs` -> pass. +- `node tests/phase22/index.test.cjs` -> pass (combined suite; breadcrumb-route-maps-helper 6/6). + +Follow-ups: + +- Next larger slice candidate remains `/myportal/representation` callback/state branch extraction only if side-effects can be injected/parity-preserved cleanly. + ### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction date: 2026-04-07 diff --git a/tests/phase22/breadcrumb-route-maps-helper.test.cjs b/tests/phase22/breadcrumb-route-maps-helper.test.cjs index 3dec5147..30c627bf 100644 --- a/tests/phase22/breadcrumb-route-maps-helper.test.cjs +++ b/tests/phase22/breadcrumb-route-maps-helper.test.cjs @@ -215,6 +215,56 @@ test("resolveMappedRouteRenderer returns null for unmapped path", () => { ); }); +test("resolveMappedRouteRenderer returns null for empty, whitespace, and non-exact path variants", () => { + const { buildBreadcrumbRendererMaps, resolveMappedRouteRenderer } = + loadHelpers(); + + const knownRenderer = () => "known"; + + const maps = buildBreadcrumbRendererMaps({ + simpleRouteRenderersByPath: { + "/known": knownRenderer + }, + simpleLinkTextPairRenderersByPath: {}, + simpleMyPortalRouteRenderersByPath: {}, + newAppealRouteRenderersByPath: {}, + callbackRouteRenderersByPath: {}, + stepBackRouteRenderersByPath: {}, + caseDetailRouteRenderersByPath: {}, + detailAndAccountRouteRenderersByPath: {} + }); + + assert.strictEqual( + resolveMappedRouteRenderer("", maps), + null, + "Expected null for empty path lookup when no empty key is mapped" + ); + + assert.strictEqual( + resolveMappedRouteRenderer(" ", maps), + null, + "Expected null for whitespace-only path lookup" + ); + + assert.strictEqual( + resolveMappedRouteRenderer("/known ", maps), + null, + "Expected null for non-exact path variant with trailing whitespace" + ); + + assert.strictEqual( + resolveMappedRouteRenderer(" /known", maps), + null, + "Expected null for non-exact path variant with leading whitespace" + ); + + assert.strictEqual( + resolveMappedRouteRenderer("/KNOWN", maps), + null, + "Expected null for non-exact case-variant path lookup" + ); +}); + test("resolveMappedRouteRenderer skips invalid map entries and non-function renderer values", () => { const { buildBreadcrumbRendererMaps, resolveMappedRouteRenderer } = loadHelpers();