22541 expand breadcrumb route-state helpers for label and dns path reuse

This commit is contained in:
2026-04-09 09:26:19 +01:00
parent 1c06ef1639
commit 59d3ed287c
5 changed files with 120 additions and 30 deletions
+43 -1
View File
@@ -11,7 +11,7 @@ const loadRouteStateModule = () => {
source = source.replace(/export const\s+/g, "const ");
source +=
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref };\n";
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref, resolveSearchBreadcrumbLabel, isDnsRoutePath };\n";
const context = {
module: { exports: {} },
@@ -116,6 +116,48 @@ test("routing/routeState supports DNS route override", async () => {
});
});
test("routing/routeState resolves breadcrumb label using key and route flags", async () => {
const mod = loadRouteStateModule();
const getViewAllLabel = (key) =>
({ myCases: "My Cases", watchedCases: "Watched Cases" })[key] || null;
const fromViewAll = mod.resolveSearchBreadcrumbLabel({
query: { va: "true", key: "myCases" },
getViewAllLabel,
advancedLabel: "Advanced",
addressLabel: "Address",
defaultLabel: "Search"
});
const fromAdvanced = mod.resolveSearchBreadcrumbLabel({
query: { adv: "true" },
getViewAllLabel,
advancedLabel: "Advanced",
addressLabel: "Address",
defaultLabel: "Search"
});
const fromDefault = mod.resolveSearchBreadcrumbLabel({
query: {},
getViewAllLabel,
advancedLabel: "Advanced",
addressLabel: "Address",
defaultLabel: "Search"
});
assert.strictEqual(fromViewAll, "My Cases");
assert.strictEqual(fromAdvanced, "Advanced");
assert.strictEqual(fromDefault, "Search");
});
test("routing/routeState identifies dns and myportal dns route prefixes", async () => {
const mod = loadRouteStateModule();
assert.strictEqual(mod.isDnsRoutePath("/dns"), true);
assert.strictEqual(mod.isDnsRoutePath("/dns/development"), true);
assert.strictEqual(mod.isDnsRoutePath("/myportal/dns"), true);
assert.strictEqual(mod.isDnsRoutePath("/myportal/dns/applications"), true);
assert.strictEqual(mod.isDnsRoutePath("/case/123"), false);
});
const run = async () => {
let passed = 0;