diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 987f7291296..a901995a389 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -197,6 +197,10 @@ beforeEach(() => { jest.clearAllMocks(); }); +beforeEach(() => { + window.history.pushState({}, 'Test page', '/dashboard?standalone=1'); +}); + test('should render', () => { const { container } = setup(); expect(container).toBeInTheDocument(); @@ -438,6 +442,36 @@ test('should NOT render MetadataBar when embedded', () => { ).not.toBeInTheDocument(); }); +test('should hide edit button and navbar, and show Exit fullscreen when in fullscreen mode', () => { + const fullscreenState = { + ...initialState, + dashboardState: { + ...initialState.dashboardState, + isFullscreenMode: true, + }, + }; + + setup(fullscreenState); + expect(screen.queryByTestId('edit-dashboard-button')).not.toBeInTheDocument(); + expect(screen.getByTestId('actions-trigger')).toBeInTheDocument(); + expect(screen.queryByTestId('main-navigation')).not.toBeInTheDocument(); +}); + +test('should show Exit fullscreen when in fullscreen mode', async () => { + setup(); + + fireEvent.click(screen.getByTestId('actions-trigger')); + + expect(await screen.findByText('Exit fullscreen')).toBeInTheDocument(); +}); + +test('should have fullscreen option in dropdown', async () => { + setup(); + await openActionsDropdown(); + expect(screen.getByText('Exit fullscreen')).toBeInTheDocument(); + expect(screen.queryByText('Enter fullscreen')).not.toBeInTheDocument(); +}); + test('should render MetadataBar when not in edit mode and not embedded', () => { const state = { dashboardInfo: { diff --git a/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx b/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx index 420e91e5524..ef58671faa8 100644 --- a/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx +++ b/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx @@ -97,11 +97,13 @@ export const useHeaderActionsMenu = ({ showPropertiesModal(); break; case MenuKeys.ToggleFullscreen: { + const isCurrentlyStandalone = + Number(getUrlParam(URL_PARAMS.standalone)) === 1; const url = getDashboardUrl({ pathname: window.location.pathname, filters: getActiveFilters(), hash: window.location.hash, - standalone: getUrlParam(URL_PARAMS.standalone), + standalone: isCurrentlyStandalone ? null : 1, }); window.location.replace(url); break;