fix(sqllab): autocomplete and delete tabs (#34781)

This commit is contained in:
JUST.in DO IT
2025-09-03 10:16:51 -07:00
committed by GitHub
parent b0d3f0f0d4
commit cefd046ea0
4 changed files with 32 additions and 15 deletions

View File

@@ -240,11 +240,13 @@ describe('sqlLabReducer', () => {
);
});
it('should migrate query editor by new query editor id', () => {
const { length } = newState.queryEditors;
const index = newState.queryEditors.findIndex(({ id }) => id === qe.id);
const newQueryEditor = {
...qe,
id: 'updatedNewId',
tabViewId: 'updatedNewId',
schema: 'updatedSchema',
inLocalStorage: false,
};
const action = {
type: actions.MIGRATE_QUERY_EDITOR,
@@ -252,8 +254,18 @@ describe('sqlLabReducer', () => {
newQueryEditor,
};
newState = sqlLabReducer(newState, action);
expect(newState.queryEditors[index].id).toEqual('updatedNewId');
expect(newState.queryEditors[index].id).toEqual(qe.id);
expect(newState.queryEditors[index].tabViewId).toEqual('updatedNewId');
expect(newState.queryEditors[index]).toEqual(newQueryEditor);
const removeAction = {
type: actions.REMOVE_QUERY_EDITOR,
queryEditor: newQueryEditor,
};
newState = sqlLabReducer(newState, removeAction);
expect(newState.queryEditors).toHaveLength(length - 1);
expect(Object.keys(newState.destroyedQueryEditors)).toContain(
newQueryEditor.tabViewId,
);
});
it('should clear the destroyed query editors', () => {
const expectedQEId = '1233289';