fix(sqllab): inactive leftbar selector on empty state (#38833)

This commit is contained in:
JUST.in DO IT
2026-03-26 08:57:16 -07:00
committed by GitHub
parent 43816d7528
commit cfa1aba1e0
6 changed files with 67 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ import {
} from 'src/SqlLab/fixtures';
import { SupersetClient, isFeatureEnabled } from '@superset-ui/core';
import { ADD_TOAST } from 'src/components/MessageToasts/actions';
import { EMPTY_STATE_QE_ID } from 'src/SqlLab/hooks/useQueryEditor';
import { ToastType } from '../../components/MessageToasts/types';
const isFeatureEnabledMock = isFeatureEnabled as unknown as jest.Mock;
@@ -882,6 +883,44 @@ describe('async actions', () => {
request(store.dispatch, store.getState, undefined);
expect(store.getActions()).toEqual(expectedActions);
});
test('creates a new query editor from the saved state in the empty tab', () => {
const unsavedEmptyTabState = {
id: EMPTY_STATE_QE_ID,
dbId: 2,
catalog: 'test_catalog',
schema: 'test_schema',
};
const store = mockStore({
...initialState,
sqlLab: {
...initialState.sqlLab,
tabHistory: [EMPTY_STATE_QE_ID],
unsavedQueryEditor: unsavedEmptyTabState,
},
});
const expectedActions = [
{
type: actions.ADD_QUERY_EDITOR,
queryEditor: {
id: 'abcd',
immutableId: 'abcd',
sql: expect.stringContaining('SELECT ...'),
name: 'Untitled Query 4',
dbId: unsavedEmptyTabState.dbId,
catalog: unsavedEmptyTabState.catalog,
schema: unsavedEmptyTabState.schema,
inLocalStorage: true,
autorun: false,
queryLimit: initialState.common.conf.DEFAULT_SQLLAB_LIMIT,
loaded: true,
},
},
];
const request = actions.addNewQueryEditor();
request(store.dispatch, store.getState, undefined);
expect(store.getActions()).toEqual(expectedActions);
});
});
});