Show clear and actionable query timeout error message (#2763)

* Show clear and actionable query timeout error message

1. Instead of waiting for a long time or server-side response 504 Gateway timeout, explore view now add a query timeout threshold. After timeout it will show specific querytimeout message.
2. fix alert box close button position.

* Show clear and actionable query timeout error message

1. Instead of waiting for a long time or server-side response 504 Gateway timeout, explore view now add a query timeout threshold. After timeout it will show specific querytimeout message.
2. fix alert box close button position.
3. fix a linting error.
This commit is contained in:
Grace Guo
2017-05-16 13:12:12 -07:00
committed by GitHub
parent 28ac3504d6
commit 960b26c7a2
9 changed files with 62 additions and 13 deletions

View File

@@ -1,6 +1,9 @@
import { it, describe } from 'mocha';
import { expect } from 'chai';
import sinon from 'sinon';
import $ from 'jquery';
import * as actions from '../../../javascripts/explorev2/actions/exploreActions';
import * as exploreUtils from '../../../javascripts/explorev2/exploreUtils';
import { defaultState } from '../../../javascripts/explorev2/stores/store';
import { exploreReducer } from '../../../javascripts/explorev2/reducers/exploreReducer';
@@ -16,3 +19,21 @@ describe('reducers', () => {
expect(newState.controls.show_legend.value).to.equal(true);
});
});
describe('runQuery', () => {
it('should handle query timeout', () => {
const dispatch = sinon.spy();
const urlStub = sinon.stub(exploreUtils, 'getExploreUrl', () => ('mockURL'));
const ajaxStub = sinon.stub($, 'ajax');
ajaxStub.yieldsTo('error', { statusText: 'timeout' });
const request = actions.runQuery({});
request(dispatch);
expect(dispatch.callCount).to.equal(2);
expect(dispatch.args[0][0].type).to.equal(actions.CHART_UPDATE_TIMEOUT);
urlStub.restore();
ajaxStub.restore();
});
});