refactor(breadcrumbs): extract representation route-state renderer group

This commit is contained in:
2026-04-09 15:16:01 +01:00
parent 7a60e64a84
commit d3f4dda8af
6 changed files with 160 additions and 38 deletions
@@ -66,6 +66,9 @@ test("buildBreadcrumbRendererMaps returns grouped maps in explicit precedence or
const stepBackRouteRenderersByPath = {
"/iota": () => "iota"
};
const representationRouteRenderersByPath = {
"/kappa": () => "kappa"
};
const caseDetailRouteRenderersByPath = {
"/delta": () => "delta"
};
@@ -80,12 +83,13 @@ test("buildBreadcrumbRendererMaps returns grouped maps in explicit precedence or
newAppealRouteRenderersByPath,
callbackRouteRenderersByPath,
stepBackRouteRenderersByPath,
representationRouteRenderersByPath,
caseDetailRouteRenderersByPath,
detailAndAccountRouteRenderersByPath
});
assert.ok(Array.isArray(result), "Expected grouped maps array");
assert.strictEqual(result.length, 8, "Expected eight grouped route maps");
assert.strictEqual(result.length, 9, "Expected nine grouped route maps");
assert.strictEqual(
result[0],
simpleRouteRenderersByPath,
@@ -118,13 +122,18 @@ test("buildBreadcrumbRendererMaps returns grouped maps in explicit precedence or
);
assert.strictEqual(
result[6],
caseDetailRouteRenderersByPath,
"Expected case detail route renderers seventh"
representationRouteRenderersByPath,
"Expected representation route renderers seventh"
);
assert.strictEqual(
result[7],
caseDetailRouteRenderersByPath,
"Expected case detail route renderers eighth"
);
assert.strictEqual(
result[8],
detailAndAccountRouteRenderersByPath,
"Expected detail and account route renderers eighth"
"Expected detail and account route renderers ninth"
);
});
@@ -146,6 +155,7 @@ test("resolveMappedRouteRenderer returns renderer from first matching grouped ma
newAppealRouteRenderersByPath: {},
callbackRouteRenderersByPath: {},
stepBackRouteRenderersByPath: {},
representationRouteRenderersByPath: {},
caseDetailRouteRenderersByPath: {},
detailAndAccountRouteRenderersByPath: {}
});
@@ -175,6 +185,7 @@ test("resolveMappedRouteRenderer returns renderer from later grouped map when ea
caseDetailRouteRenderersByPath: {},
callbackRouteRenderersByPath: {},
stepBackRouteRenderersByPath: {},
representationRouteRenderersByPath: {},
detailAndAccountRouteRenderersByPath: {
"/account/personaldetails": detailRenderer
}
@@ -202,6 +213,7 @@ test("resolveMappedRouteRenderer returns null for unmapped path", () => {
newAppealRouteRenderersByPath: {},
callbackRouteRenderersByPath: {},
stepBackRouteRenderersByPath: {},
representationRouteRenderersByPath: {},
caseDetailRouteRenderersByPath: {},
detailAndAccountRouteRenderersByPath: {}
});
@@ -230,6 +242,7 @@ test("resolveMappedRouteRenderer returns null for empty, whitespace, and non-exa
newAppealRouteRenderersByPath: {},
callbackRouteRenderersByPath: {},
stepBackRouteRenderersByPath: {},
representationRouteRenderersByPath: {},
caseDetailRouteRenderersByPath: {},
detailAndAccountRouteRenderersByPath: {}
});
@@ -282,6 +295,7 @@ test("resolveMappedRouteRenderer skips invalid map entries and non-function rend
newAppealRouteRenderersByPath: undefined,
callbackRouteRenderersByPath: {},
stepBackRouteRenderersByPath: {},
representationRouteRenderersByPath: {},
caseDetailRouteRenderersByPath: {},
detailAndAccountRouteRenderersByPath: {}
});
@@ -54,6 +54,12 @@ test("breadcrumbs/factory module includes expected mapped route definitions", as
"Expected step-back route renderer factory export"
);
assert.strictEqual(
source.includes("export const createRepresentationRouteRenderers ="),
true,
"Expected representation route renderer factory export"
);
assert.strictEqual(
source.includes("export const createCaseDetailRouteRenderers ="),
true,
@@ -132,6 +138,12 @@ test("breadcrumbs/factory module includes expected mapped route definitions", as
"Expected /myportal/[appealtypes] to be mapped in createStepBackRouteRenderers"
);
assert.strictEqual(
source.includes('"/myportal/representation": () => ('),
true,
"Expected /myportal/representation to be mapped in createRepresentationRouteRenderers"
);
assert.strictEqual(
source.includes('"/case/[ticketnumber]": () =>'),
true,
@@ -221,7 +233,7 @@ test("breadcrumbs/component composes mapped routes via imported factories and sh
);
assert.strictEqual(
/const\s+\{[\s\S]*simpleRouteRenderersByPath[\s\S]*newAppealRouteRenderersByPath[\s\S]*callbackRouteRenderersByPath[\s\S]*stepBackRouteRenderersByPath[\s\S]*detailAndAccountRouteRenderersByPath[\s\S]*\}\s*=\s*createMappedRouteRendererGroups\s*\(/.test(
/const\s+\{[\s\S]*simpleRouteRenderersByPath[\s\S]*newAppealRouteRenderersByPath[\s\S]*callbackRouteRenderersByPath[\s\S]*stepBackRouteRenderersByPath[\s\S]*representationRouteRenderersByPath[\s\S]*detailAndAccountRouteRenderersByPath[\s\S]*\}\s*=\s*createMappedRouteRendererGroups\s*\(/.test(
source
),
true,
@@ -320,6 +332,12 @@ test("breadcrumbs/component composes mapped routes via imported factories and sh
"Expected /myportal/[appealtypes] explicit branch to be removed after step-back mapping"
);
assert.strictEqual(
source.includes('isPath("/myportal/representation")'),
false,
"Expected /myportal/representation explicit branch to be removed after representation mapping"
);
assert.strictEqual(
source.includes('isPath("/myportal/case/[ticketnumber]")'),
false,
@@ -405,6 +423,9 @@ test("breadcrumbs/map builder preserves route map ordering", async () => {
const stepBackOrderIndex = mapBuilderSlice.indexOf(
"stepBackRouteRenderersByPath"
);
const representationOrderIndex = mapBuilderSlice.indexOf(
"representationRouteRenderersByPath"
);
const caseDetailOrderIndex = mapBuilderSlice.indexOf(
"caseDetailRouteRenderersByPath"
);
@@ -419,10 +440,11 @@ test("breadcrumbs/map builder preserves route map ordering", async () => {
newAppealOrderIndex > simpleMyPortalOrderIndex &&
callbackOrderIndex > newAppealOrderIndex &&
stepBackOrderIndex > callbackOrderIndex &&
caseDetailOrderIndex > stepBackOrderIndex &&
representationOrderIndex > stepBackOrderIndex &&
caseDetailOrderIndex > representationOrderIndex &&
detailAndAccountOrderIndex > caseDetailOrderIndex,
true,
"Expected map builder call to preserve explicit route-map ordering (simple -> link-text -> myportal -> new-appeal -> callback -> step-back -> case detail -> detail/account)"
"Expected map builder call to preserve explicit route-map ordering (simple -> link-text -> myportal -> new-appeal -> callback -> step-back -> representation -> case detail -> detail/account)"
);
});