Skip to content

Commit e9f560b

Browse files
VIA-618 SB Show care card Flu in pregnancy page.
Markdown isn't being rendered yet.
1 parent d864cb9 commit e9f560b

File tree

8 files changed

+86
-2
lines changed

8 files changed

+86
-2
lines changed

src/app/_components/vaccine/Vaccine.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,20 @@ describe("Any vaccine page", () => {
125125
expect(overviewText).toBeInTheDocument();
126126
});
127127

128+
it("should include recommendation text", async () => {
129+
await renderNamedVaccinePage(VaccineType.FLU_IN_PREGNANCY);
130+
131+
const overviewText: HTMLElement = screen.getByTestId("recommendation");
132+
133+
expect(overviewText).toBeInTheDocument();
134+
});
135+
128136
it("should include callout text", async () => {
129137
await renderNamedVaccinePage(VaccineType.HIB_MENC);
130138

131-
const overviewText: HTMLElement = screen.getByTestId("callout");
139+
const calloutText: HTMLElement = screen.getByTestId("callout");
132140

133-
expect(overviewText).toBeInTheDocument();
141+
expect(calloutText).toBeInTheDocument();
134142
});
135143

136144
it("should include lowercase vaccine name in more information text", async () => {

src/app/_components/vaccine/Vaccine.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { HowToGetVaccineFallback } from "@src/app/_components/content/HowToGetVa
77
import { MoreInformation } from "@src/app/_components/content/MoreInformation";
88
import { Overview } from "@src/app/_components/content/Overview";
99
import { EligibilityVaccinePageContent } from "@src/app/_components/eligibility/EligibilityVaccinePageContent";
10+
import NonUrgentCareCard from "@src/app/_components/nhs-frontend/NonUrgentCareCard";
1011
import { RSVPregnancyInfo } from "@src/app/_components/vaccine-custom/RSVPregnancyInfo";
1112
import { NhsNumber, VaccineDetails, VaccineInfo, VaccineType } from "@src/models/vaccine";
1213
import { getContentForVaccine } from "@src/services/content-api/content-service";
@@ -69,6 +70,14 @@ const VaccineComponent = async ({ vaccineType }: VaccineProps): Promise<JSX.Elem
6970
<>
7071
<Overview styledVaccineContent={styledVaccineContent} vaccineType={vaccineType} />
7172
<Callout styledVaccineContent={styledVaccineContent} vaccineType={vaccineType} />
73+
{styledVaccineContent.recommendation && (
74+
<div data-testid="recommendation">
75+
<NonUrgentCareCard
76+
heading={styledVaccineContent.recommendation.heading}
77+
content={styledVaccineContent.recommendation.component}
78+
/>
79+
</div>
80+
)}
7281
</>
7382
)}
7483

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ describe("ContentStylingService", () => {
255255
subsections: [mockMarkdownSubsection, mockUrgentSubsection],
256256
};
257257
const mockCallout: HeadingWithContent = { heading: "Callout Heading", content: "Callout content" };
258+
const mockRecommendation: HeadingWithContent = {
259+
heading: "Recommendation Heading",
260+
content: "Recommendation content",
261+
};
258262
const mockContent: VaccinePageContent = {
259263
overview: { content: "This is an overview", containsHtml: false },
260264
whatVaccineIsFor: mockWhatSection,
@@ -263,6 +267,7 @@ describe("ContentStylingService", () => {
263267
vaccineSideEffects: mockSideEffectsSection,
264268
webpageLink: new URL("https://test.example.com/"),
265269
callout: mockCallout,
270+
recommendation: mockRecommendation,
266271
};
267272

268273
const styledVaccineContent: StyledVaccineContent = await getStyledContentForVaccine(vaccine, mockContent, false);
@@ -274,6 +279,7 @@ describe("ContentStylingService", () => {
274279
expect(styledVaccineContent.howToGetVaccine.heading).toEqual(mockHowSection.headline);
275280
expect(styledVaccineContent.vaccineSideEffects.heading).toEqual(mockSideEffectsSection.headline);
276281
expect(styledVaccineContent.callout?.heading).toEqual(mockCallout.heading);
282+
expect(styledVaccineContent.recommendation?.heading).toEqual(mockRecommendation.heading);
277283

278284
const expectedRsvHowToGetSection = "<div><p>para1</p><p>para2</p></div>";
279285
const expectedRsvPregnancyHowToGetSection = `<div><div><p>para3</p><p>para4</p></div></div>`;
@@ -330,6 +336,37 @@ describe("ContentStylingService", () => {
330336
expect(isValidElement(styledVaccineContent.vaccineSideEffects.component)).toBe(true);
331337
expect(styledVaccineContent.webpageLink).toEqual(new URL("https://test.example.com/"));
332338
});
339+
340+
it("should return styled content without recommendation when recommendation is missing", async () => {
341+
const mockWhoSection: VaccinePageSection = {
342+
headline: "Who is this Vaccine For",
343+
subsections: [mockMarkdownSubsection, mockNonUrgentSubsection],
344+
};
345+
const mockHowSection: VaccinePageSection = {
346+
headline: "How to get this Vaccine",
347+
subsections: [mockMarkdownSubsection, mockNonUrgentSubsection],
348+
};
349+
const mockSideEffectsSection: VaccinePageSection = {
350+
headline: "Side effects of the generic vaccine",
351+
subsections: [mockMarkdownSubsection, mockNonUrgentSubsection],
352+
};
353+
const mockContent: VaccinePageContent = {
354+
overview: { content: "This is an overview", containsHtml: false },
355+
whoVaccineIsFor: mockWhoSection,
356+
howToGetVaccine: mockHowSection,
357+
vaccineSideEffects: mockSideEffectsSection,
358+
webpageLink: new URL("https://test.example.com/"),
359+
recommendation: undefined,
360+
};
361+
362+
const styledVaccineContent: StyledVaccineContent = await getStyledContentForVaccine(
363+
VaccineType.RSV,
364+
mockContent,
365+
false,
366+
);
367+
368+
expect(styledVaccineContent.recommendation).toBeUndefined();
369+
});
333370
});
334371

335372
describe("extractHeadingAndContent", () => {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ function styleCallout(callout: HeadingWithContent | undefined): HeadingWithConte
159159
return undefined;
160160
}
161161

162+
function styleRecommendation(recommendation: HeadingWithContent | undefined): StyledPageSection | undefined {
163+
if (recommendation) {
164+
return { heading: recommendation.heading, component: <>{recommendation.content}</> };
165+
}
166+
return undefined;
167+
}
168+
162169
const getStyledContentForVaccine = async (
163170
vaccine: VaccineType,
164171
filteredContent: VaccinePageContent,
@@ -173,6 +180,7 @@ const getStyledContentForVaccine = async (
173180
const howToGetVaccine: StyledPageSection = styleHowToGetSection(vaccine, filteredContent.howToGetVaccine, fragile);
174181
const vaccineSideEffects: StyledPageSection = styleSection(filteredContent.vaccineSideEffects);
175182
const callout: HeadingWithContent | undefined = styleCallout(filteredContent.callout);
183+
const recommendation: StyledPageSection | undefined = styleRecommendation(filteredContent.recommendation);
176184
const webpageLink: URL = filteredContent.webpageLink;
177185

178186
return {
@@ -183,6 +191,7 @@ const getStyledContentForVaccine = async (
183191
vaccineSideEffects,
184192
webpageLink,
185193
callout,
194+
recommendation,
186195
};
187196
};
188197

src/services/content-api/parsers/custom/flu-in-pregnancy.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,17 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
122122

123123
expect(pageCopy).toEqual(expect.objectContaining(expected));
124124
});
125+
126+
it("should return recommendation", () => {
127+
const expected = {
128+
recommendation: {
129+
heading: "Breakfast",
130+
content: "I'll have:\n\n* Egg\n* Bacon\n* Sausage\n* Bubble\n* Mushrooms\n* Black Pudding\n* Toast",
131+
},
132+
};
133+
134+
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
135+
136+
expect(pageCopy).toEqual(expect.objectContaining(expected));
137+
});
125138
});

src/services/content-api/parsers/custom/flu-in-pregnancy.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const getFilteredContentForFluInPregnancyVaccine = (apiContent: string):
3636
heading: "Booking service closed",
3737
content: "Flu vaccine bookings will reopen in autumn 2026",
3838
};
39+
const recommendation: HeadingWithContent = {
40+
heading: "Breakfast",
41+
content: "I'll have:\n\n* Egg\n* Bacon\n* Sausage\n* Bubble\n* Mushrooms\n* Black Pudding\n* Toast",
42+
};
3943

4044
return {
4145
overview,
@@ -45,5 +49,6 @@ export const getFilteredContentForFluInPregnancyVaccine = (apiContent: string):
4549
vaccineSideEffects: whenToGet,
4650
webpageLink,
4751
callout: callout,
52+
recommendation: recommendation,
4853
};
4954
};

src/services/content-api/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export type VaccinePageContent = {
110110
vaccineSideEffects: VaccinePageSection;
111111
webpageLink: URL;
112112
callout?: HeadingWithContent;
113+
recommendation?: HeadingWithContent;
113114
};
114115

115116
export type StyledPageSection = {
@@ -133,6 +134,7 @@ export type StyledVaccineContent = {
133134
vaccineSideEffects: StyledPageSection;
134135
webpageLink: URL;
135136
callout?: HeadingWithContent;
137+
recommendation?: StyledPageSection;
136138
};
137139

138140
export type ContentApiVaccinationsResponse = {

test-data/content-api/data.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ export const mockStyledContent: StyledVaccineContent = {
592592
},
593593
webpageLink: new URL("https://test.example.com/"),
594594
callout: { heading: "Callout Heading", content: "Callout content" },
595+
recommendation: { heading: "Recommendation Heading", component: <div>Recommendation component</div> },
595596
};
596597

597598
export const mockStyledContentWithHtmlOverview: StyledVaccineContent = {

0 commit comments

Comments
 (0)