Skip to content

Commit 2d05ab0

Browse files
VIA-618 SB/EO Remove booking links from the How to get it sections, for Flu in pregnancy and whooping cough in pregnancy.
1 parent 398d959 commit 2d05ab0

File tree

6 files changed

+84
-12
lines changed

6 files changed

+84
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
_extractPartsForAspect,
77
_findAspect,
88
_hasHealthAspect,
9-
_removeExcludedHyperlinks,
109
getFilteredContentForVaccine,
10+
removeExcludedHyperlinks,
1111
} from "@src/services/content-api/parsers/content-filter-service";
1212
import { buildFilteredContentForCovid19Vaccine } from "@src/services/content-api/parsers/custom/covid-19";
1313
import { buildFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
@@ -420,7 +420,7 @@ describe("Content Filter", () => {
420420

421421
const expectedTextAttr = "<p>Book by going to NBS or via the NHS app</p>";
422422

423-
const actualSubsections = _removeExcludedHyperlinks(subsectionsWithMainEntity);
423+
const actualSubsections = removeExcludedHyperlinks(subsectionsWithMainEntity);
424424

425425
actualSubsections.forEach((subsection) => {
426426
if (subsection.type === "expanderElement" || subsection.type === "tableElement") {
@@ -442,7 +442,7 @@ describe("Content Filter", () => {
442442
];
443443
const expectedTextAttr = "<p>Book by going to NBS or via the NHS app</p>";
444444

445-
const actualSubsections = _removeExcludedHyperlinks(subsectionsWithTextElement);
445+
const actualSubsections = removeExcludedHyperlinks(subsectionsWithTextElement);
446446

447447
actualSubsections.forEach((subsection) => {
448448
if (subsection.type === "simpleElement") {
@@ -466,7 +466,7 @@ describe("Content Filter", () => {
466466
},
467467
];
468468

469-
const actualSubsections = _removeExcludedHyperlinks(subsections);
469+
const actualSubsections = removeExcludedHyperlinks(subsections);
470470

471471
actualSubsections.forEach((subsection) => {
472472
if (subsection.type === "simpleElement") {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const _extractPartsForAspect = (response: ContentApiVaccineResponse, aspectName:
6262
if (!subsections) {
6363
throw new Error(`Missing subsections for Aspect: ${aspectName}`);
6464
} else {
65-
const subsectionsWithExcludedLinksRemoved = _removeExcludedHyperlinks(subsections);
65+
const subsectionsWithExcludedLinksRemoved = removeExcludedHyperlinks(subsections);
6666
return subsectionsWithExcludedLinksRemoved;
6767
}
6868
};
@@ -157,7 +157,7 @@ function _extractCalloutContent(response: ContentApiVaccineResponse): string {
157157
return content;
158158
}
159159

160-
const _removeExcludedHyperlinks = (subsections: VaccinePageSubsection[]) => {
160+
const removeExcludedHyperlinks = (subsections: VaccinePageSubsection[]) => {
161161
const nbsHyperlinkPattern: RegExp =
162162
/<a [^>]*?href="[^>]*?\/nhs-services\/vaccination-and-booking-services\/book-[^>]*?>(.*?)<\/a>/g;
163163
const nhsAppPattern: RegExp = /<a [^>]*?href="[^>]*?\/nhs-app[^>]*?>(.*?)<\/a>/g;
@@ -286,5 +286,5 @@ export {
286286
_extractHeadlineForAspect,
287287
_extractDescriptionForVaccine,
288288
_extractHeadlineForContraindicationsAspect,
289-
_removeExcludedHyperlinks,
289+
removeExcludedHyperlinks,
290290
};

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
22
import { buildFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
33

4+
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
5+
46
const apiResponse = JSON.stringify({
57
mainEntityOfPage: [
68
{ hasPart: [{ text: "Flu in Pregnancy Vaccine Lead Paragraph (overview)" }] },
@@ -53,7 +55,24 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
5355
expect(pageCopy).toEqual(expect.objectContaining(expected));
5456
});
5557

56-
it("should return all parts for howToGetVaccine section", async () => {
58+
it("should return all parts for howToGetVaccine section, without booking links", async () => {
59+
const actual = JSON.stringify({
60+
mainEntityOfPage: [
61+
{ hasPart: [{ text: "Flu in Pregnancy Vaccine Lead Paragraph (overview)" }] },
62+
{ hasPart: [{ text: "<p>Why pregnant women are offered the vaccine paragraph</p>" }] },
63+
{ hasPart: [{ text: "<p>Is the vaccine safe in pregnancy paragraph</p>" }] },
64+
{ hasPart: [{ text: "<p>When should I have the vaccine paragraph</p>" }] },
65+
{
66+
hasPart: [
67+
{
68+
text: '<p><a href="https://www.nhs.uk/nhs-services/vaccination-and-booking-services/book-flu-vaccination/">book a free NHS flu vaccination appointment at a pharmacy online</a> or in the <a href="https://www.nhs.uk/nhs-app/">NHS App</a></p>',
69+
},
70+
],
71+
},
72+
{ hasPart: [{ text: "paragraph 5" }] },
73+
{ hasPart: [{ text: "Flu in Pregnancy Vaccine Lead Paragraph (overview)" }] },
74+
],
75+
});
5776
const expected = {
5877
howToGetVaccine: {
5978
headline: "How to get the vaccine",
@@ -62,13 +81,13 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
6281
type: "simpleElement",
6382
headline: "",
6483
name: "markdown",
65-
text: "<p>How to get the vaccine paragraph</p>",
84+
text: "<p>book a free NHS flu vaccination appointment at a pharmacy online or in the NHS App</p>",
6685
},
6786
],
6887
},
6988
};
7089

71-
const pageCopy = await buildFilteredContentForFluInPregnancyVaccine(apiResponse);
90+
const pageCopy = await buildFilteredContentForFluInPregnancyVaccine(actual);
7291

7392
expect(pageCopy).toEqual(expect.objectContaining(expected));
7493
});

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
2+
import { removeExcludedHyperlinks } from "@src/services/content-api/parsers/content-filter-service";
23
import {
34
ContentApiVaccineResponse,
45
HeadingWithContent,
@@ -25,7 +26,9 @@ export const buildFilteredContentForFluInPregnancyVaccine = async (apiContent: s
2526
};
2627
const howToGetVaccine: VaccinePageSection = {
2728
headline: "How to get the vaccine",
28-
subsections: [{ type: "simpleElement", headline: "", text: paragraphs[4], name: "markdown" }],
29+
subsections: removeExcludedHyperlinks([
30+
{ type: "simpleElement", headline: "", text: paragraphs[4], name: "markdown" },
31+
]),
2932
};
3033
const whenToGet: VaccinePageSection = {
3134
headline: "When should I have the vaccine?",

src/services/content-api/parsers/custom/whooping-cough.test.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
22
import { buildFilteredContentForWhoopingCoughVaccine } from "@src/services/content-api/parsers/custom/whooping-cough";
33

4+
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
5+
46
const apiResponse = JSON.stringify({
57
mainEntityOfPage: [
68
{ hasPart: [{ text: "Whooping Cough Vaccine Lead Paragraph (overview)" }] },
@@ -120,4 +122,49 @@ describe("getFilteredContentForWhoopingCoughVaccine", () => {
120122

121123
expect(pageCopy).toEqual(expect.objectContaining(expected));
122124
});
125+
126+
it("should return all parts for howToGetVaccine section, without booking links", async () => {
127+
const actual = JSON.stringify({
128+
mainEntityOfPage: [
129+
{ hasPart: [{ text: "Whooping Cough Vaccine Lead Paragraph (overview)" }] },
130+
{ hasPart: [{ text: "<p>What the vaccine is for paragraph</p>" }] },
131+
{ hasPart: [{ text: "<p>Who the vaccine is for paragraph</p>" }] },
132+
{ hasPart: [{ text: "paragraph 3" }] },
133+
{ hasPart: [{ text: "paragraph 4" }] },
134+
{ hasPart: [{ text: "paragraph 5" }] },
135+
{ hasPart: [{ text: "<p>Side effects of the vaccine paragraph</p>" }] },
136+
{ hasPart: [{ text: "paragraph 7" }] },
137+
{ hasPart: [{ text: "paragraph 8" }] },
138+
{ hasPart: [{ text: "paragraph 9" }] },
139+
{ hasPart: [{ text: "paragraph 10" }] },
140+
{ hasPart: [{ text: "paragraph 11" }] },
141+
{ hasPart: [{ text: "paragraph 12" }] },
142+
{ hasPart: [{ text: "paragraph 13" }] },
143+
{
144+
hasPart: [
145+
{
146+
text: '<p><a href="https://www.nhs.uk/nhs-services/vaccination-and-booking-services/book-flu-vaccination/">book a free vaccination appointment at a pharmacy online</a> or in the <a href="https://www.nhs.uk/nhs-app/">NHS App</a></p>',
147+
},
148+
],
149+
},
150+
{ hasPart: [{ text: "paragraph 15" }] },
151+
],
152+
});
153+
const expected = {
154+
howToGetVaccine: {
155+
headline: "How to get the vaccine",
156+
subsections: [
157+
{
158+
type: "simpleElement",
159+
headline: "",
160+
name: "markdown",
161+
text: "<p>book a free vaccination appointment at a pharmacy online or in the NHS App</p>",
162+
},
163+
],
164+
},
165+
};
166+
const pageCopy = await buildFilteredContentForWhoopingCoughVaccine(actual);
167+
168+
expect(pageCopy).toEqual(expect.objectContaining(expected));
169+
});
123170
});

src/services/content-api/parsers/custom/whooping-cough.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
2+
import { removeExcludedHyperlinks } from "@src/services/content-api/parsers/content-filter-service";
23
import { ContentApiVaccineResponse, VaccinePageContent, VaccinePageSection } from "@src/services/content-api/types";
34

45
export const buildFilteredContentForWhoopingCoughVaccine = async (apiContent: string): Promise<VaccinePageContent> => {
@@ -20,7 +21,9 @@ export const buildFilteredContentForWhoopingCoughVaccine = async (apiContent: st
2021
};
2122
const howToGetVaccine: VaccinePageSection = {
2223
headline: "How to get the vaccine",
23-
subsections: [{ type: "simpleElement", headline: "", text: paragraphs[14], name: "markdown" }],
24+
subsections: removeExcludedHyperlinks([
25+
{ type: "simpleElement", headline: "", text: paragraphs[14], name: "markdown" },
26+
]),
2427
};
2528
const vaccineSideEffects: VaccinePageSection = {
2629
headline: "Side effects of the vaccine",

0 commit comments

Comments
 (0)