Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comparing 2.5.1 to 2.5.2 (DO NOT MERGE) #2288

Open
wants to merge 8 commits into
base: arc-themes-release-version-2.5.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/stylelint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ jobs:
filter_mode: "diff_context"
stylelint_config: ".stylelintrc.json"
stylelint_input: "**/*.scss"
format: "json"
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"useTabs": true,
"printWidth": 100,
experimentalTernaries: false,
}
"experimentalTernaries": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -61,7 +64,11 @@ export const ExtraLargePromoPresentation = ({
hasOverline || contentHeading || showImage || contentDescription || contentAuthors || hasDate ? (
<LazyLoad enabled={shouldLazyLoad}>
<article className={BLOCK_CLASS_NAME}>
{hasOverline ? <Overline href={overlineUrl}>{overlineText}</Overline> : null}
{hasOverline ? (
<Overline href={overlineUrl} suppressContentEditableWarning {...editableOverline}>
{overlineText}
</Overline>
) : null}
{contentHeading ||
showImage ||
contentDescription ||
Expand All @@ -71,7 +78,7 @@ export const ExtraLargePromoPresentation = ({
<Stack>
{contentHeading ? (
<HeadingSection>
<Heading>
<Heading suppressContentEditableWarning {...editableHeading}>
<Conditional component={Link} condition={contentUrl} href={contentUrl}>
{contentHeading}
</Conditional>
Expand Down Expand Up @@ -112,7 +119,11 @@ export const ExtraLargePromoPresentation = ({
)}
</MediaItem>
) : null}
{contentDescription ? <Paragraph>{contentDescription}</Paragraph> : null}
{contentDescription ? (
<Paragraph suppressContentEditableWarning {...editableDescription}>
{contentDescription}
</Paragraph>
) : null}
{contentAuthors || hasDate ? (
<Attribution>
<Join separator={Separator}>
Expand All @@ -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",
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -351,9 +377,12 @@ const ExtraLargePromo = ({ customFields }) => {
return (
<ExtraLargePromoPresentation
hasOverline={hasOverline}
editableOverline={editableOverline}
contentHeading={contentHeading}
editableHeading={editableHeading}
showImage={showImage}
contentDescription={contentDescription}
editableDescription={editableDescription}
hasDate={hasDate}
shouldLazyLoad={shouldLazyLoad}
overlineUrl={overlineUrl}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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 @@ -27,30 +28,71 @@ describe("the extra large promo feature", () => {
const config = {
lazyLoad: true,
};
const { container } = render(<ExtraLargePromo customFields={config} />);
expect(container.firstChild).toBe(null);
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByTestId("extra-large-promo")).toBeNull();
});

it("should return null if no show flag is true", () => {
const config = {};
const { container } = render(<ExtraLargePromo customFields={config} />);
expect(container.firstChild).toBeNull();
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByTestId("extra-large-promo")).toBeNull();
});

it("should return an overline if showOverline is true", () => {
const config = {
showOverline: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByRole("link", { name: "Premium" })).not.toBeNull();
expect(screen.getByRole("link", { name: "Premium" })).not.toBeNull();
});

it("should overline text be an editable field", () => {
const arcSite = "dagen"; // using default website

const config = {
showOverline: true,
};
render(<ExtraLargePromo customFields={config} />);

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;
}

if (overline) {
expect(screen.getByText(overline)).toHaveAttribute("contenteditable", "true");
}
});

it("should return a headline if showHeadline is true", () => {
const config = {
showHeadline: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByRole("heading", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("heading", { name: config.headline })).not.toBeNull();
});

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

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

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

expect(screen.getByText(mockData.description.basic)).toHaveAttribute("contenteditable");
});

it("should return a image if showImage is true", () => {
Expand All @@ -65,7 +107,7 @@ describe("the extra large promo feature", () => {
}),
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("img", { name: config.headline })).not.toBeNull();
});

it("should return a fallback image if showImage is true and imageUrl is not valid", () => {
Expand All @@ -74,7 +116,7 @@ describe("the extra large promo feature", () => {
showImage: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("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 @@ -125,26 +167,28 @@ describe("the extra large promo feature", () => {
};
render(<ExtraLargePromo customFields={config} />);
expect(
screen.queryByText("Why does August seem hotter? Maybe it comes from weariness."),
screen.getByText("Why does August seem hotter? Maybe it comes from weariness."),
).not.toBeNull();
});

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

it("should return a byline if showDate is true", () => {
const config = {
showDate: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByText("January 30, 2020", { exact: false })).not.toBeNull();
expect(screen.getByText("January 30, 2020", { exact: false })).not.toBeNull();
});

it("should returned a sponsored overline if it's sponsored content", () => {
Expand All @@ -153,7 +197,7 @@ describe("the extra large promo feature", () => {
showOverline: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByText("Sponsored")).not.toBeNull();
expect(screen.getByText("Sponsored")).not.toBeNull();
});

it("should return a video if playVideoInPlace is true and video content available", () => {
Expand All @@ -163,6 +207,6 @@ describe("the extra large promo feature", () => {
showImage: true,
};
render(<ExtraLargePromo customFields={config} />);
expect(screen.queryByText("video embed")).not.toBeNull();
expect(screen.getByText("video embed")).not.toBeNull();
});
});
6 changes: 3 additions & 3 deletions blocks/gallery-block/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ The Gallery block shows a carousel with images and captions. It is used to displ

This is set in the `blocks.json`.

| **Prop** | **Required** | **Type** | **Description** |
| --------------------- | ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| **galleryCubeClicks** | no | integer | If present sets the interval at which ads will be shown between gallery images. The click count do not take into account direction. |
| **Prop** | **Required** | **Type** | **Description** |
| --------------------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **galleryCubeClicks** | no | integer | If present sets the interval at which ads will be shown between gallery images. The click count does not take into account direction. |

## ANS Schema

Expand Down
2 changes: 1 addition & 1 deletion blocks/gallery-block/themes/news.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"overflow": "auto",
"components": {
"image": {
"block-size": "auto",
"block-size": "100%",
"max-block-size": "100%",
"max-inline-size": "100%",
"object-fit": "contain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const FormPasswordConfirm = ({
}) => {
const [password, setPassword] = useState("");

const escapeForHtmlPattern = (value) =>{
const specialChars = /[.*+?^${}()|[\]\\]/g;
const newValue = value.replace(specialChars, '\\$&');
return newValue;
};

const fieldParameters = {
...(autoComplete ? { autoComplete } : {}),
...(placeholder ? { placeholder } : {}),
Expand Down Expand Up @@ -55,7 +61,7 @@ const FormPasswordConfirm = ({
name={`${name}-confirmation`}
required
type="password"
validationPattern={`^${password}$`}
validationPattern={escapeForHtmlPattern(password)}
className={className}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function AppleSignIn({ customButtons, socialSignOnIn, className, oidcClients = [
const phrases = usePhrases();
const { Identity } = useIdentity();

const appleOIDCClient = oidcClients.find((oidcClient) => {
const appleOIDCClient = oidcClients && oidcClients.find((oidcClient) => {
const parsedClientId = oidcClient.clientId.split(';')[0];

return oidcClient.protocol === 'Apple' && parsedClientId === appleClientId;
Expand Down
9 changes: 7 additions & 2 deletions blocks/identity-block/utils/validate-password-pattern.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const SPECIAL_CHARACTERS_ALLOWED = "@$!%*?&";
const SPECIAL_CHARACTERS_ALLOWED =
".@$!%*+?&#<=>^:;,-" +
"\\/\\(\\)\\{\\}\\[\\]\\|\\`\\\\" +
"~_" +
'"' +
"'";

// positive lookahead (?= )
// with a non-capturing group within (?: )
Expand All @@ -12,7 +17,7 @@ const validatePasswordPattern = (
pwMinLength,
pwPwNumbers,
pwSpecialCharacters,
pwUppercase
pwUppercase,
) =>
`(?=(?:.*[a-z]){${pwLowercase},})(?=(?:.*[A-Z]){${pwUppercase},})(?=(?:.*\\d){${pwPwNumbers},})(?=(?:.*[${SPECIAL_CHARACTERS_ALLOWED}]){${pwSpecialCharacters},}).{${pwMinLength},}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ describe("Validate Password", () => {
it("Takes matching special characters", () => {
const pattern = new RegExp(validatePasswordPattern(0, 1, 0, 7, 0));

expect(pattern.test("@$!%*?&")).toBe(true);
expect(pattern.test("---------")).toBe(false);
expect(pattern.test("^^^^^^^^^^^^^^^^^^^^^^^")).toBe(false);
expect(pattern.test("@$!%*?&")).toBe(true);
expect(pattern.test("---")).toBe(false);
expect(pattern.test("---------")).toBe(true);
expect(pattern.test("^^^^^^^^^^^^^^^^^^^^^^^")).toBe(true);
});
});
Loading
Loading