File tree Expand file tree Collapse file tree 4 files changed +60
-1
lines changed
Expand file tree Collapse file tree 4 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 1+ export const SESSION_TIMEOUT_ROUTE = "/session-timeout" ;
Original file line number Diff line number Diff line change 1+ import SessionTimeout from "@src/app/session-timeout/page" ;
2+ import { mockNHSAppJSFunctions } from "@src/utils/nhsapp-js.test" ;
3+ import { render , screen } from "@testing-library/react" ;
4+
5+ describe ( "SessionTimeout" , ( ) => {
6+ const mockIsOpenInNHSApp = jest . fn ( ) ;
7+ const mockGoToHomePage = jest . fn ( ) ;
8+
9+ beforeEach ( ( ) => {
10+ mockNHSAppJSFunctions ( mockIsOpenInNHSApp , mockGoToHomePage ) ;
11+ } ) ;
12+
13+ it ( "should show NHS App home page inside NHS App" , ( ) => {
14+ mockIsOpenInNHSApp . mockReturnValue ( true ) ;
15+ render ( < SessionTimeout /> ) ;
16+ expect ( mockGoToHomePage ) . toHaveBeenCalledTimes ( 1 ) ;
17+ } ) ;
18+
19+ it ( "should show timeout out page outside NHS App" , ( ) => {
20+ mockIsOpenInNHSApp . mockReturnValue ( false ) ;
21+ render ( < SessionTimeout /> ) ;
22+ const heading = screen . getByRole ( "heading" , {
23+ level : 1 ,
24+ name : "You have been logged out" ,
25+ } ) ;
26+ expect ( heading ) . toBeInTheDocument ( ) ;
27+ } ) ;
28+ } ) ;
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import MainContent from "@src/app/_components/nhs-frontend/MainContent" ;
4+ import { useEffect } from "react" ;
5+
6+ const SessionTimeout = ( ) => {
7+ useEffect ( ( ) => {
8+ if ( window . nhsapp . tools . isOpenInNHSApp ( ) ) {
9+ window . nhsapp . navigation . goToHomePage ( ) ;
10+ }
11+ } , [ ] ) ;
12+
13+ return (
14+ < MainContent >
15+ < title > You have been logged out</ title >
16+ < h1 > You have been logged out</ h1 >
17+ < p >
18+ For security reasons, you're automatically logged out if you have not used the service for 10 minutes.
19+ </ p >
20+ < p >
21+ If you were entering information, it has not been saved and you will need to re-enter it.
22+ </ p >
23+ < p >
24+ To continue, close the tab which has the service open and login again.
25+ </ p >
26+ </ MainContent >
27+ ) ;
28+ } ;
29+
30+ export default SessionTimeout ;
Original file line number Diff line number Diff line change @@ -28,6 +28,6 @@ export const config = {
2828 * 5. /favicon.ico (exclude the favicon path)
2929 * 6. /nhsuk-frontend-9.1.0 (exclude nhsuk js)
3030 */
31- "/((?!api/auth|api/sso|session-logout|sso-failure|favicon.ico|nhsuk-frontend-9.1.0|_next/static|_next/image).*)" ,
31+ "/((?!api/auth|api/sso|session-logout|session-timeout| sso-failure|favicon.ico|nhsuk-frontend-9.1.0|_next/static|_next/image).*)" ,
3232 ] ,
3333} ;
You can’t perform that action at this time.
0 commit comments