From ae9afc9e08abb87a5f753ea96aadafb4d9334e65 Mon Sep 17 00:00:00 2001 From: Gripholder Date: Tue, 15 Oct 2024 05:22:02 -0700 Subject: [PATCH] Add editable headline, description and overline for extra-large-promo-block --- .../features/extra-large-promo/default.jsx | 37 +++++++++++++++-- .../extra-large-promo/default.test.jsx | 40 +++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx b/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx index 1d683f78d3..9cc4a5d53d 100644 --- a/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx +++ b/blocks/extra-large-promo-block/features/extra-large-promo/default.jsx @@ -39,9 +39,12 @@ const getType = (type, content) => (content?.type === type ? content : undefined export const ExtraLargePromoPresentation = ({ hasOverline, + editableOverline, contentHeading, + editableHeading, showImage, contentDescription, + editableDescription, hasDate, shouldLazyLoad, overlineUrl, @@ -61,7 +64,11 @@ export const ExtraLargePromoPresentation = ({ hasOverline || contentHeading || showImage || contentDescription || contentAuthors || hasDate ? (
- {hasOverline ? {overlineText} : null} + {hasOverline ? ( + + {overlineText} + + ) : null} {contentHeading || showImage || contentDescription || @@ -71,7 +78,7 @@ export const ExtraLargePromoPresentation = ({ {contentHeading ? ( - + {contentHeading} @@ -112,7 +119,11 @@ export const ExtraLargePromoPresentation = ({ )} ) : null} - {contentDescription ? {contentDescription} : null} + {contentDescription ? ( + + {contentDescription} + + ) : null} {contentAuthors || hasDate ? ( @@ -136,7 +147,7 @@ export const ExtraLargePromoPresentation = ({ const ExtraLargePromo = ({ customFields }) => { const { arcSite, isAdmin } = useFusionContext(); - const { searchableField } = useEditableContent(); + const { editableContent, searchableField } = useEditableContent(); const { dateLocalization: { language, timeZone, dateTimeFormat } = { language: "en", @@ -290,17 +301,32 @@ const ExtraLargePromo = ({ customFields }) => { // Default to websites object data let [overlineText, overlineUrl] = [sectionText, sectionUrl]; + let editableOverline = content?.websites?.[arcSite]?.website_section?.name + ? editableContent(content, `websites.${[arcSite]}.website_section.name`) + : {}; if (content?.owner?.sponsored) { overlineText = content?.label?.basic?.text || phrases.t("global.sponsored-content"); overlineUrl = null; + editableOverline = content?.label?.basic?.text + ? editableContent(content, "label.basic.text") + : {}; } else if (shouldUseLabel) { [overlineText, overlineUrl] = [labelText, labelUrl]; + editableOverline = content?.label?.basic?.text + ? editableContent(content, "label.basic.text") + : {}; } const hasOverline = showOverline && overlineText; const contentDescription = showDescription ? content?.description?.basic : null; + const editableDescription = content?.description + ? editableContent(content, "description.basic") + : {}; const contentHeading = showHeadline ? content?.headlines?.basic : null; + const editableHeading = content?.headlines?.basic + ? editableContent(content, "headlines.basic") + : {}; const contentUrl = content?.websites?.[arcSite]?.website_url; const embedMarkup = playVideoInPlace && getVideoFromANS(content); const contentAuthors = @@ -351,9 +377,12 @@ const ExtraLargePromo = ({ customFields }) => { return ( { expect(screen.queryByRole("link", { name: "Premium" })).not.toBeNull(); }); + it("should overline text be an editable field", () => { + const arcSite = "dagen"; // using default website + + const config = { + showOverline: true, + }; + render(); + + let overline = mockData?.websites[arcSite]?.website_section?.name; + + if (!!mockData.owner?.sponsored) { + overline = mockData.label.basic.text; + } else if (!!mockData?.label?.basic?.display) { + overline = mockData?.label?.basic?.text; + } + + overline ? expect(screen.getByText(overline)).toHaveAttribute("contenteditable", "true") : null; // Bypass test if overline value doesn't exist (to be editable) + }); + it("should return a headline if showHeadline is true", () => { const config = { showHeadline: true, @@ -53,6 +73,26 @@ describe("the extra large promo feature", () => { expect(screen.queryByRole("heading", { name: config.headline })).not.toBeNull(); }); + it("should headline be an editable field", () => { + const config = { + showHeadline: true, + }; + render(); + + expect(screen.queryByRole("heading", { name: mockData.headlines.basic })).toHaveAttribute( + "contenteditable", + ); + }); + + it("should description be an editable field", () => { + const config = { + showDescription: true, + }; + render(); + + expect(screen.queryByText(mockData.description.basic)).toHaveAttribute("contenteditable"); + }); + it("should return a image if showImage is true", () => { const config = { imageOverrideURL: "#",