File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
frontend/src/components/NavBar/UserInfo Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const UserInfo = () => {
19
19
</ S . Wrapper >
20
20
}
21
21
>
22
- < DropdownItem href = " /logout" > Log out</ DropdownItem >
22
+ < DropdownItem href = { ` ${ window . basePath } /logout` } > Log out</ DropdownItem >
23
23
</ Dropdown >
24
24
) : null ;
25
25
} ;
Original file line number Diff line number Diff line change @@ -51,6 +51,23 @@ describe('UserInfo', () => {
51
51
expect ( logout ) . toBeInTheDocument ( ) ;
52
52
} ) ;
53
53
54
+ it ( 'should render logout link with correct context path' , async ( ) => {
55
+ const username = 'someName' ;
56
+ const baseUrl = '/tt-test01' ;
57
+ Object . defineProperty ( window , 'basePath' , {
58
+ value : baseUrl ,
59
+ writable : true ,
60
+ } ) ;
61
+ ( useUserInfo as jest . Mock ) . mockImplementation ( ( ) => ( { username } ) ) ;
62
+
63
+ renderComponent ( ) ;
64
+ const dropdown = screen . getByText ( username ) ;
65
+ await userEvent . click ( dropdown ) ;
66
+
67
+ const logout = screen . getByText ( 'Log out' ) ;
68
+ expect ( logout ) . toHaveAttribute ( 'href' , '/tt-test01/logout' ) ;
69
+ } ) ;
70
+
54
71
it ( 'should not render anything if the username does not exists' , ( ) => {
55
72
( useUserInfo as jest . Mock ) . mockImplementation ( ( ) => ( {
56
73
username : undefined ,
You can’t perform that action at this time.
0 commit comments