Skip to content

Commit cd3ae69

Browse files
VIA-629 SB Add walk-in booking section to Covid page when campaign active.
1 parent 9025ad4 commit cd3ae69

File tree

12 files changed

+76
-4
lines changed

12 files changed

+76
-4
lines changed

src/_lambda/content-cache-hydrator/content-change-detector.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { VaccinePageContent } from "@src/services/content-api/types";
33

44
const mockPreviousApprovedVaccineContent: VaccinePageContent = {
55
overview: { content: "This is an overview", containsHtml: false },
6+
actions: [],
67
whatVaccineIsFor: {
78
headline: "What Vaccine Is For",
89
subsections: [

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jest.mock("@src/app/_components/content/HowToGetVaccineFallback", () => ({
4848
.fn()
4949
.mockImplementation(() => <div data-testid="how-to-get-content-fallback-mock">How to get content fallback</div>),
5050
}));
51+
jest.mock("@src/app/_components/eligibility/EligibilityActions", () => ({
52+
EligibilityActions: jest.fn().mockImplementation(() => <div data-testid="eligibility-actions-mock">Actions</div>),
53+
}));
5154
jest.mock("@project/auth", () => ({
5255
auth: jest.fn(),
5356
}));
@@ -154,6 +157,14 @@ describe("Any vaccine page", () => {
154157
expect(calloutText).toBeInTheDocument();
155158
});
156159

160+
it("should include actions", async () => {
161+
await renderNamedVaccinePage(VaccineType.COVID_19);
162+
163+
const calloutText: HTMLElement = screen.getByTestId("eligibility-actions-mock");
164+
165+
expect(calloutText).toBeInTheDocument();
166+
});
167+
157168
it("should include lowercase vaccine name in more information text", async () => {
158169
const expectedMoreInformationHeading: string = "More information about the RSV vaccine";
159170

src/app/_components/vaccine/Vaccine.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HowToGetVaccineFallback } from "@src/app/_components/content/HowToGetVa
66
import { MoreInformation } from "@src/app/_components/content/MoreInformation";
77
import { Overview } from "@src/app/_components/content/Overview";
88
import Recommendation from "@src/app/_components/content/Recommendation";
9+
import { EligibilityActions } from "@src/app/_components/eligibility/EligibilityActions";
910
import { EligibilityVaccinePageContent } from "@src/app/_components/eligibility/EligibilityVaccinePageContent";
1011
import WarningCallout from "@src/app/_components/nhs-frontend/WarningCallout";
1112
import { RSVPregnancyInfo } from "@src/app/_components/vaccine-custom/RSVPregnancyInfo";
@@ -71,6 +72,7 @@ const VaccineComponent = async ({ vaccineType }: VaccineProps): Promise<JSX.Elem
7172
<Overview overview={styledVaccineContent.overview} vaccineType={vaccineType} />
7273
<Recommendation styledVaccineContent={styledVaccineContent} />
7374
<WarningCallout styledVaccineContent={styledVaccineContent} vaccineType={vaccineType} />
75+
<EligibilityActions actions={styledVaccineContent.actions} />
7476
<Overview overview={styledVaccineContent.overviewConclusion} vaccineType={vaccineType} />
7577
</>
7678
)}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ const buildFilteredContentForStandardVaccine = async (apiContent: string): Promi
274274
vaccineSideEffects,
275275
webpageLink,
276276
callout,
277+
actions: [],
277278
};
278279
};
279280

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ describe("ContentStylingService", () => {
307307
};
308308
const mockContent: VaccinePageContent = {
309309
overview: { content: "This is an overview", containsHtml: false },
310+
actions: [],
310311
whatVaccineIsFor: mockWhatSection,
311312
whoVaccineIsFor: mockWhoSection,
312313
howToGetVaccine: mockHowSection,
@@ -362,6 +363,7 @@ describe("ContentStylingService", () => {
362363
};
363364
const mockContent: VaccinePageContent = {
364365
overview: { content: "This is an overview", containsHtml: false },
366+
actions: [],
365367
whoVaccineIsFor: mockWhoSection,
366368
howToGetVaccine: mockHowSection,
367369
vaccineSideEffects: mockSideEffectsSection,
@@ -398,6 +400,7 @@ describe("ContentStylingService", () => {
398400
};
399401
const mockContent: VaccinePageContent = {
400402
overview: { content: "This is an overview", containsHtml: false },
403+
actions: [],
401404
whoVaccineIsFor: mockWhoSection,
402405
howToGetVaccine: mockHowSection,
403406
vaccineSideEffects: mockSideEffectsSection,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const getStyledContentForVaccine = async (
221221
const callout: StyledPageSection | undefined = styleCallout(filteredContent.callout);
222222
const recommendation: StyledPageSection | undefined = styleRecommendation(filteredContent.recommendation);
223223
const overviewConclusion: Overview | undefined = filteredContent.overviewConclusion;
224+
const actions = filteredContent.actions;
224225
let whatVaccineIsFor;
225226
if (filteredContent.whatVaccineIsFor) {
226227
whatVaccineIsFor = styleSection(filteredContent.whatVaccineIsFor);
@@ -234,6 +235,7 @@ const getStyledContentForVaccine = async (
234235
overview,
235236
callout,
236237
recommendation,
238+
actions,
237239
overviewConclusion,
238240
whatVaccineIsFor,
239241
whoVaccineIsFor,

src/services/content-api/parsers/custom/covid-19.test.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildFilteredContentForCovid19Vaccine } from "@src/services/content-api/parsers/custom/covid-19";
2+
import { ActionDisplayType, ButtonUrl, Content, Label } from "@src/services/eligibility-api/types";
23
import { genericVaccineContentAPIResponse } from "@test-data/content-api/data";
34

45
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
@@ -31,7 +32,7 @@ describe("buildFilteredContentForCovid19Vaccine", () => {
3132
expect(pageCopyForCovid19Vaccine.recommendation?.heading).toEqual("The COVID-19 vaccine is recommended if you:");
3233
});
3334

34-
it("should return a callout when no campaign is active", async () => {
35+
it("should return a callout but no actions when no campaign is active", async () => {
3536
// Given
3637
jest.setSystemTime(new Date("2025-10-01"));
3738

@@ -51,16 +52,37 @@ describe("buildFilteredContentForCovid19Vaccine", () => {
5152

5253
// Then
5354
expect(pageCopy).toEqual(expect.objectContaining(expected));
55+
expect(pageCopy.actions).toHaveLength(0);
5456
});
5557

56-
it("should not return a callout when no campaign is active", async () => {
58+
it("should return actions but no callout when no campaign is active", async () => {
5759
// Given
5860
jest.setSystemTime(new Date("2025-12-01"));
5961

62+
const expected = {
63+
actions: [
64+
{
65+
type: ActionDisplayType.actionLinkWithInfo,
66+
content: [
67+
"## Get vaccinated without an appointment",
68+
"You can find a walk-in COVID-19 vaccination site to get a vaccination without an appointment. You do not need to be registered with a GP.",
69+
].join("\n\n") as Content,
70+
button: {
71+
label: "Find a walk-in COVID-19 vaccination site" as Label,
72+
url: new URL(
73+
"https://www.nhs.uk/nhs-services/vaccination-and-booking-services/find-a-walk-in-covid-19-vaccination-site/",
74+
) as ButtonUrl,
75+
},
76+
delineator: false,
77+
},
78+
],
79+
};
80+
6081
// When
6182
const pageCopy = await buildFilteredContentForCovid19Vaccine(JSON.stringify(genericVaccineContentAPIResponse));
6283

6384
// Then
85+
expect(pageCopy).toEqual(expect.objectContaining(expected));
6486
expect(pageCopy.callout).toBeUndefined();
6587
});
6688
});

src/services/content-api/parsers/custom/covid-19.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { VaccineType } from "@src/models/vaccine";
22
import { buildFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
33
import { HeadingWithContent, HeadingWithTypedContent, VaccinePageContent } from "@src/services/content-api/types";
4+
import { Action, ActionDisplayType, ButtonUrl, Content, Label } from "@src/services/eligibility-api/types";
45
import config from "@src/utils/config";
56
import { logger } from "@src/utils/logger";
67
import { Logger } from "pino";
@@ -13,9 +14,24 @@ export const buildFilteredContentForCovid19Vaccine = async (apiContent: string):
1314
const standardFilteredContent = await buildFilteredContentForStandardVaccine(apiContent);
1415

1516
let callout: HeadingWithTypedContent | undefined;
17+
const actions: Action[] = [];
1618
if (campaigns.isActive(VaccineType.COVID_19)) {
1719
log.info("Campaign active");
1820
callout = undefined;
21+
actions.push({
22+
type: ActionDisplayType.actionLinkWithInfo,
23+
content: [
24+
"## Get vaccinated without an appointment",
25+
"You can find a walk-in COVID-19 vaccination site to get a vaccination without an appointment. You do not need to be registered with a GP.",
26+
].join("\n\n") as Content,
27+
button: {
28+
label: "Find a walk-in COVID-19 vaccination site" as Label,
29+
url: new URL(
30+
"https://www.nhs.uk/nhs-services/vaccination-and-booking-services/find-a-walk-in-covid-19-vaccination-site/",
31+
) as ButtonUrl,
32+
},
33+
delineator: false,
34+
});
1935
} else {
2036
log.info("No campaign active");
2137
callout = {
@@ -37,5 +53,5 @@ export const buildFilteredContentForCovid19Vaccine = async (apiContent: string):
3753
].join("\n"),
3854
};
3955

40-
return { ...standardFilteredContent, callout, recommendation };
56+
return { ...standardFilteredContent, callout, recommendation, actions };
4157
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const buildFilteredContentForFluInPregnancyVaccine = async (apiContent: s
4949

5050
return {
5151
overview: undefined,
52+
actions: [],
5253
whatVaccineIsFor: whyOffered,
5354
whoVaccineIsFor: isItSafe,
5455
howToGetVaccine,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const buildFilteredContentForWhoopingCoughVaccine = async (apiContent: st
3333

3434
return {
3535
overview,
36+
actions: [],
3637
whatVaccineIsFor,
3738
whoVaccineIsFor,
3839
howToGetVaccine,

0 commit comments

Comments
 (0)