Skip to content

Commit 00c036b

Browse files
VIA-306 MD: Show vaccines for during pregnancy page
1 parent a5f533a commit 00c036b

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ src/app/_components/nhs-app/CardLink.tsx:ipv4:30
77
4042f9b1238dd4efc8bfdee65fa4ecbd5e08504e:fake-api/data/apim/token.json:generic-api-key:2
88
4042f9b1238dd4efc8bfdee65fa4ecbd5e08504e:fake-api/data/apim/token.json:generic-api-key:6
99
src/app/api/fake-login/token/route.ts:jwt:11
10+
src/app/_components/nhs-app/CardLinkWithDescription.tsx:ipv4:30
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
interface CardLinkProps {
2+
title: string;
3+
description: string;
4+
link: string;
5+
}
6+
7+
const CardLinkWithDescription = ({ title, description, link }: CardLinkProps) => {
8+
return (
9+
<li className="nhsapp-card">
10+
<div className="nhsapp-card">
11+
<div className="nhsapp-card__container">
12+
<div className="nhsapp-card__content">
13+
<a href={link} className="nhsapp-card__link nhsuk-link--no-visited-state">
14+
{title}
15+
</a>
16+
<div className="nhsapp-card__below">
17+
<p className="nhsapp-card__description">{description}</p>
18+
</div>
19+
</div>
20+
<svg
21+
className="nhsapp-icon nhsapp-icon--chevron-right"
22+
xmlns="http://www.w3.org/2000/svg"
23+
aria-hidden="true"
24+
focusable="false"
25+
height="2rem"
26+
width="2rem"
27+
viewBox="0 0 24 24"
28+
>
29+
{" "}
30+
<path d="M8.82 19.11a.97.97 0 0 1-.72-.31.996.996 0 0 1 .03-1.41l5.61-5.38-5.6-5.25c-.4-.38-.42-1.01-.05-1.41.38-.4 1.01-.42 1.41-.05l6.37 5.97c.2.19.31.45.32.72s-.11.54-.31.73l-6.37 6.11c-.19.19-.44.28-.69.28Z" />{" "}
31+
</svg>{" "}
32+
</div>{" "}
33+
</div>
34+
</li>
35+
);
36+
};
37+
38+
export default CardLinkWithDescription;

src/app/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const VACCINATIONS_HUB_PAGE_ROUTE = "/check-and-book-vaccinations";
22
export const SERVICE_HEADING = "Check and book vaccinations";
33
export const VACCINES_FOR_ALL_AGES_PAGE = "Vaccines for all ages";
4+
export const VACCINES_FOR_PREGNANT_PAGE = "Vaccines during Pregnancy";
45
export const NHS_TITLE_SUFFIX = "NHS";
56
export const HUB_FEEDBACK_REFERRER_ID = "hub";
67

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import VaccinesForPregnant from "@src/app/vaccines-during-pregnancy/page";
2+
import { assertBackLinkIsPresent } from "@test-data/utils/back-link-helpers";
3+
import { render, screen } from "@testing-library/react";
4+
5+
jest.mock("@src/app/_components/nhs-frontend/BackLink", () => jest.fn(() => <div data-testid="back-link"></div>));
6+
7+
describe("VaccinesForPregnantPeople", () => {
8+
const vaccines = [
9+
{
10+
name: "Whooping cough (Pertussis)",
11+
description: "Around 20 weeks",
12+
link: "/vaccines/whooping-cough-vaccination",
13+
},
14+
{ name: "RSV in pregnancy", description: "From 28 weeks", link: "/vaccines/rsv-pregnancy" },
15+
];
16+
17+
it("should render heading", () => {
18+
render(<VaccinesForPregnant />);
19+
20+
const heading: HTMLElement = screen.getByRole("heading", { name: "Vaccines during Pregnancy", level: 1 });
21+
22+
expect(heading).toBeVisible();
23+
});
24+
25+
it("should render back link", () => {
26+
render(<VaccinesForPregnant />);
27+
28+
assertBackLinkIsPresent(screen);
29+
});
30+
31+
it.each(vaccines)(`should render card link with description for $name`, ({ name, description, link }) => {
32+
render(<VaccinesForPregnant />);
33+
34+
const cardLink: HTMLElement = screen.getByRole("link", { name });
35+
const cardDescription: HTMLElement = screen.getByText(description);
36+
37+
expect(cardLink).toBeVisible();
38+
expect(cardLink.getAttribute("href")).toEqual(link);
39+
expect(cardDescription).toBeVisible();
40+
});
41+
42+
it("renders vaccines for all ages button", async () => {
43+
render(<VaccinesForPregnant />);
44+
expectLinkToBeRendered("View vaccines for all ages", "/vaccines-for-all-ages");
45+
});
46+
});
47+
48+
const expectLinkToBeRendered = (text: string, href: string) => {
49+
const link: HTMLElement = screen.getByRole("link", { name: text });
50+
expect(link).toBeVisible();
51+
expect(link).toHaveAttribute("href", href);
52+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import CardLinkWithDescription from "@src/app/_components/nhs-app/CardLinkWithDescription";
2+
import BackLink from "@src/app/_components/nhs-frontend/BackLink";
3+
import MainContent from "@src/app/_components/nhs-frontend/MainContent";
4+
import { NHS_TITLE_SUFFIX, VACCINES_FOR_PREGNANT_PAGE } from "@src/app/constants";
5+
import Link from "next/link";
6+
import React, { JSX } from "react";
7+
8+
const VaccinesForPregnant = (): JSX.Element => {
9+
return (
10+
<>
11+
<title>{`${VACCINES_FOR_PREGNANT_PAGE} - ${NHS_TITLE_SUFFIX}`}</title>
12+
<BackLink />
13+
<MainContent>
14+
<h1 className={"app-dynamic-page-title__heading"}>{VACCINES_FOR_PREGNANT_PAGE}</h1>
15+
<ul className="nhsapp-cards nhsapp-cards--stacked">
16+
<CardLinkWithDescription
17+
title={"Whooping cough (Pertussis)"}
18+
description={"Around 20 weeks"}
19+
link={"/vaccines/whooping-cough-vaccination"}
20+
/>
21+
<CardLinkWithDescription
22+
title={"RSV in pregnancy"}
23+
description={"From 28 weeks"}
24+
link={"/vaccines/rsv-pregnancy"}
25+
/>
26+
</ul>
27+
<Link href={"/vaccines-for-all-ages"} className={"nhsuk-button nhsuk-button--secondary"}>
28+
View vaccines for all ages
29+
</Link>
30+
</MainContent>
31+
</>
32+
);
33+
};
34+
35+
export default VaccinesForPregnant;

0 commit comments

Comments
 (0)