refactor(breadcrumbs): extract callback route renderers into mapped groups

This commit is contained in:
2026-04-09 14:57:47 +01:00
parent 0cd78e6f46
commit 0b905f9374
6 changed files with 159 additions and 50 deletions
+41
View File
@@ -668,6 +668,47 @@ Follow-ups:
- Next larger slice: extract remaining callback-bearing deterministic branches into mapped route groups with callback injection, then update structure guards accordingly.
### CL-22541-V: breadcrumbs larger slice — callback route-group extraction (`/myportal/case/id/[incident]`, `/case`)
date: 2026-04-09
author: Cline
scope: `lib/routing/{breadcrumbRendererFactories,breadcrumbRouteMaps}.js`, `components/breadcrumbs.js`, `tests/phase22/{breadcrumb-route-maps-helper,breadcrumbs-route-map-structure}.test.cjs`
type: change
rationale: Execute the next larger extraction slice by moving callback-bearing breadcrumb branches into a dedicated callback renderer map while preserving `router.back()` behavior through explicit callback injection.
impact: Structural refactor with preserved callback semantics; no intended route/auth/session/API/EN-CY/a11y behavior change.
status: completed
Summary:
- Added `createCallbackRouteRenderers(...)` in `lib/routing/breadcrumbRendererFactories.js` to map:
- `/myportal/case/id/[incident]`
- `/case`
- Introduced explicit callback injection (`onBack`) into grouped factory composition and route renderers, preserving `router.back()` behavior via injected callback.
- Extended `createMappedRouteRendererGroups(...)` return with `callbackRouteRenderersByPath`.
- Updated map builder in `lib/routing/breadcrumbRouteMaps.js` to include callback map in explicit precedence order:
- simple -> link-text -> myportal -> new-appeal -> callback -> case detail -> detail/account.
- Updated `components/breadcrumbs.js`:
- pass `onBack: () => { router.back(); }` into grouped factory composition
- include callback route map in `buildBreadcrumbRendererMaps(...)`
- remove now-redundant inline `isPath("/myportal/case/id/[incident]")` and `isPath("/case")` branches.
- Expanded tests:
- `tests/phase22/breadcrumb-route-maps-helper.test.cjs`
- update grouped map order assertions to seven maps including callback group.
- `tests/phase22/breadcrumbs-route-map-structure.test.cjs`
- assert callback factory export and mapped callback route presence
- assert callback map inclusion in component grouped destructuring and map-order invariant
- assert inline callback branches are removed while `router.back();` remains preserved.
Validation:
- `npx eslint lib/routing/breadcrumbRendererFactories.js lib/routing/breadcrumbRouteMaps.js components/breadcrumbs.js tests/phase22/breadcrumb-route-maps-helper.test.cjs tests/phase22/breadcrumbs-route-map-structure.test.cjs tests/phase22/index.test.cjs` -> pass.
- `node tests/phase22/index.test.cjs` -> pass (combined suite).
Follow-ups:
- Next smaller slice candidate: add a focused helper test for empty-string/whitespace path lookups to assert strict null behavior for non-exact keys.
- Next larger slice candidate: evaluate whether `/newappeal/[appealtypes]` and `/myportal/[appealtypes]` back-link branches can be extracted with explicit callback/setter injection while preserving state-step semantics.
### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction
date: 2026-04-07