fix: fix bug where dashboard did not enter fullscreen mode. (#32839)

This commit is contained in:
Levis Mbote
2025-04-07 18:20:49 +03:00
committed by GitHub
parent 629b137bb0
commit b6df88a134
2 changed files with 37 additions and 1 deletions

View File

@@ -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: {

View File

@@ -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;