Skip to content

Commit b818fb9

Browse files
committed
Update nhs sde about page
1 parent 0a7ee53 commit b818fb9

9 files changed

Lines changed: 180 additions & 109 deletions

File tree

src/app/[locale]/account/profile/cohort-discovery-request/components/CohortAccessStepper/CohortAccessStepper.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import useAuth from "@/hooks/useAuth";
1717
import { useCohortStatus } from "@/hooks/useCohortStatus";
1818
import useDialog from "@/hooks/useDialog";
1919
import { colors } from "@/config/theme";
20-
import { statusMapping, STEP_STATE } from "@/consts/cohortDiscovery";
21-
import { RouteName } from "@/consts/routeName";
20+
import {
21+
COHORT_ABOUT_HREF,
22+
statusMapping,
23+
STEP_STATE,
24+
} from "@/consts/cohortDiscovery";
2225
import { differenceInDays } from "@/utils/date";
2326
import { capitalise } from "@/utils/general";
2427
import ProfileForm from "@/app/[locale]/account/profile/components/ProfileForm";
@@ -29,7 +32,6 @@ import { CircleState, StepNode, StepTitle } from "../Stepper";
2932
const TRANSLATION_PATH = "pages.account.profile.cohortDiscovery.stepper";
3033
const RESOLVED_STATUSES = ["APPROVED", "REJECTED", "EXPIRED", "BANNED"];
3134

32-
const INFO_HREF = `/${RouteName.ABOUT}/${RouteName.COHORT_DISCOVERY}`;
3335
const TERMS_HREF =
3436
"https://digital.nhs.uk/data-and-information/research-powered-by-data/registration-service";
3537

@@ -140,7 +142,7 @@ const CohortAccessStepper = ({
140142
<Typography color={colors.grey700}>
141143
{t.rich("moreInfo", {
142144
link: chunks => (
143-
<Link href={INFO_HREF}>{chunks}</Link>
145+
<Link href={COHORT_ABOUT_HREF}>{chunks}</Link>
144146
),
145147
})}
146148
</Typography>

src/app/[locale]/account/profile/cohort-discovery-request/components/NhsSdeAccessStepper/NhsSdeAccessStepper.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@ import usePost from "@/hooks/usePost";
1919
import apis from "@/config/apis";
2020
import { colors } from "@/config/theme";
2121
import {
22+
COHORT_ABOUT_HREF,
2223
COHORT_STATUS,
2324
NHS_SDE_FINAL_STATUSES,
2425
NHS_SDE_NEGATIVE_STATUSES,
2526
NHS_SDE_STATUS,
2627
STEP_STATE,
2728
} from "@/consts/cohortDiscovery";
28-
import { RouteName } from "@/consts/routeName";
2929
import { capitalise } from "@/utils/general";
3030
import { revalidateCacheAction } from "@/app/actions/revalidateCacheAction";
3131
import { useFeatures } from "@/providers/FeatureProvider";
3232
import { CircleState, StepNode, StepTitle } from "../Stepper";
3333

3434
const TRANSLATION_PATH = "pages.account.profile.cohortDiscovery.nhsStepper";
35-
const ABOUT_HREF = `/${RouteName.ABOUT}/${RouteName.COHORT_DISCOVERY}`;
36-
const MORE_INFO_HREF = `${ABOUT_HREF}?tab=nhs-sde-network`;
37-
const HOW_TO_HREF = `${ABOUT_HREF}?tab=how-to-request-access`;
35+
const MORE_INFO_HREF = `${COHORT_ABOUT_HREF}?tab=nhs-sde-network`;
36+
const HOW_TO_HREF = `${COHORT_ABOUT_HREF}?tab=how-to-request-access`;
3837
const REGISTRATION_INFO_URL =
3938
"https://digital.nhs.uk/data-and-information/research-powered-by-data/sde-network";
4039

src/components/CohortDiscoveryInfo/CohortAccessButtons.tsx

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/components/CohortDiscoveryInfo/CohortDiscoveryInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const CohortDiscoveryInfo = async ({
166166
content={
167167
cohortDiscovery?.template
168168
?.newCohortDiscoveryFieldGroup
169-
.thirdPageText
169+
.thirdPageText ?? ""
170170
}
171171
/>
172172
</Box>
@@ -197,7 +197,7 @@ const CohortDiscoveryInfo = async ({
197197
content={
198198
cohortDiscovery?.template
199199
?.newCohortDiscoveryFieldGroup
200-
.thirdPageTextPartTwo
200+
.thirdPageTextPartTwo ?? ""
201201
}
202202
/>
203203
</Box>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import HTMLVideoEmbed from "./HTMLVideoEmbed";
2+
import { render } from "@/utils/testUtils";
3+
4+
const IFRAME = '<iframe src="https://www.youtube.com/embed/abc123"></iframe>';
5+
6+
describe("HTMLVideoEmbed", () => {
7+
it.each([
8+
["undefined", undefined],
9+
["an empty string", ""],
10+
])("renders nothing when content is %s", (_label, content) => {
11+
const { container } = render(<HTMLVideoEmbed content={content} />);
12+
13+
expect(container).toBeEmptyDOMElement();
14+
});
15+
16+
it("renders the embed inside a responsive wrapper", () => {
17+
const { container } = render(<HTMLVideoEmbed content={IFRAME} />);
18+
19+
const iframe = container.querySelector("iframe");
20+
21+
expect(iframe).toBeInTheDocument();
22+
expect(iframe).toHaveAttribute(
23+
"src",
24+
"https://www.youtube.com/embed/abc123"
25+
);
26+
});
27+
28+
it("strips unsafe markup from CMS content", () => {
29+
const { container } = render(
30+
<HTMLVideoEmbed content={`${IFRAME}<script>alert(1)</script>`} />
31+
);
32+
33+
expect(container.querySelector("script")).not.toBeInTheDocument();
34+
expect(container.querySelector("iframe")).toBeInTheDocument();
35+
});
36+
});
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { CmsStep } from "@/interfaces/Cms";
2+
import StepList from "./StepList";
3+
import { render, screen } from "@/utils/testUtils";
4+
5+
jest.mock("./ViewCohortDatasetsButton", () => ({
6+
__esModule: true,
7+
default: ({ nhsSdeOnly }: { nhsSdeOnly?: boolean }) => (
8+
<button type="button">
9+
{nhsSdeOnly ? "view datasets nhs" : "view datasets"}
10+
</button>
11+
),
12+
}));
13+
14+
jest.mock("../CohortDiscoveryButton", () => ({
15+
__esModule: true,
16+
default: () => <button type="button">apply</button>,
17+
}));
18+
19+
const step = (overrides: Partial<CmsStep> = {}): CmsStep => ({
20+
stepTitle: "A step",
21+
stepText: "<p>Step body</p>",
22+
...overrides,
23+
});
24+
25+
describe("StepList", () => {
26+
it("numbers every step when no markers are set", () => {
27+
render(
28+
<StepList
29+
steps={[
30+
step({ stepTitle: "First" }),
31+
step({ stepTitle: "Second" }),
32+
step({ stepTitle: "Third" }),
33+
]}
34+
/>
35+
);
36+
37+
expect(screen.getByText("1")).toBeInTheDocument();
38+
expect(screen.getByText("2")).toBeInTheDocument();
39+
expect(screen.getByText("3")).toBeInTheDocument();
40+
});
41+
42+
it("skips email markers when numbering, so numbers stay sequential", () => {
43+
render(
44+
<StepList
45+
steps={[
46+
step({ stepTitle: "First" }),
47+
step({ stepTitle: "Notification", marker: "email" }),
48+
step({ stepTitle: "Second" }),
49+
]}
50+
/>
51+
);
52+
53+
expect(screen.getByText("1")).toBeInTheDocument();
54+
expect(screen.getByText("2")).toBeInTheDocument();
55+
expect(screen.queryByText("3")).not.toBeInTheDocument();
56+
});
57+
58+
it("renders an icon instead of a number for an email marker", () => {
59+
render(
60+
<StepList
61+
steps={[step({ stepTitle: "Notification", marker: "email" })]}
62+
/>
63+
);
64+
65+
expect(screen.getByTestId("MailOutlineIcon")).toBeInTheDocument();
66+
expect(screen.queryByText("1")).not.toBeInTheDocument();
67+
});
68+
69+
it("treats a single-element array marker the same as a scalar", () => {
70+
render(
71+
<StepList
72+
steps={[step({ stepTitle: "Notification", marker: ["email"] })]}
73+
/>
74+
);
75+
76+
expect(screen.getByTestId("MailOutlineIcon")).toBeInTheDocument();
77+
});
78+
79+
it("renders step titles and sanitised body content", () => {
80+
render(
81+
<StepList
82+
steps={[
83+
step({
84+
stepTitle: "Define your cohort",
85+
stepText: "<p>Use the query builder</p>",
86+
}),
87+
]}
88+
/>
89+
);
90+
91+
expect(screen.getByText("Define your cohort")).toBeInTheDocument();
92+
expect(screen.getByText("Use the query builder")).toBeInTheDocument();
93+
});
94+
95+
it.each([
96+
["viewDatasets", "view datasets"],
97+
["viewDatasetsNhs", "view datasets nhs"],
98+
["apply", "apply"],
99+
])("renders the %s button", (buttonKey, label) => {
100+
render(<StepList steps={[step({ buttonKey })]} />);
101+
102+
expect(
103+
screen.getByRole("button", { name: label })
104+
).toBeInTheDocument();
105+
});
106+
107+
it("renders no button when buttonKey is omitted", () => {
108+
render(<StepList steps={[step()]} />);
109+
110+
expect(screen.queryByRole("button")).not.toBeInTheDocument();
111+
});
112+
113+
it("renders no button for an unknown buttonKey", () => {
114+
render(<StepList steps={[step({ buttonKey: "viewDatasetsNHS" })]} />);
115+
116+
expect(screen.queryByRole("button")).not.toBeInTheDocument();
117+
});
118+
119+
it("renders an empty list without throwing", () => {
120+
render(<StepList steps={[]} />);
121+
122+
expect(screen.getByRole("list")).toBeEmptyDOMElement();
123+
});
124+
});

src/config/messages/en.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,12 +2013,8 @@
20132013
"CohortDiscoveryInfo": {
20142014
"title": "Cohort Discovery",
20152015
"whatCanIDo": "What can I do in Cohort Discovery?",
2016-
"step1": "Firstly, request access through the NHS website",
2017-
"step2": "Once approved, select this button",
20182016
"learnAbout": "Learn about Cohort Discovery and gain access to the service",
2019-
"accessButton": "Access Cohort Discovery",
2020-
"nhsNetwork": "NHS Research SDE Network",
2021-
"nhsNetworkInfo": "The following additional NHS Research SDE datasets are available in Cohort Discovery, but require you go to through a separate approval process by the NHS Research SDE Network."
2017+
"accessButton": "Access Cohort Discovery"
20222018
}
20232019
},
20242020
"modules": {

src/consts/cohortDiscovery.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { RouteName } from "@/consts/routeName";
2+
13
const COHORT_STATUS = {
24
APPROVED: "APPROVED",
35
REJECTED: "REJECTED",
@@ -61,6 +63,8 @@ const STEP_STATE = {
6163
PENDING: "pending",
6264
} as const;
6365

66+
const COHORT_ABOUT_HREF = `/${RouteName.ACCOUNT}/${RouteName.PROFILE}/${RouteName.COHORT_DISCOVERY_ABOUT}`;
67+
6468
export {
6569
statusMapping,
6670
NHSSDEStatusMapping,
@@ -72,4 +76,5 @@ export {
7276
COHORT_DISCOVERY_SDE_EXPIRY_WARNING_DAYS,
7377
NHS_SDE_FILTER,
7478
STEP_STATE,
79+
COHORT_ABOUT_HREF,
7580
};

src/interfaces/Cms.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ interface CtaLink {
3939
title: string;
4040
}
4141

42-
type CmsStepMarker = "number" | "email" | "none";
42+
type CmsStepMarker = "number" | "email";
4343

4444
interface CmsStep {
4545
stepTitle: string;
4646
stepText: string;
47-
marker?: CmsStepMarker;
48-
buttonKey?: string;
47+
marker?: CmsStepMarker | CmsStepMarker[];
48+
buttonKey?: string | string[];
4949
}
5050

5151
interface PageTemplatePromo {

0 commit comments

Comments
 (0)