Skip to content

Commit 19e1f93

Browse files
VIA-618 SB Show specific expander headings for flu in pregnancy page.
1 parent 7960e43 commit 19e1f93

File tree

5 files changed

+74
-29
lines changed

5 files changed

+74
-29
lines changed

src/app/_components/content/MoreInformation.test.tsx

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,64 @@ import { render, screen } from "@testing-library/react";
55
import React from "react";
66

77
describe("MoreInformation component ", () => {
8-
it("should display whatItIsFor expander block", async () => {
9-
const vaccineType = VaccineType.RSV;
10-
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
8+
describe("moreInformationHeadersFromContentApi false", () => {
9+
it("should display whatItIsFor expander block", async () => {
10+
const vaccineType = VaccineType.RSV;
11+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
1112

12-
expectExpanderBlockToBePresent("What the vaccine is for", "What Section styled component");
13-
});
13+
expectExpanderBlockToBePresent("What the vaccine is for", "What Section styled component");
14+
});
1415

15-
it("should display whoVaccineIsFor expander block", async () => {
16-
const vaccineType = VaccineType.RSV;
17-
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
16+
it("should display whoVaccineIsFor expander block", async () => {
17+
const vaccineType = VaccineType.RSV;
18+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
1819

19-
expectExpanderBlockToBePresent("Who should have the vaccine", "Who Section styled component");
20-
});
20+
expectExpanderBlockToBePresent("Who should have the vaccine", "Who Section styled component");
21+
});
2122

22-
it("should display howToGet expander block", async () => {
23-
const vaccineType = VaccineType.TD_IPV_3_IN_1;
24-
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
23+
it("should display howToGet expander block", async () => {
24+
const vaccineType = VaccineType.TD_IPV_3_IN_1;
25+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
26+
27+
expectExpanderBlockToBePresent("How to get the vaccine", "How Section styled component");
28+
});
29+
30+
it("should display vaccineSideEffects expander block", async () => {
31+
const vaccineType = VaccineType.RSV;
32+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
2533

26-
expectExpanderBlockToBePresent("How to get the vaccine", "How Section styled component");
34+
expectExpanderBlockToBePresent("Side effects of the vaccine", "Side effects section styled component");
35+
});
2736
});
2837

29-
it("should display vaccineSideEffects expander block", async () => {
30-
const vaccineType = VaccineType.RSV;
31-
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
38+
describe("moreInformationHeadersFromContentApi true", () => {
39+
it("should display whatItIsFor expander block", async () => {
40+
const vaccineType = VaccineType.FLU_IN_PREGNANCY;
41+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
3242

33-
expectExpanderBlockToBePresent("Side effects of the vaccine", "Side effects section styled component");
43+
expectExpanderBlockToBePresent("what-heading", "What Section styled component");
44+
});
45+
46+
it("should display whoVaccineIsFor expander block", async () => {
47+
const vaccineType = VaccineType.FLU_IN_PREGNANCY;
48+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
49+
50+
expectExpanderBlockToBePresent("who-heading", "Who Section styled component");
51+
});
52+
53+
it("should display howToGet expander block", async () => {
54+
const vaccineType = VaccineType.FLU_IN_PREGNANCY;
55+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
56+
57+
expectExpanderBlockToBePresent("how-heading", "How Section styled component");
58+
});
59+
60+
it("should display vaccineSideEffects expander block", async () => {
61+
const vaccineType = VaccineType.FLU_IN_PREGNANCY;
62+
render(<MoreInformation styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
63+
64+
expectExpanderBlockToBePresent("side-effects-heading", "Side effects section styled component");
65+
});
3466
});
3567

3668
it("should not include 'how to get' section for RSV_PREGNANCY ", async () => {

src/app/_components/content/MoreInformation.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,44 @@ const MoreInformation = (props: {
2121
{/* What-vaccine-is-for expandable section */}
2222
{props.styledVaccineContent.whatVaccineIsFor && (
2323
<Details expander>
24-
<Details.Summary>{HEADINGS.WHAT_VACCINE_IS_FOR}</Details.Summary>
24+
<Details.Summary>
25+
{vaccineInfo.moreInformationHeadersFromContentApi
26+
? props.styledVaccineContent.whatVaccineIsFor.heading
27+
: HEADINGS.WHAT_VACCINE_IS_FOR}
28+
</Details.Summary>
2529
<Details.Text>{props.styledVaccineContent.whatVaccineIsFor.component}</Details.Text>
2630
</Details>
2731
)}
2832

2933
{/* Who-vaccine-is-for expandable section */}
3034
<Details expander>
31-
<Details.Summary>{HEADINGS.WHO_SHOULD_HAVE_VACCINE}</Details.Summary>
35+
<Details.Summary>
36+
{vaccineInfo.moreInformationHeadersFromContentApi
37+
? props.styledVaccineContent.whoVaccineIsFor.heading
38+
: HEADINGS.WHO_SHOULD_HAVE_VACCINE}
39+
</Details.Summary>
3240
<Details.Text>{props.styledVaccineContent.whoVaccineIsFor.component}</Details.Text>
3341
</Details>
3442

3543
{/* How-to-get-the-vaccine expandable section */}
3644
{showHowToGetExpander && (
3745
<Details expander>
38-
<Details.Summary>{HEADINGS.HOW_TO_GET_VACCINE}</Details.Summary>
46+
<Details.Summary>
47+
{vaccineInfo.moreInformationHeadersFromContentApi
48+
? props.styledVaccineContent.howToGetVaccine.heading
49+
: HEADINGS.HOW_TO_GET_VACCINE}
50+
</Details.Summary>
3951
<Details.Text>{props.styledVaccineContent.howToGetVaccine.component}</Details.Text>
4052
</Details>
4153
)}
4254

4355
{/* Side-effects-of-the-vaccine expandable section */}
4456
<Details expander>
45-
<Details.Summary>{HEADINGS.VACCINE_SIDE_EFFECTS}</Details.Summary>
57+
<Details.Summary>
58+
{vaccineInfo.moreInformationHeadersFromContentApi
59+
? props.styledVaccineContent.vaccineSideEffects.heading
60+
: HEADINGS.VACCINE_SIDE_EFFECTS}
61+
</Details.Summary>
4662
<Details.Text>{props.styledVaccineContent.vaccineSideEffects.component}</Details.Text>
4763
</Details>
4864
</Details.ExpanderGroup>

src/models/vaccine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type VaccineDetails = {
3737
cacheFilename: Filename;
3838
nbsPath: UrlPathFragment;
3939
showWarningCallout?: boolean;
40+
moreInformationHeadersFromContentApi?: boolean;
4041
};
4142

4243
type displayName = {
@@ -297,6 +298,7 @@ const VaccineInfo: Record<VaccineType, VaccineDetails> = {
297298
contentPath: "pregnancy/keeping-well/flu-jab" as UrlPathFragment,
298299
cacheFilename: "flu-jab.json" as Filename,
299300
nbsPath: "flu-vaccine-in-pregnancy" as UrlPathFragment,
301+
moreInformationHeadersFromContentApi: true,
300302
},
301303
};
302304

src/services/content-api/parsers/content-filter-service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ describe("Content Filter", () => {
565565
it("should return all parts for whoVaccineIsFor section", () => {
566566
const expectedWhoVaccineIsFor = {
567567
whoVaccineIsFor: {
568-
headline: "Who should have the vaccine",
568+
headline: "Suitability Health Aspect headline",
569569
subsections: [
570570
{
571571
type: "simpleElement",

src/services/content-api/parsers/content-filter-service.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ const _getDescription = (name: string, description?: string): string => {
195195
return description;
196196
};
197197

198-
const _generateWhoVaccineIsForHeading = (): string => {
199-
return "Who should have the vaccine";
200-
};
201-
202198
function _extractHeadlineForContraindicationsAspect(content: ContentApiVaccineResponse): VaccinePageSubsection[] {
203199
return [
204200
{
@@ -235,7 +231,7 @@ const getFilteredContentForStandardVaccine = (apiContent: string): VaccinePageCo
235231
}
236232

237233
const whoVaccineIsFor: VaccinePageSection = {
238-
headline: _generateWhoVaccineIsForHeading(),
234+
headline: _extractHeadlineForAspect(content, "SuitabilityHealthAspect"),
239235
subsections: _extractPartsForAspect(content, "SuitabilityHealthAspect")
240236
.concat(_extractHeadlineForContraindicationsAspect(content))
241237
.concat(_extractPartsForAspect(content, "ContraindicationsHealthAspect")),
@@ -276,7 +272,6 @@ export {
276272
_extractPartsForAspect,
277273
_extractHeadlineForAspect,
278274
_extractDescriptionForVaccine,
279-
_generateWhoVaccineIsForHeading,
280275
_extractHeadlineForContraindicationsAspect,
281276
_removeExcludedHyperlinks,
282277
};

0 commit comments

Comments
 (0)