Skip to content

Commit d542c46

Browse files
FE: Auth: Fix context path for logout (#1258)
Co-authored-by: German Osin <[email protected]>
1 parent 5d6a71b commit d542c46

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

frontend/src/components/NavBar/UserInfo/UserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
};

frontend/src/components/NavBar/UserInfo/__tests__/UserInfo.spec.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)