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:47 UTC
[superset] branch elizabeth/sql-lab-saved-tabs created (now 6c246da)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a change to branch elizabeth/sql-lab-saved-tabs
in repository https://gitbox.apache.org/repos/asf/superset.git.
at 6c246da fix test for sqllab
This branch includes the following new commits:
new 6c246da fix test for sqllab
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: fix test for sqllab
Posted by hu...@apache.org.
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', () => {