diff --git a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js index a3f7e5b8df4..0c424db35fb 100644 --- a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js +++ b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js @@ -613,7 +613,7 @@ describe('async actions', () => { describe('queryEditorSetSql', () => { describe('with backend persistence flag on', () => { - it('does not update the tab state in the backend', () => { + it('updates the tab state in the backend', () => { expect.assertions(2); const sql = 'SELECT * '; @@ -629,7 +629,7 @@ describe('async actions', () => { }); }); describe('with backend persistence flag off', () => { - it('updates the tab state in the backend', () => { + it('does not update the tab state in the backend', () => { const backendPersistenceOffMock = jest .spyOn(featureFlags, 'isFeatureEnabled') .mockImplementation( diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 56353ce1757..2cccb2e8992 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -949,6 +949,11 @@ export function queryEditorSetQueryLimit(queryEditor, queryLimit) { export function queryEditorSetTemplateParams(queryEditor, templateParams) { return function (dispatch) { + dispatch({ + type: QUERY_EDITOR_SET_TEMPLATE_PARAMS, + queryEditor, + templateParams, + }); const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) ? SupersetClient.put({ endpoint: encodeURI(`/tabstateview/${queryEditor.id}`), @@ -956,24 +961,16 @@ export function queryEditorSetTemplateParams(queryEditor, templateParams) { }) : Promise.resolve(); - return sync - .then(() => - dispatch({ - type: QUERY_EDITOR_SET_TEMPLATE_PARAMS, - queryEditor, - templateParams, - }), - ) - .catch(() => - dispatch( - addDangerToast( - t( - 'An error occurred while setting the tab template parameters. ' + - 'Please contact your administrator.', - ), + return sync.catch(() => + dispatch( + addDangerToast( + t( + 'An error occurred while setting the tab template parameters. ' + + 'Please contact your administrator.', ), ), - ); + ), + ); }; }