Skip to content

Commit cbea4ce

Browse files
marie-dedikova-nhsanoop-surej-nhs
authored andcommitted
VIA-2 DB/MD Add vaccine error page without hyperlink
1 parent 6413b8b commit cbea4ce

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

src/app/vaccines/flu/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { VaccineDisplayNames, VaccineTypes } from "@src/models/vaccine";
55
import Vaccine from "@src/app/_components/vaccine/Vaccine";
66
import { getContentForVaccine } from "@src/services/content-api/gateway/content-reader-service";
77
import { VaccineContentProvider } from "@src/app/_components/providers/VaccineContentProvider";
8+
import { StyledVaccineContent } from "@src/services/content-api/parsers/content-styling-service";
89

910
export const dynamic = "force-dynamic";
1011

1112
const VaccineFlu = (): JSX.Element => {
12-
const contentPromise = getContentForVaccine(VaccineTypes.FLU);
13+
const contentPromise: Promise<StyledVaccineContent> = getContentForVaccine(
14+
VaccineTypes.FLU,
15+
);
1316

1417
return (
1518
<div>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { render, screen } from "@testing-library/react";
2+
import VaccineError from "@src/app/vaccines/vaccine-error/page";
3+
import { VaccineDisplayNames, VaccineTypes } from "@src/models/vaccine";
4+
5+
describe("VaccineError", () => {
6+
it("should display back button", () => {
7+
const pathToSchedulePage: string = "/schedule";
8+
9+
render(VaccineError({ vaccineType: VaccineTypes.FLU }));
10+
11+
const linkToSchedulePage: HTMLElement = screen.getByRole("link", {
12+
name: "Go back",
13+
});
14+
expect(linkToSchedulePage.getAttribute("href")).toBe(pathToSchedulePage);
15+
});
16+
17+
it.each([VaccineTypes.FLU, VaccineTypes.RSV, VaccineTypes.SIX_IN_ONE])(
18+
`should display vaccine name in error heading`,
19+
(vaccineType: VaccineTypes) => {
20+
render(VaccineError({ vaccineType: vaccineType }));
21+
22+
const heading: HTMLElement = screen.getByRole("heading", {
23+
level: 1,
24+
name: `${VaccineDisplayNames[vaccineType]} vaccine`,
25+
});
26+
27+
expect(heading).toBeInTheDocument();
28+
},
29+
);
30+
31+
it("should display subheading", () => {
32+
render(VaccineError({ vaccineType: VaccineTypes.FLU }));
33+
34+
const subheading: HTMLElement = screen.getByRole("heading", {
35+
level: 2,
36+
name: "Vaccine content is unavailable",
37+
});
38+
39+
expect(subheading).toBeInTheDocument();
40+
});
41+
42+
it("should display error text", () => {
43+
render(VaccineError({ vaccineType: VaccineTypes.FLU }));
44+
45+
const text: HTMLElement = screen.getByText(
46+
"Sorry, there is a problem showing vaccine information. Come back later, or read about vaccinations on NHS.uk.",
47+
);
48+
49+
expect(text).toBeInTheDocument();
50+
});
51+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { JSX } from "react";
2+
import BackLink from "@src/app/_components/nhs-frontend/BackLink";
3+
import { VaccineDisplayNames, VaccineTypes } from "@src/models/vaccine";
4+
import styles from "@src/app/styles.module.css";
5+
6+
interface VaccineProps {
7+
vaccineType: VaccineTypes;
8+
}
9+
10+
const VaccineError = (props: VaccineProps): JSX.Element => {
11+
return (
12+
<div>
13+
<BackLink link="/schedule" />
14+
<h1 className="app-dynamic-page-title__heading">{`${VaccineDisplayNames[props.vaccineType]} vaccine`}</h1>
15+
<div className={styles.subheading}>
16+
<div>
17+
<h2 className="nhsuk-heading-s">Vaccine content is unavailable</h2>
18+
</div>
19+
<p>
20+
Sorry, there is a problem showing vaccine information. Come back
21+
later, or read about vaccinations on NHS.uk.
22+
</p>
23+
</div>
24+
</div>
25+
);
26+
};
27+
28+
export default VaccineError;

0 commit comments

Comments
 (0)