Skip to content

Commit faca345

Browse files
VIA-172 AJ Implemented the requirement of redirecting to NHS app homepage for mobile and the page for desktop version
1 parent 9097fd8 commit faca345

File tree

2 files changed

+24
-57
lines changed

2 files changed

+24
-57
lines changed

src/app/session-logout/page.test.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ describe("SessionLogout", () => {
1010
mockNHSAppJSFunctions(mockIsOpenInNHSApp, mockGoToHomePage);
1111
});
1212

13-
it("should show mobile version inside NHS App", () => {
13+
it("should show NHS App home page inside NHS App", () => {
1414
mockIsOpenInNHSApp.mockReturnValue(true);
1515
render(<SessionLogout />);
16-
const mobileButton = screen.getByRole("button", { name: "Log back in" });
17-
expect(mobileButton).toBeInTheDocument();
16+
expect(mockGoToHomePage).toHaveBeenCalledTimes(1);
1817
});
1918

20-
it("should show desktop version outside NHS App", () => {
19+
it("should show logged out page outside NHS App", () => {
2120
mockIsOpenInNHSApp.mockReturnValue(false);
2221
render(<SessionLogout />);
23-
const desktopButton = screen.getByRole("button", { name: "Continue" });
24-
expect(desktopButton).toBeInTheDocument();
22+
const heading = screen.getByRole("heading", {
23+
level: 1,
24+
name: "You have logged out",
25+
});
26+
expect(heading).toBeInTheDocument();
2527
});
2628
});

src/app/session-logout/page.tsx

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,27 @@
11
"use client";
22

3-
import { toNHSAppHomePage } from "@src/utils/navigation";
4-
import styles from "./styles.module.css";
53
import MainContent from "@src/app/_components/nhs-frontend/MainContent";
6-
import { useEffect, useState } from "react";
4+
import { useEffect } from "react";
75

86
const SessionLogout = () => {
9-
const [isOpenInNHSApp, setIsOpenInNHSApp] = useState(false);
10-
117
useEffect(() => {
12-
setIsOpenInNHSApp(window.nhsapp.tools.isOpenInNHSApp());
8+
if (window.nhsapp.tools.isOpenInNHSApp()) {
9+
window.nhsapp.navigation.goToHomePage();
10+
}
1311
}, []);
1412

15-
return isOpenInNHSApp ? (
16-
<>
17-
<MainContent>
18-
<title>You have been logged out</title>
19-
<div className={styles.logoutScreen}>
20-
<div className={styles.logoutBanner}>
21-
<h4>For your security, you need to login again.</h4>
22-
</div>
23-
<div className={styles.logoutContent}>
24-
<h1>You have logged out</h1>
25-
</div>
26-
<div className={styles.logBackInButton}>
27-
<button
28-
className="nhsuk-button nhsuk-button--reverse nhsapp-button"
29-
onClick={toNHSAppHomePage}
30-
>
31-
Log back in
32-
</button>
33-
</div>
34-
</div>
35-
</MainContent>
36-
</>
37-
) : (
38-
<>
39-
<MainContent>
40-
<title>You have been logged out</title>
41-
<h1>You have been logged out</h1>
42-
<p>
43-
For security, you&#39;re automatically logged out if you have not used
44-
the service for 10 minutes.
45-
</p>
46-
<p>
47-
If you were entering information, it has not been saved and you will
48-
need to re-enter it.
49-
</p>
50-
<div className={styles.continueButton}>
51-
<button
52-
className="nhsuk-button nhsapp-button"
53-
onClick={toNHSAppHomePage}
54-
>
55-
Continue
56-
</button>
57-
</div>
58-
</MainContent>
59-
</>
13+
return (
14+
<MainContent>
15+
<title>You have logged out</title>
16+
<h1>You have logged out</h1>
17+
<p>
18+
If you were entering information, it has not been saved and you will
19+
need to re-enter it.
20+
</p>
21+
<p>
22+
To continue, close the tab which has the service open and login again.
23+
</p>
24+
</MainContent>
6025
);
6126
};
6227

0 commit comments

Comments
 (0)