set pause to 'true' when refresh interval is zero (#21498)

* set pause to 'true' when refresh interval is zero

* keep original assertion

* fix expect message in functional tests now that pause is set to true

* fix executorProvider mocha test
This commit is contained in:
Nathan Reese 2018-08-01 09:00:41 -06:00 committed by GitHub
parent 8f9bf6a3f6
commit f256748eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 5 deletions

View file

@ -76,8 +76,9 @@ class Timefilter extends SimpleEmitter {
setRefreshInterval = (refreshInterval) => {
// Object.assign used for partially composed updates
const newRefreshInterval = Object.assign(this.getRefreshInterval(), refreshInterval);
if (newRefreshInterval.value < 0) {
if (newRefreshInterval.value <= 0) {
newRefreshInterval.value = 0;
newRefreshInterval.pause = true;
}
if (areTimePickerValsDifferent(this.getRefreshInterval(), newRefreshInterval)) {
this._refreshInterval = {

View file

@ -131,7 +131,17 @@ describe('setRefreshInterval', () => {
test('should allow partial updates to refresh interval', () => {
timefilter.setRefreshInterval({ value: 10 });
expect(timefilter.getRefreshInterval()).to.eql({ pause: false, value: 10 });
expect(timefilter.getRefreshInterval()).to.eql({ pause: true, value: 10 });
});
test('should not allow negative intervals', () => {
timefilter.setRefreshInterval({ value: -10 });
expect(timefilter.getRefreshInterval()).to.eql({ pause: true, value: 0 });
});
test('should set pause to true when interval is zero', () => {
timefilter.setRefreshInterval({ value: 0, pause: false });
expect(timefilter.getRefreshInterval()).to.eql({ pause: true, value: 0 });
});
test('not emit anything if nothing has changed', () => {

View file

@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) {
let kibanaBaseUrl;
const urlQuery = `` +
`_g=(refreshInterval:(pause:!f,value:0),` +
`_g=(refreshInterval:(pause:!t,value:0),` +
`time:(from:'2012-11-17T00:00:00.000Z',mode:absolute,to:'2015-11-17T18:01:36.621Z'))&` +
`_a=(description:'',filters:!(),` +
`fullScreenMode:!f,` +

View file

@ -76,7 +76,7 @@ export default function ({ getService, getPageObjects }) {
const expectedUrl =
baseUrl +
'/app/kibana?_t=1453775307251#' +
'/discover?_g=(refreshInterval:(pause:!f,value:0),time' +
'/discover?_g=(refreshInterval:(pause:!t,value:0),time' +
':(from:\'2015-09-19T06:31:44.000Z\',mode:absolute,to:\'2015-09' +
'-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-' +
'*\',interval:auto,query:(language:lucene,query:\'\')' +

View file

@ -29,7 +29,6 @@ describe('$executor service', () => {
$timeout.cancel = (id) => clearTimeout(id);
timefilter.setRefreshInterval({
pause: false,
value: 0
});
@ -63,6 +62,7 @@ describe('$executor service', () => {
it('should call $timeout if the timefilter is not paused and set to 1000ms', () => {
timefilter.setRefreshInterval({
pause: false,
value: 1000
});
executor.start(scope);
@ -71,6 +71,7 @@ describe('$executor service', () => {
it('should execute function if timefilter is not paused and interval set to 1000ms', (done) => {
timefilter.setRefreshInterval({
pause: false,
value: 1000
});
executor.register({ execute: () => Promise.resolve().then(() => done(), done) });
@ -80,6 +81,7 @@ describe('$executor service', () => {
it('should execute function multiple times', (done) => {
let calls = 0;
timefilter.setRefreshInterval({
pause: false,
value: 10
});
executor.register({ execute: () => {
@ -91,6 +93,7 @@ describe('$executor service', () => {
it('should call handleResponse', (done) => {
timefilter.setRefreshInterval({
pause: false,
value: 10
});
executor.register({
@ -102,6 +105,7 @@ describe('$executor service', () => {
it('should call handleError', (done) => {
timefilter.setRefreshInterval({
pause: false,
value: 10
});
executor.register({