mirror of
https://github.com/apache/superset.git
synced 2026-07-16 11:46:09 +00:00
fix(sqllab): inactive leftbar selector on empty state (#38833)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user