Skip to content

Commit b51be85

Browse files
marie-dedikova-nhsanoop-surej-nhs
authored andcommitted
VIA-2 DB/MD Add link to the error page for vaccine pages & add a few missing types to a test
1 parent cbea4ce commit b51be85

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ describe("Any vaccine page", () => {
4545

4646
it("should display overview text", async () => {
4747
await renderVaccinePage();
48-
const overviewBlock = screen.getByText("Overview text");
48+
const overviewBlock: HTMLElement = screen.getByText("Overview text");
4949
expect(overviewBlock).toBeInTheDocument();
5050
});
5151

5252
it("should display whatItIsFor expander block", async () => {
5353
await renderVaccinePage();
5454

55-
const heading = screen.getByText("what-heading");
56-
const content = screen.getByText("What Section styled component");
55+
const heading: HTMLElement = screen.getByText("what-heading");
56+
const content: HTMLElement = screen.getByText(
57+
"What Section styled component",
58+
);
5759

5860
expect(heading).toBeInTheDocument();
5961
expect(content).toBeInTheDocument();
@@ -62,8 +64,8 @@ describe("Any vaccine page", () => {
6264
it("should display whoVaccineIsFor expander block", async () => {
6365
await renderVaccinePage();
6466

65-
const heading = screen.getByText("who-heading");
66-
const content = screen.getByRole("heading", {
67+
const heading: HTMLElement = screen.getByText("who-heading");
68+
const content: HTMLElement = screen.getByRole("heading", {
6769
level: 2,
6870
name: "Who Section styled component",
6971
});
@@ -75,8 +77,10 @@ describe("Any vaccine page", () => {
7577
it("should display howToGetVaccine expander block", async () => {
7678
await renderVaccinePage();
7779

78-
const heading = screen.getByText("how-heading");
79-
const content = screen.getByText("How Section styled component");
80+
const heading: HTMLElement = screen.getByText("how-heading");
81+
const content: HTMLElement = screen.getByText(
82+
"How Section styled component",
83+
);
8084

8185
expect(heading).toBeInTheDocument();
8286
expect(content).toBeInTheDocument();
@@ -85,7 +89,7 @@ describe("Any vaccine page", () => {
8589
it("should display webpage link", async () => {
8690
await renderVaccinePage();
8791

88-
const webpageLink = screen.getByRole("link", {
92+
const webpageLink: HTMLElement = screen.getByRole("link", {
8993
name: `Learn more about the ${mockVaccineName} vaccination on nhs.uk`,
9094
});
9195

src/app/vaccines/vaccine-error/page.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ describe("VaccineError", () => {
4343
render(VaccineError({ vaccineType: VaccineTypes.FLU }));
4444

4545
const text: HTMLElement = screen.getByText(
46-
"Sorry, there is a problem showing vaccine information. Come back later, or read about vaccinations on NHS.uk.",
46+
/Sorry, there is a problem showing vaccine/,
4747
);
4848

4949
expect(text).toBeInTheDocument();
5050
});
51+
52+
it("renders link in error text", async () => {
53+
render(VaccineError({ vaccineType: VaccineTypes.FLU }));
54+
55+
const link: HTMLElement = screen.getByRole("link", {
56+
name: "vaccinations on NHS.uk",
57+
});
58+
59+
expect(link).toBeInTheDocument();
60+
expect(link.getAttribute("href")).toEqual(
61+
"https://www.nhs.uk/vaccinations/",
62+
);
63+
});
5164
});

src/app/vaccines/vaccine-error/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ interface VaccineProps {
77
vaccineType: VaccineTypes;
88
}
99

10-
const VaccineError = (props: VaccineProps): JSX.Element => {
10+
const VaccineError = ({ vaccineType }: VaccineProps): JSX.Element => {
1111
return (
1212
<div>
1313
<BackLink link="/schedule" />
14-
<h1 className="app-dynamic-page-title__heading">{`${VaccineDisplayNames[props.vaccineType]} vaccine`}</h1>
14+
<h1 className="app-dynamic-page-title__heading">{`${VaccineDisplayNames[vaccineType]} vaccine`}</h1>
1515
<div className={styles.subheading}>
1616
<div>
1717
<h2 className="nhsuk-heading-s">Vaccine content is unavailable</h2>
1818
</div>
1919
<p>
2020
Sorry, there is a problem showing vaccine information. Come back
21-
later, or read about vaccinations on NHS.uk.
21+
later, or read about{" "}
22+
<a href="https://www.nhs.uk/vaccinations/">vaccinations on NHS.uk</a>.
2223
</p>
2324
</div>
2425
</div>

0 commit comments

Comments
 (0)