Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/content/ContentValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const REQUIRED_COMMON_KEYS: (keyof CommonContent)[] = [
];

const REQUIRED_PAGE_KEYS: (keyof MainPagesContent)[] = [
"before-you-start",
"get-self-test-kit-for-HIV",
"kit-not-available-in-area",
"go-to-clinic",
Expand Down
56 changes: 26 additions & 30 deletions ui/content/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@
}
},
"pages": {
"before-you-start": {
"pageTitle": "Before you order a free HIV self-test kit - HomeTest - NHS",
"title": "Before you order a free HIV self-test kit",
"urgentCard": {
"heading": "Go to a sexual health clinic if:",
"hivExposureBullet": "you think you've been exposed to HIV in the last 72 hours, as they can give you emergency medicine called PEP",
"stiSymptomsBulletPrefix": "you think you have any",
"stiSymptomsLink": {
"text": "sexually transmitted infection (STI) symptoms",
"href": "https://www.nhs.uk/conditions/sexually-transmitted-infections-stis/"
},
"transmissionInfo": "The virus can be spread by having vaginal, anal or oral sex without a condom or by sharing needles with someone who has HIV.",
"aeAdvicePrefix": "You can also get emergency HIV medicine from"
},
"continueButton": "Continue to order a kit"
},
"get-self-test-kit-for-HIV": {
"title": "Get a self-test kit for HIV",
"ageRequirement": "You can use this service if you are aged 18 or over.",
Expand Down Expand Up @@ -396,45 +412,33 @@
"suppliers": {
"preventx": {
"title": "Preventx terms of use",
"introduction": [
"This is introduction paragraph for Preventx. https://www.sh.uk/"
],
"introduction": ["This is introduction paragraph for Preventx. https://www.sh.uk/"],
"sections": [
{
"id": "preventx-first-section",
"heading": "It is first section for Preventx",
"paragraphs": [
"It is example of content for Preventx."
],
"paragraphs": ["It is example of content for Preventx."],
"subsections": [
{
"heading": "It is the first subsection for Preventx",
"paragraphs": [
"It is example of content for Preventx."
]
"paragraphs": ["It is example of content for Preventx."]
}
]
}
]
},
"sh:24": {
"title": "SH:24 terms of use",
"introduction": [
"This is introduction paragraph for SH:24. https://sh24.org.uk/"
],
"introduction": ["This is introduction paragraph for SH:24. https://sh24.org.uk/"],
"sections": [
{
"id": "sh24-first-section",
"heading": "It is first section for SH:24 ",
"paragraphs": [
"It is example of content for SH:24."
],
"paragraphs": ["It is example of content for SH:24."],
"subsections": [
{
"heading": "It is the first subsection for SH:24",
"paragraphs": [
"It is example of content for SH:24."
]
"paragraphs": ["It is example of content for SH:24."]
}
]
}
Expand All @@ -454,15 +458,11 @@
{
"id": "preventx-first-section",
"heading": "It is first privacy section for Preventx",
"paragraphs": [
"It is example of privacy policy content for Preventx."
],
"paragraphs": ["It is example of privacy policy content for Preventx."],
"subsections": [
{
"heading": "It is the first privacy subsection for Preventx",
"paragraphs": [
"It is example of privacy policy content for Preventx."
]
"paragraphs": ["It is example of privacy policy content for Preventx."]
}
]
}
Expand All @@ -477,15 +477,11 @@
{
"id": "sh24-first-section",
"heading": "It is first privacy section for SH:24",
"paragraphs": [
"It is example of privacy policy content for SH:24."
],
"paragraphs": ["It is example of privacy policy content for SH:24."],
"subsections": [
{
"heading": "It is the first privacy subsection for SH:24",
"paragraphs": [
"It is example of privacy policy content for SH:24."
]
"paragraphs": ["It is example of privacy policy content for SH:24."]
}
]
}
Expand Down
21 changes: 19 additions & 2 deletions ui/content/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,29 @@ export interface GoToClinicContent {
moreOptionsHeading: string;
}

export interface BeforeYouStartContent {
pageTitle: string;
title: string;
urgentCard: {
heading: string;
hivExposureBullet: string;
stiSymptomsBulletPrefix: string;
stiSymptomsLink: {
text: string;
href: string;
};
transmissionInfo: string;
aeAdvicePrefix: string;
};
continueButton: string;
}

// ============================================================================
// Pages Container
// ============================================================================

export interface PagesContent {
"before-you-start": BeforeYouStartContent;
"get-self-test-kit-for-HIV": StartPageContent;
"enter-delivery-address": EnterDeliveryAddressContent;
"enter-address-manually": EnterAddressManuallyContent;
Expand Down Expand Up @@ -521,8 +539,7 @@ export interface ContentFile {

export type MainPagesContent = Omit<
PagesContent,
| "home-test-privacy-policy"
| "home-test-terms-of-use"
"home-test-privacy-policy" | "home-test-terms-of-use"
>;

export interface MainContentFile {
Expand Down
1 change: 1 addition & 0 deletions ui/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
export { useContent, useCommonContent, usePageContent } from "./useContent";
export type { UseContentReturn } from "./useContent";
export { useAsyncErrorHandler } from "./useAsyncErrorHandler";
export { usePageTitle } from "./usePageTitle";
export { useThrowError } from "./useThrowError";
7 changes: 5 additions & 2 deletions ui/hooks/useContent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
BeforeYouStartContent,
BloodSampleGuideContent,
CannotUseServiceUnder18Content,
CheckYourAnswersContent,
Expand All @@ -7,7 +8,6 @@ import type {
EnterAddressManuallyContent,
EnterDeliveryAddressContent,
EnterMobilePhoneNumberContent,
ServiceErrorContent,
GoToClinicContent,
HomeTestPrivacyPolicyContent,
HomeTestTermsOfUseContent,
Expand All @@ -17,14 +17,15 @@ import type {
OrderSubmittedContent,
OrderTrackingContent,
SelectDeliveryAddressContent,
ServiceErrorContent,
StartPageContent,
SuppliersLegalDocumentsContent,
TestResultsContent,
} from "@/content";

import { content } from "@/content";

export const PageKeys = {
BeforeYouStart: "before-you-start",
GetSelfTest: "get-self-test-kit-for-HIV",
KitNotAvailableInArea: "kit-not-available-in-area",
EnterDeliveryAddress: "enter-delivery-address",
Expand All @@ -47,6 +48,7 @@ export type PageKey = (typeof PageKeys)[keyof typeof PageKeys];

export interface UseContentReturn {
commonContent: CommonContent;
"before-you-start": BeforeYouStartContent;
"get-self-test-kit-for-HIV": StartPageContent;
"kit-not-available-in-area": KitNotAvailableInAreaContent;
"enter-delivery-address": EnterDeliveryAddressContent;
Expand All @@ -73,6 +75,7 @@ export interface UseContentReturn {
export const useContent = (): UseContentReturn => {
return {
commonContent: content.commonContent,
"before-you-start": content.pages["before-you-start"],
"get-self-test-kit-for-HIV": content.pages["get-self-test-kit-for-HIV"],
"kit-not-available-in-area": content.pages["kit-not-available-in-area"],
"enter-delivery-address": content.pages["enter-delivery-address"],
Expand Down
11 changes: 11 additions & 0 deletions ui/hooks/usePageTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useEffect } from "react";

export function usePageTitle(title: string) {
useEffect(() => {
const previous = document.title;
document.title = title;
return () => {
document.title = previous;
};
}, [title]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import "@testing-library/jest-dom";
import { fireEvent, render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";

import BeforeYouStartPage from "@/routes/get-self-test-kit-for-HIV-journey/BeforeYouStartPage";

const mockNavigate = jest.fn();

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
useNavigate: () => mockNavigate,
}));

const TestWrapper = ({ children }: { children: React.ReactNode }) => (
<MemoryRouter initialEntries={["/before-you-start"]}>{children}</MemoryRouter>
);

describe("BeforeYouStartPage", () => {
beforeEach(() => {
mockNavigate.mockClear();
});

it("renders the page heading", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(
screen.getByRole("heading", { name: "Before you order a free HIV self-test kit", level: 1 }),
).toBeInTheDocument();
});

it("renders the urgent card heading", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(
screen.getByRole("heading", { name: "Urgent advice: Go to a sexual health clinic if:" }),
).toBeInTheDocument();
});

it("renders the HIV exposure bullet", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(
screen.getByText(
"you think you've been exposed to HIV in the last 72 hours, as they can give you emergency medicine called PEP",
),
).toBeInTheDocument();
});

it("renders the STI symptoms link with the correct href", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

const stiLink = screen.getByRole("link", {
name: "sexually transmitted infection (STI) symptoms",
});
expect(stiLink).toBeInTheDocument();
expect(stiLink).toHaveAttribute(
"href",
"https://www.nhs.uk/conditions/sexually-transmitted-infections-stis/",
);
});

it("renders the Find a sexual health clinic ActionLink with the correct href", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

const clinicLink = screen.getByRole("link", { name: "Find a sexual health clinic" });
expect(clinicLink).toBeInTheDocument();
expect(clinicLink).toHaveAttribute(
"href",
"https://www.nhs.uk/service-search/sexual-health-services/find-a-sexual-health-clinic/",
);
});

it("renders the A&E link with the correct href", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

const aeLink = screen.getByRole("link", { name: "your nearest A&E" });
expect(aeLink).toBeInTheDocument();
expect(aeLink).toHaveAttribute(
"href",
"https://www.nhs.uk/service-search/find-an-accident-and-emergency-service/",
);
});

it("renders the Continue to order a kit button", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(screen.getByRole("button", { name: "Continue to order a kit" })).toBeInTheDocument();
});

it("navigates to /get-self-test-kit-for-HIV when the Continue button is clicked", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

fireEvent.click(screen.getByRole("button", { name: "Continue to order a kit" }));

expect(mockNavigate).toHaveBeenCalledWith("/get-self-test-kit-for-HIV");
});

it("renders the transmission info paragraph", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(
screen.getByText(
"The virus can be spread by having vaginal, anal or oral sex without a condom or by sharing needles with someone who has HIV.",
),
).toBeInTheDocument();
});

it("sets the document title", () => {
render(<BeforeYouStartPage />, { wrapper: TestWrapper });

expect(document.title).toBe("Before you order a free HIV self-test kit - HomeTest - NHS");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,6 @@ describe("Back Navigation", () => {
fireEvent.click(screen.getByText("Back"));

expect(goBackMock).not.toHaveBeenCalled();
expect(goToStepMock).toHaveBeenCalledWith(RoutePath.GetSelfTestKitPage);
expect(goToStepMock).toHaveBeenCalledWith(RoutePath.BeforeYouStartPage);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe("CheckYourAnswersPage", () => {

await waitFor(() => {
expect(mockClearAddresses).toHaveBeenCalled();
expect(mockResetNavigation).toHaveBeenCalledWith(RoutePath.GetSelfTestKitPage, {
expect(mockResetNavigation).toHaveBeenCalledWith(RoutePath.BeforeYouStartPage, {
replace: true,
});
expect(screen.getByTestId("order-reference")).toHaveTextContent("");
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ServiceErrorPage from "./routes/ServiceErrorPage";
import SuppliersPrivacyPolicyPage from "./routes/SuppliersPrivacyPolicyPage";
import SuppliersTermsConditionsPage from "./routes/SuppliersTermsConditionsPage";
import TestResultsPage from "./routes/TestResultsPage";
import BeforeYouStartPage from "./routes/get-self-test-kit-for-HIV-journey/BeforeYouStartPage";
import BloodSampleGuidePage from "./routes/get-self-test-kit-for-HIV-journey/BloodSampleGuidePage";
import CannotUseServiceUnder18Page from "./routes/get-self-test-kit-for-HIV-journey/CannotUseServiceUnder18Page";
import CheckYourAnswersPage from "./routes/get-self-test-kit-for-HIV-journey/CheckYourAnswersPage";
Expand Down Expand Up @@ -74,7 +75,11 @@ const router = createBrowserRouter([
children: [
{
path: RoutePath.HomePage,
element: <Navigate to={RoutePath.GetSelfTestKitPage} replace />,
element: <Navigate to={RoutePath.BeforeYouStartPage} replace />,
},
{
path: RoutePath.BeforeYouStartPage,
element: <BeforeYouStartPage />,
},
{
path: RoutePath.OrderTrackingPage,
Expand Down
1 change: 1 addition & 0 deletions ui/src/lib/models/route-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum RoutePath {
HomePage = "/",
LoginPage = "/login",
CallbackPage = "/callback",
BeforeYouStartPage = "/before-you-start",
GetSelfTestKitPage = "/get-self-test-kit-for-HIV",
OrderTrackingPage = "/orders/:orderId/tracking",
TestResultsPage = "/orders/:orderId/results",
Expand Down
Loading
Loading