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 = () => {
1919 </ S . Wrapper >
2020 }
2121 >
22- < DropdownItem href = " /logout" > Log out</ DropdownItem >
22+ < DropdownItem href = { ` ${ window . basePath } /logout` } > Log out</ DropdownItem >
2323 </ Dropdown >
2424 ) : null ;
2525} ;
Original file line number Diff line number Diff line change @@ -51,6 +51,23 @@ describe('UserInfo', () => {
5151 expect ( logout ) . toBeInTheDocument ( ) ;
5252 } ) ;
5353
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+
5471 it ( 'should not render anything if the username does not exists' , ( ) => {
5572 ( useUserInfo as jest . Mock ) . mockImplementation ( ( ) => ( {
5673 username : undefined ,
You can’t perform that action at this time.
0 commit comments