This is an automated email from the ASF dual-hosted git repository. sadpandajoe pushed a commit to branch fix-dashboard-export-excludes-edit-panel in repository https://gitbox.apache.org/repos/asf/superset.git
commit 356617df9d1f6ace3e13e58a2eed37b2b2a1ea3c Author: Joe Li <[email protected]> AuthorDate: Fri Nov 13 00:15:04 2026 +0000 test(dashboard): add failing guard for edit-mode export capturing the builder pane The client-side Export to PDF / Download as Image actions capture the .dashboard element, which also contains the builder side pane while the dashboard is in edit mode. Add a header-menu test asserting those actions are unavailable in edit mode, with a view-mode control so it cannot pass vacuously. The edit-mode test fails until the fix is applied. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --- .../dashboard/components/Header/Header.test.tsx | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 3b6cbd1e6c8..43924b6c902 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -1384,3 +1384,47 @@ test.each(headerActionsMenuVisibilityCases)( window.featureFlags = {}; }, ); + +// The browser-side PDF / image export captures the `.dashboard` element. In +// edit mode that element also contains the builder side pane, so the export +// would include editing chrome. The client-side exports must therefore be +// unavailable while editing. +const openDownloadSubmenu = async () => { + await openActionsDropdown(); + await userEvent.hover(screen.getByText('Download')); + await screen.findByText('Export to PDF'); +}; + +// Without `can_csv` the export items are disabled for permission reasons, +// which would mask the edit-mode behavior under test. +const canExportState = { + user: { ...initialState.user, roles: { Admin: [['can_csv', 'Superset']] } }, +}; + +const menuItemFor = (label: string) => + screen.getByText(label).closest('[role="menuitem"]') as HTMLElement; + +test('client-side PDF and image exports are enabled outside edit mode', async () => { + window.featureFlags = {}; + setup(canExportState); + await openDownloadSubmenu(); + expect(menuItemFor('Export to PDF')).not.toHaveAttribute( + 'aria-disabled', + 'true', + ); + expect(menuItemFor('Download as Image')).not.toHaveAttribute( + 'aria-disabled', + 'true', + ); +}); + +test('client-side PDF and image exports are unavailable in edit mode', async () => { + window.featureFlags = {}; + setup({ ...editableState, ...canExportState }); + await openDownloadSubmenu(); + expect(menuItemFor('Export to PDF')).toHaveAttribute('aria-disabled', 'true'); + expect(menuItemFor('Download as Image')).toHaveAttribute( + 'aria-disabled', + 'true', + ); +});
