mirror of
https://github.com/apache/superset.git
synced 2026-04-16 22:55:52 +00:00
Implement a React-based table editor (#5186)
* A React table editor * addressing comments * Fix SelectAsyncControl error on clear * fix tests * more corrections * Removed <strong>
This commit is contained in:
committed by
GitHub
parent
aa14bac5c7
commit
68ba63fcd9
@@ -1,12 +1,9 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import $ from 'jquery';
|
||||
import * as chartActions from '../../../src/chart/chartAction';
|
||||
import * as actions from '../../../src/explore/actions/exploreActions';
|
||||
import { defaultState } from '../../../src/explore/store';
|
||||
import exploreReducer from '../../../src/explore/reducers/exploreReducer';
|
||||
import * as actions from '../../../src/explore/actions/exploreActions';
|
||||
|
||||
describe('reducers', () => {
|
||||
it('sets correct control value given a key and value', () => {
|
||||
@@ -20,65 +17,3 @@ describe('reducers', () => {
|
||||
expect(newState.controls.show_legend.value).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetching actions', () => {
|
||||
let dispatch;
|
||||
let request;
|
||||
let ajaxStub;
|
||||
|
||||
beforeEach(() => {
|
||||
dispatch = sinon.spy();
|
||||
ajaxStub = sinon.stub($, 'ajax');
|
||||
});
|
||||
afterEach(() => {
|
||||
ajaxStub.restore();
|
||||
});
|
||||
|
||||
describe('fetchDatasourceMetadata', () => {
|
||||
const datasourceKey = '1__table';
|
||||
|
||||
const makeRequest = (alsoTriggerQuery = false) => {
|
||||
request = actions.fetchDatasourceMetadata(datasourceKey, alsoTriggerQuery);
|
||||
request(dispatch);
|
||||
};
|
||||
|
||||
it('calls fetchDatasourceStarted', () => {
|
||||
makeRequest();
|
||||
expect(dispatch.args[0][0].type).to.equal(actions.FETCH_DATASOURCE_STARTED);
|
||||
});
|
||||
|
||||
it('makes the ajax request', () => {
|
||||
makeRequest();
|
||||
expect(ajaxStub.calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
it('calls correct url', () => {
|
||||
const url = `/superset/fetch_datasource_metadata?datasourceKey=${datasourceKey}`;
|
||||
makeRequest();
|
||||
expect(ajaxStub.getCall(0).args[0].url).to.equal(url);
|
||||
});
|
||||
|
||||
it('calls correct actions on error', () => {
|
||||
ajaxStub.yieldsTo('error', { responseJSON: { error: 'error text' } });
|
||||
makeRequest();
|
||||
expect(dispatch.callCount).to.equal(2);
|
||||
expect(dispatch.getCall(1).args[0].type).to.equal(actions.FETCH_DATASOURCE_FAILED);
|
||||
});
|
||||
|
||||
it('calls correct actions on success', () => {
|
||||
ajaxStub.yieldsTo('success', { data: '' });
|
||||
makeRequest();
|
||||
expect(dispatch.callCount).to.equal(4);
|
||||
expect(dispatch.getCall(1).args[0].type).to.equal(actions.SET_DATASOURCE);
|
||||
expect(dispatch.getCall(2).args[0].type).to.equal(actions.FETCH_DATASOURCE_SUCCEEDED);
|
||||
expect(dispatch.getCall(3).args[0].type).to.equal(actions.RESET_FIELDS);
|
||||
});
|
||||
|
||||
it('triggers query if flag is set', () => {
|
||||
ajaxStub.yieldsTo('success', { data: '' });
|
||||
makeRequest(true);
|
||||
expect(dispatch.callCount).to.equal(5);
|
||||
expect(dispatch.getCall(4).args[0].type).to.equal(chartActions.TRIGGER_QUERY);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user