22541 add bundled case breadcrumb state resolver

This commit is contained in:
2026-04-09 09:28:54 +01:00
parent 59d3ed287c
commit f447aa19ea
4 changed files with 97 additions and 26 deletions
+27 -1
View File
@@ -11,7 +11,7 @@ const loadRouteStateModule = () => {
source = source.replace(/export const\s+/g, "const ");
source +=
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref, resolveSearchBreadcrumbLabel, isDnsRoutePath };\n";
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref, resolveSearchBreadcrumbLabel, isDnsRoutePath, resolveCaseBreadcrumbState };\n";
const context = {
module: { exports: {} },
@@ -158,6 +158,32 @@ test("routing/routeState identifies dns and myportal dns route prefixes", async
assert.strictEqual(mod.isDnsRoutePath("/case/123"), false);
});
test("routing/routeState resolves bundled case breadcrumb state", async () => {
const mod = loadRouteStateModule();
const getViewAllLabel = (key) => ({ myCases: "My Cases" })[key] || null;
const state = mod.resolveCaseBreadcrumbState({
query: { va: "true", key: "myCases" },
hasSession: true,
getViewAllLabel,
advancedLabel: "Advanced",
addressLabel: "Address",
defaultLabel: "Search"
});
assert.deepStrictEqual(JSON.parse(JSON.stringify(state)), {
breadcrumbHref: {
pathname: "/myportal/viewall",
query: { key: "myCases" }
},
caseResultsHref: {
pathname: "/myportal/searchresults",
query: { va: "true", key: "myCases" }
},
breadcrumbLabel: "My Cases"
});
});
const run = async () => {
let passed = 0;