diff --git a/superset-frontend/src/features/home/RightMenu.test.tsx b/superset-frontend/src/features/home/RightMenu.test.tsx
index bb4a40a53..50c0ca325 100644
--- a/superset-frontend/src/features/home/RightMenu.test.tsx
+++ b/superset-frontend/src/features/home/RightMenu.test.tsx
@@ -346,3 +346,30 @@ test('If there is NOT a DB with allow_file_upload set as True the option should
(await screen.findByText('Upload CSV to database')).closest('a'),
).not.toBeInTheDocument();
});
+
+test('Logs out and clears local storage item redux', async () => {
+ const mockedProps = createProps();
+ resetUseSelectorMock();
+ render(, {
+ useRedux: true,
+ useQueryParams: true,
+ useRouter: true,
+ });
+
+ // Set an item in local storage to test if it gets cleared
+ localStorage.setItem('redux', JSON.stringify({ test: 'test' }));
+ expect(localStorage.getItem('redux')).not.toBeNull();
+
+ userEvent.hover(await screen.findByText(/Settings/i));
+
+ // Simulate user clicking the logout button
+ await waitFor(() => {
+ const logoutButton = screen.getByText('Logout');
+ userEvent.click(logoutButton);
+ });
+
+ // Wait for local storage to be cleared
+ await waitFor(() => {
+ expect(localStorage.getItem('redux')).toBeNull();
+ });
+});
diff --git a/superset-frontend/src/features/home/RightMenu.tsx b/superset-frontend/src/features/home/RightMenu.tsx
index 93e03f5ed..99a139836 100644
--- a/superset-frontend/src/features/home/RightMenu.tsx
+++ b/superset-frontend/src/features/home/RightMenu.tsx
@@ -348,6 +348,10 @@ const RightMenu = ({
const handleDatabaseAdd = () => setQuery({ databaseAdded: true });
+ const handleLogout = () => {
+ localStorage.removeItem('redux');
+ };
+
const theme = useTheme();
return (
@@ -512,7 +516,7 @@ const RightMenu = ({
{t('Info')}
)}
-
+
{t('Logout')}
,