22541 extract breadcrumb route-state helper and align phase22 auth locale test

This commit is contained in:
2026-04-09 09:23:22 +01:00
parent 3cea83b7e1
commit 1c06ef1639
7 changed files with 279 additions and 105 deletions
+34
View File
@@ -18,6 +18,40 @@ Follow-ups:
---
### CL-22541: breadcrumb/back-link route-state helper extraction (`va/adv/ads/key`)
date: 2026-04-09
author: Cline
scope: `lib/routing/routeState.js`, `components/breadcrumbs.js`, `components/case/summary.js`, `tests/phase22/{route-state-helper.test.cjs,index.test.cjs}`
type: change
rationale: Action Priority 3 refactor backlog item by extracting duplicated route-state decision logic (`va/adv/ads/key`) into a shared pure helper and reusing it from breadcrumb and case-summary back-link flows to reduce drift/regression risk.
impact: Refactor-only decision-layer consolidation for search/case/myportal navigation; no auth/session/CSP/API contract changes; EN/CY behavior intended unchanged as helper only resolves route targets and preserves existing query forwarding behavior.
status: completed
Summary:
- Created branch from `origin/SIPS-Development`: `22541-breadcrumb-route-state-helper`.
- Added `lib/routing/routeState.js` with:
- `normalizeRouteStateQuery(query)`
- `resolveSearchResultsHref(options)`
- Updated `components/breadcrumbs.js` to consume the shared helper for:
- breadcrumb href resolution (`/myportal/viewall`, advanced/address/default results)
- case-results breadcrumb target on `/case/[ticketnumber]`
- preserving existing label selection behavior via normalized flags.
- Updated `components/case/summary.js` to replace local `buildSearchHref` with shared helper output (`searchHref`), including DNS-route override and no-flag fallback behavior.
- Added table-driven unit coverage in `tests/phase22/route-state-helper.test.cjs` and registered it in `tests/phase22/index.test.cjs`.
Validation:
- `npx eslint lib/routing/routeState.js components/breadcrumbs.js components/case/summary.js tests/phase22/route-state-helper.test.cjs tests/phase22/index.test.cjs` -> pass with 1 pre-existing warning in `components/case/summary.js` (`react-hooks/exhaustive-deps`).
- `node tests/phase22/route-state-helper.test.cjs` -> pass (5/5).
- `node tests/phase22/index.test.cjs` -> fails in existing auth suite (`tests/phase22/auth-redirect-safety.test.cjs`) with `ReferenceError: resolveLocale is not defined` in `pages/api/auth/[...nextauth].js`; unrelated to route-state changes.
Follow-ups:
- If needed, triage/fix the existing phase22 auth redirect test harness failure separately to restore full combined suite execution.
- Expand helper adoption in future slices to other navigation decision call sites if additional duplication emerges.
### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction
date: 2026-04-07