Skip to content

Commit aecd00b

Browse files
VIA-603 AS/DB Render 'Common Content' as inset 'information' component from Content-API
In the COVID-19 content API response 'side effects' section is the only place we have found a 'Common Content' component so far (in this case used for some information related to A&E); match rendering shown on NHS website.
1 parent 501479b commit aecd00b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/services/content-api/parsers/content-styling-service.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ describe("ContentStylingService", () => {
137137
expect(text).toBeInTheDocument();
138138
});
139139

140+
it("should style Common Content subsection as an Information component (inset text)", async () => {
141+
const mockCommonContentSubsection: VaccinePageSubsection = {
142+
type: "simpleElement",
143+
text: "<p>This is a styled paragraph Common Content subsection</p>",
144+
name: "Common Content",
145+
headline: "",
146+
};
147+
148+
const styledSubsection: JSX.Element = styleSubsection(mockCommonContentSubsection, 1, false);
149+
render(styledSubsection);
150+
151+
const commonContentText: HTMLElement = screen.getByText("This is a styled paragraph Common Content subsection");
152+
const information: HTMLElement = screen.getByText("Information:");
153+
154+
expect(information).toBeInTheDocument();
155+
expect(information.className).toEqual("nhsuk-u-visually-hidden");
156+
expect(commonContentText).toBeInTheDocument();
157+
});
158+
140159
it("should return styled non-urgent component for subsection", async () => {
141160
const styledSubsection: JSX.Element = styleSubsection(mockNonUrgentSubsection, 1, false);
142161
render(styledSubsection);

src/services/content-api/parsers/content-styling-service.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum SubsectionTypes {
2828
URGENT = "URGENT",
2929
CALLOUT = "CALLOUT",
3030
EMERGENCY = "EMERGENCY",
31+
COMMON_CONTENT = "COMMON_CONTENT",
3132
}
3233

3334
const Subsections: Record<SubsectionTypes, string> = {
@@ -36,6 +37,7 @@ const Subsections: Record<SubsectionTypes, string> = {
3637
[SubsectionTypes.URGENT]: "urgent",
3738
[SubsectionTypes.EMERGENCY]: "immediate",
3839
[SubsectionTypes.CALLOUT]: "Callout",
40+
[SubsectionTypes.COMMON_CONTENT]: "Common Content",
3941
};
4042

4143
const _getDivWithSanitisedHtml = (html: string) => {
@@ -65,7 +67,7 @@ const styleSubsection = (subsection: VaccinePageSubsection, id: number, isLastSu
6567
text = `<h3>${subsection.headline}</h3>`.concat(text);
6668
}
6769

68-
if (subsection.name === Subsections.INFORMATION) {
70+
if (subsection.name === Subsections.INFORMATION || subsection.name === Subsections.COMMON_CONTENT) {
6971
return <InsetText key={id}>{_getDivWithSanitisedHtml(text)}</InsetText>;
7072
} else if (subsection.name === Subsections.NON_URGENT) {
7173
const { heading, headingLevel, content } = extractHeadingAndContent(subsection.text);

0 commit comments

Comments
 (0)