betodealmeida commented on a change in pull request #8060: SIP-23: Persist SQL 
Lab state in the backend
URL: 
https://github.com/apache/incubator-superset/pull/8060#discussion_r320987516
 
 

 ##########
 File path: superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
 ##########
 @@ -206,4 +228,502 @@ describe('async actions', () => {
       });
     });
   });
+
+  describe('cloneQueryToNewTab', () => {
+    it('creates new query editor', () => {
+      expect.assertions(1);
+
+      const id = 'id';
+      const state = {
+        tabHistory: [id],
+        queryEditors: [{ id, title: 'Dummy query editor' }],
+      };
+      const store = mockStore(state);
+      const expected = {
+        type: actions.ADD_QUERY_EDITOR,
+        queryEditor: {
+          title: 'Copy of Dummy query editor',
+          dbId: 1,
+          schema: null,
+          autorun: true,
+          sql: 'SELECT * FROM something',
+          queryLimit: undefined,
+          maxRow: undefined,
+        },
+      };
+      
expect(store.dispatch(actions.cloneQueryToNewTab(query))).toEqual(expected);
+    });
+  });
+
+  describe('addQueryEditor', () => {
+    let stub;
+    beforeEach(() => {
+      stub = sinon.stub(shortid, 'generate').returns('abcd');
+    });
+    afterEach(() => {
+      stub.restore();
+    });
+
+    it('creates new query editor', () => {
+      expect.assertions(1);
+
+      const store = mockStore({});
+      const expectedActions = [{
+        type: actions.ADD_QUERY_EDITOR,
+        queryEditor,
+      }];
+      return 
store.dispatch(actions.addQueryEditor(defaultQueryEditor)).then(() => {
+        expect(store.getActions()).toEqual(expectedActions);
+      });
+    });
+  });
+
+  describe('backend sync', () => {
+    const updateTabStateEndpoint = 'glob:*/tabstateview/*';
+    fetchMock.put(updateTabStateEndpoint, {});
+    fetchMock.delete(updateTabStateEndpoint, {});
+    fetchMock.post(updateTabStateEndpoint, JSON.stringify({ id: 1 }));
+
+    const updateTableSchemaEndpoint = 'glob:*/tableschemaview/*';
+    fetchMock.put(updateTableSchemaEndpoint, {});
+    fetchMock.delete(updateTableSchemaEndpoint, {});
+    fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 }));
+
+    const getTableMetadataEndpoint = 'glob:*/superset/table/*';
+    fetchMock.get(getTableMetadataEndpoint, {});
+    const getExtraTableMetadataEndpoint = 
'glob:*/superset/extra_table_metadata/*';
+    fetchMock.get(getExtraTableMetadataEndpoint, {});
+
+    let isFeatureEnabledMock;
+
+    beforeAll(() => {
+      isFeatureEnabledMock = jest.spyOn(featureFlags, 'isFeatureEnabled')
 
 Review comment:
   Will do, good point.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to