diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx index f321a54ec4dbe..54b81df96013d 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx @@ -27,7 +27,7 @@ import { initialState, databases } from 'src/SqlLab/fixtures'; const mockedProps = { queryEditorId: '123', animation: false, - database: databases.result[0], + database: { ...databases.result[0], allows_virtual_table_explore: false }, onUpdate: () => {}, onSave: () => {}, saveQueryWarning: null, @@ -61,6 +61,25 @@ const middlewares = [thunk]; const mockStore = configureStore(middlewares); describe('SavedQuery', () => { + it('doesnt render save button when allows_virtual_table_explore is undefined', async () => { + const noRenderProps = { + ...mockedProps, + database: { + ...mockedProps.database, + allows_virtual_table_explore: undefined, + }, + }; + render(, { + useRedux: true, + store: mockStore(mockState), + }); + expect(() => { + screen.getByRole('button', { name: /save/i }); + }).toThrow( + 'Unable to find an accessible element with the role "button" and name `/save/i`', + ); + }); + it('renders a non-split save button when allows_virtual_table_explore is not enabled', () => { render(, { useRedux: true, diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx index 4071b9e2d71d4..6ed0f4c668e7e 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx @@ -98,6 +98,8 @@ const SaveQuery = ({ const [showSaveDatasetModal, setShowSaveDatasetModal] = useState(false); const isSaved = !!query.remoteId; const canExploreDatabase = !!database?.allows_virtual_table_explore; + const shouldShowSaveButton = + database?.allows_virtual_table_explore !== undefined; const overlayMenu = ( @@ -180,10 +182,12 @@ const SaveQuery = ({ return ( - + {shouldShowSaveButton && ( + + )} setShowSaveDatasetModal(false)}