fix(breadcrumbs): restore static and viewall label crumb resolution
This commit is contained in:
@@ -94,7 +94,10 @@ const Breadcrumbs = (props) => {
|
||||
mySubmittedReps: "Submitted representations"
|
||||
};
|
||||
|
||||
return labelsByKey[viewKey] || null;
|
||||
const viewAllLabelResolver = labelsByKey[viewKey];
|
||||
return typeof viewAllLabelResolver === "function"
|
||||
? viewAllLabelResolver()
|
||||
: viewAllLabelResolver || null;
|
||||
};
|
||||
|
||||
const getStaticTextCrumbLabel = (path) => {
|
||||
@@ -116,7 +119,8 @@ const Breadcrumbs = (props) => {
|
||||
"/auth/error": () => t("auth:auth-error-signin-error-title")
|
||||
};
|
||||
|
||||
return staticTextCrumbByPath[path] || null;
|
||||
const staticTextCrumbResolver = staticTextCrumbByPath[path];
|
||||
return staticTextCrumbResolver ? staticTextCrumbResolver() : null;
|
||||
};
|
||||
|
||||
const renderMyPortalCrumb = () => (
|
||||
@@ -175,7 +179,7 @@ const Breadcrumbs = (props) => {
|
||||
|
||||
const renderBackCrumb = (
|
||||
onClick,
|
||||
listItemClass = "govuk-breadcrumbs__link-item backChevron"
|
||||
listItemClass = "govuk-breadcrumbs__list-item backChevron"
|
||||
) => renderAnchorCrumb("#", t("common:back-link"), onClick, listItemClass);
|
||||
|
||||
const renderDnsCaseReferenceCrumbs = (referenceValue) => (
|
||||
|
||||
@@ -284,6 +284,34 @@ test("breadcrumbs/component composes mapped routes via imported factories and sh
|
||||
"Expected breadcrumb JSX to use single mapped route render invocation"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
source.includes("const viewAllLabelResolver = labelsByKey[viewKey];"),
|
||||
true,
|
||||
"Expected view-all label lookup to resolve callable/non-callable map entries"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
source.includes('return typeof viewAllLabelResolver === "function"'),
|
||||
true,
|
||||
"Expected view-all label resolver to invoke function-backed labels"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
source.includes(
|
||||
"const staticTextCrumbResolver = staticTextCrumbByPath[path];"
|
||||
),
|
||||
true,
|
||||
"Expected static text breadcrumb path lookup to resolve a callable label renderer"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
source.includes(
|
||||
"return staticTextCrumbResolver ? staticTextCrumbResolver() : null;"
|
||||
),
|
||||
true,
|
||||
"Expected static text breadcrumb resolver to invoke mapped label function"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
source.includes('isPath("/myportal/advancedsearchresults")'),
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user