You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/01/19 18:09:48 UTC
[superset] 01/01: fix test for sqllab
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch elizabeth/sql-lab-saved-tabs
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 6c246da95570cb4068c8aa69b16401541bafdb1e
Author: hughhhh <hu...@gmail.com>
AuthorDate: Tue Jan 19 13:08:51 2021 -0500
fix test for sqllab
---
.../spec/javascripts/sqllab/actions/sqlLab_spec.js | 40 +++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js
index c0ebbc2..8de12d1 100644
--- a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js
+++ b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js
@@ -26,6 +26,7 @@ import * as featureFlags from 'src/featureFlags';
import * as actions from 'src/SqlLab/actions/sqlLab';
import { defaultQueryEditor, query } from '../fixtures';
+import { ADD_TOAST } from 'src/messageToasts/actions';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
@@ -62,7 +63,12 @@ describe('async actions', () => {
describe('saveQuery', () => {
const saveQueryEndpoint = 'glob:*/savedqueryviewapi/api/create';
- fetchMock.post(saveQueryEndpoint, 'ok');
+ fetchMock.post(saveQueryEndpoint, { results: { json: {} } });
+
+ const makeRequest = () => {
+ const request = actions.saveQuery(query);
+ return request(dispatch);
+ };
it('posts to the correct url', () => {
expect.assertions(1);
@@ -83,6 +89,38 @@ describe('async actions', () => {
});
});
});
+
+ it('calls 3 dispatch actions', () => {
+ expect.assertions(1);
+
+ return makeRequest().then(() => {
+ expect(dispatch.callCount).toBe(3);
+ });
+ });
+
+ it('calls QUERY_EDITOR_SAVED after making a request', () => {
+ expect.assertions(1);
+
+ return makeRequest().then(() => {
+ expect(dispatch.args[0][0].type).toBe(actions.QUERY_EDITOR_SAVED);
+ });
+ });
+
+ it('onSave calls QUERY_EDITOR_SAVED and QUERY_EDITOR_SET_TITLE', () => {
+ expect.assertions(1);
+
+ const store = mockStore({});
+ const expectedActionTypes = [
+ actions.QUERY_EDITOR_SAVED,
+ ADD_TOAST,
+ actions.QUERY_EDITOR_SET_TITLE,
+ ];
+ return store.dispatch(actions.saveQuery(query)).then(() => {
+ expect(store.getActions().map(a => a.type)).toEqual(
+ expectedActionTypes,
+ );
+ });
+ });
});
describe('fetchQueryResults', () => {