Skip to content

Commit

Permalink
Revert "Add editable headline and description for medium-promo-block" (
Browse files Browse the repository at this point in the history
…#2220)

Revert "Add editable headline and description for medium-promo-block (#2217)"

This reverts commit 9e56a21.
  • Loading branch information
Gripholder authored Sep 17, 2024
1 parent 9e56a21 commit 647bfc7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 49 deletions.
16 changes: 3 additions & 13 deletions blocks/medium-promo-block/features/medium-promo/default.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BLOCK_CLASS_NAME = "b-medium-promo";
const MediumPromo = ({ customFields }) => {
const { registerSuccessEvent } = useComponentContext();
const { arcSite, isAdmin } = useFusionContext();
const { editableContent, searchableField } = useEditableContent();
const { searchableField } = useEditableContent();
const {
dateLocalization: { language, timeZone, dateTimeFormat } = {
language: "en",
Expand Down Expand Up @@ -163,13 +163,7 @@ const MediumPromo = ({ customFields }) => {

const hasAuthors = showByline ? content?.credits?.by && content?.credits?.by?.length : null;
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 contentDate = content?.display_date;
Expand Down Expand Up @@ -243,7 +237,7 @@ const MediumPromo = ({ customFields }) => {
) : null}

{contentHeading ? (
<Heading suppressContentEditableWarning {...editableHeading}>
<Heading>
<Conditional
component={Link}
condition={contentUrl}
Expand All @@ -255,11 +249,7 @@ const MediumPromo = ({ customFields }) => {
</Heading>
) : null}

{showDescription ? (
<Paragraph suppressContentEditableWarning {...editableDescription}>
{contentDescription}
</Paragraph>
) : null}
{showDescription ? <Paragraph>{contentDescription}</Paragraph> : null}
{hasAuthors || showDate ? (
<Attribution>
<Join separator={Separator}>
Expand Down
49 changes: 13 additions & 36 deletions blocks/medium-promo-block/features/medium-promo/default.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { useContent } from "fusion:content";

Expand Down Expand Up @@ -28,18 +27,18 @@ describe("the medium promo feature", () => {
jest.clearAllMocks();
});

it("should not render if lazyLoad on the server and not in the admin", () => {
it("should return null if lazyLoad on the server and not in the admin", () => {
const config = {
lazyLoad: true,
};
render(<MediumPromo customFields={config} />);
expect(screen.queryByRole("article")).not.toBeInTheDocument();
const { container } = render(<MediumPromo customFields={config} />);
expect(container.firstChild).toBe(null);
});

it("should not render if none of the show... flags are true", () => {
it("should return null if none of the show... flags are true", () => {
const config = {};
render(<MediumPromo customFields={config} />);
expect(screen.queryByRole("article")).not.toBeInTheDocument();
const { container } = render(<MediumPromo customFields={config} />);
expect(container.firstChild).toBeNull();
});

it("should display a headline if showHeadline is true", () => {
Expand All @@ -48,27 +47,7 @@ describe("the medium promo feature", () => {
};
render(<MediumPromo customFields={config} />);

expect(screen.getByRole("heading", { name: mockData.headlines.basic })).not.toBeNull();
});

it("should headline be an editable field", () => {
const config = {
showHeadline: true,
};
render(<MediumPromo customFields={config} />);

expect(screen.queryByRole("heading", { name: mockData.headlines.basic })).toHaveAttribute(
"contenteditable",
);
});

it("should description be an editable field", () => {
const config = {
showDescription: true,
};
render(<MediumPromo customFields={config} />);

expect(screen.queryByText(mockData.description.basic)).toHaveAttribute("contenteditable");
expect(screen.queryByRole("heading", { name: config.headline })).not.toBeNull();
});

it("should display an image if showImage is true", () => {
Expand All @@ -78,7 +57,7 @@ describe("the medium promo feature", () => {
showImage: true,
};
render(<MediumPromo customFields={config} />);
expect(screen.getByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
});

it("should make a blank call to the signing-service if the image is from PhotoCenter and has an Auth value", () => {
Expand Down Expand Up @@ -129,7 +108,7 @@ describe("the medium promo feature", () => {
showImage: true,
};
render(<MediumPromo customFields={config} />);
expect(screen.getByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
});

it("should display a description if showDescription is true", () => {
Expand All @@ -138,19 +117,17 @@ describe("the medium promo feature", () => {
};
render(<MediumPromo customFields={config} />);
expect(
screen.getByText("Why does August seem hotter? Maybe it comes from weariness."),
screen.queryByText("Why does August seem hotter? Maybe it comes from weariness."),
).not.toBeNull();
});

it("should display a byline if showByline is true", () => {
const config = {
showByline: true,
};
render(<MediumPromo customFields={config} />);
const { getByText } = render(<MediumPromo customFields={config} />);
expect(
screen.getByText(
"global.by-text Example Author1, Example Author2, global.and-text Example Author3",
),
getByText("global.by-text Example Author1, Example Author2, global.and-text Example Author3"),
).not.toBeNull();
});

Expand All @@ -159,6 +136,6 @@ describe("the medium promo feature", () => {
showDate: true,
};
render(<MediumPromo customFields={config} />);
expect(screen.getByText("January 30, 2020", { exact: false })).not.toBeNull();
expect(screen.queryByText("January 30, 2020", { exact: false })).not.toBeNull();
});
});

0 comments on commit 647bfc7

Please sign in to comment.