fix(sqllab): autosync fail on migrated queryEditor (#26922)

This commit is contained in:
JUST.in DO IT 2024-01-31 11:19:55 -08:00 committed by GitHub
parent 4b85af2586
commit 62993c2fba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -477,6 +477,7 @@ export function migrateQueryEditorFromLocalStorage(
const newQueryEditor = { const newQueryEditor = {
...queryEditor, ...queryEditor,
id: json.id.toString(), id: json.id.toString(),
inLocalStorage: false,
}; };
dispatch({ dispatch({
type: MIGRATE_QUERY_EDITOR, type: MIGRATE_QUERY_EDITOR,

View File

@ -937,12 +937,17 @@ describe('async actions', () => {
{ ...query, id: 'previewTwo' }, { ...query, id: 'previewTwo' },
]; ];
const store = mockStore({}); const store = mockStore({});
const oldQueryEditor = { ...queryEditor, inLocalStorage: true };
const expectedActions = [ const expectedActions = [
{ {
type: actions.MIGRATE_QUERY_EDITOR, type: actions.MIGRATE_QUERY_EDITOR,
oldQueryEditor: queryEditor, oldQueryEditor,
// new qe has a different id // new qe has a different id
newQueryEditor: { ...queryEditor, id: '1' }, newQueryEditor: {
...oldQueryEditor,
id: '1',
inLocalStorage: false,
},
}, },
{ {
type: actions.MIGRATE_TAB_HISTORY, type: actions.MIGRATE_TAB_HISTORY,
@ -975,7 +980,7 @@ describe('async actions', () => {
return store return store
.dispatch( .dispatch(
actions.migrateQueryEditorFromLocalStorage( actions.migrateQueryEditorFromLocalStorage(
queryEditor, oldQueryEditor,
tables, tables,
queries, queries,
), ),