fix(sqllab): invalid dump sql shown after closing tab (#27295)

This commit is contained in:
JUST.in DO IT
2024-02-29 09:57:30 -08:00
committed by GitHub
parent d65f64d1ce
commit 8d245704ef
5 changed files with 91 additions and 6 deletions

View File

@@ -75,6 +75,25 @@ describe('sqlLabReducer', () => {
initialState.queryEditors.length,
);
});
it('should select the latest query editor when tabHistory is empty', () => {
const currentQE = newState.queryEditors[0];
newState = {
...initialState,
tabHistory: [initialState.queryEditors[0]],
};
const action = {
type: actions.REMOVE_QUERY_EDITOR,
queryEditor: currentQE,
};
newState = sqlLabReducer(newState, action);
expect(newState.queryEditors).toHaveLength(
initialState.queryEditors.length - 1,
);
expect(newState.queryEditors.map(qe => qe.id)).not.toContainEqual(
currentQE.id,
);
expect(newState.tabHistory).toEqual([initialState.queryEditors[2].id]);
});
it('should remove a query editor including unsaved changes', () => {
expect(newState.queryEditors).toHaveLength(
initialState.queryEditors.length + 1,