fix(breadcrumbs): restore static and viewall label crumb resolution
This commit is contained in:
@@ -94,7 +94,10 @@ const Breadcrumbs = (props) => {
|
|||||||
mySubmittedReps: "Submitted representations"
|
mySubmittedReps: "Submitted representations"
|
||||||
};
|
};
|
||||||
|
|
||||||
return labelsByKey[viewKey] || null;
|
const viewAllLabelResolver = labelsByKey[viewKey];
|
||||||
|
return typeof viewAllLabelResolver === "function"
|
||||||
|
? viewAllLabelResolver()
|
||||||
|
: viewAllLabelResolver || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStaticTextCrumbLabel = (path) => {
|
const getStaticTextCrumbLabel = (path) => {
|
||||||
@@ -116,7 +119,8 @@ const Breadcrumbs = (props) => {
|
|||||||
"/auth/error": () => t("auth:auth-error-signin-error-title")
|
"/auth/error": () => t("auth:auth-error-signin-error-title")
|
||||||
};
|
};
|
||||||
|
|
||||||
return staticTextCrumbByPath[path] || null;
|
const staticTextCrumbResolver = staticTextCrumbByPath[path];
|
||||||
|
return staticTextCrumbResolver ? staticTextCrumbResolver() : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderMyPortalCrumb = () => (
|
const renderMyPortalCrumb = () => (
|
||||||
@@ -175,7 +179,7 @@ const Breadcrumbs = (props) => {
|
|||||||
|
|
||||||
const renderBackCrumb = (
|
const renderBackCrumb = (
|
||||||
onClick,
|
onClick,
|
||||||
listItemClass = "govuk-breadcrumbs__link-item backChevron"
|
listItemClass = "govuk-breadcrumbs__list-item backChevron"
|
||||||
) => renderAnchorCrumb("#", t("common:back-link"), onClick, listItemClass);
|
) => renderAnchorCrumb("#", t("common:back-link"), onClick, listItemClass);
|
||||||
|
|
||||||
const renderDnsCaseReferenceCrumbs = (referenceValue) => (
|
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"
|
"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(
|
assert.strictEqual(
|
||||||
source.includes('isPath("/myportal/advancedsearchresults")'),
|
source.includes('isPath("/myportal/advancedsearchresults")'),
|
||||||
false,
|
false,
|
||||||
|
|||||||
Reference in New Issue
Block a user