Skip to content

Commit

Permalink
Fix "Dashboard doesn't display results if user navigates to open dash…
Browse files Browse the repository at this point in the history
…board from discover" - Option 2 (#64999)

* Test which currently fails on 7.7 most times
* don’t delay search requests if `0` ms delay


Co-authored-by: LeeDr <lee.drengenberg@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored May 4, 2020
1 parent 9637a3e commit 7535d01
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/plugins/data/public/search/fetch/fetch_soon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('fetchSoon', () => {
(callClient as jest.Mock).mockClear();
});

test('should delay by 0ms if config is set to not batch searches', () => {
test('should execute asap if config is set to not batch searches', () => {
const config = getConfigStub({
'courier:batchSearches': false,
});
Expand All @@ -67,8 +67,6 @@ describe('fetchSoon', () => {

fetchSoon(request, options, { config } as FetchHandlers);

expect(callClient).not.toBeCalled();
jest.advanceTimersByTime(0);
expect(callClient).toBeCalled();
});

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/public/search/fetch/fetch_soon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ async function delayedFetch(
fetchHandlers: FetchHandlers,
ms: number
) {
if (ms === 0) {
return callClient([request], [options], fetchHandlers)[0];
}

const i = requestsToFetch.length;
requestsToFetch = [...requestsToFetch, request];
requestOptions = [...requestOptions, options];
Expand Down
123 changes: 123 additions & 0 deletions x-pack/test/functional/apps/dashboard/_async_dashboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
// import moment from 'moment';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
// const find = getService('find');
const log = getService('log');
// const security = getService('security');
const pieChart = getService('pieChart');
const renderable = getService('renderable');
// const dashboardExpect = getService('dashboardExpect');
const appMenu = getService('appsMenu');
const PageObjects = getPageObjects([
'common',
'header',
'home',
'discover',
'dashboard',
'timePicker',
]);

describe('sample data dashboard', function describeIndexTests() {
this.tags('smoke');

before(async () => {
// await security.testUser.setRoles(['kibana_admin', 'kibana_sample_admin', 'superuser']);
await PageObjects.common.sleep(5000);
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.addSampleDataSet('flights');
const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights');
expect(isInstalled).to.be(true);
// go to Discover, select flight data index, expand timespan to 1 yr
await appMenu.clickLink('Discover');
await PageObjects.discover.selectIndexPattern('kibana_sample_data_flights');
await PageObjects.timePicker.setCommonlyUsedTime('superDatePickerCommonlyUsed_Last_1 year');
await retry.try(async function() {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
});

after(async () => {
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
await PageObjects.home.removeSampleDataSet('flights');
const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights');
expect(isInstalled).to.be(false);
// await security.testUser.restoreDefaults();
});

it('should launch sample flights data set dashboard', async () => {
await appMenu.clickLink('Dashboard');
await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.timePicker.setCommonlyUsedTime('superDatePickerCommonlyUsed_Last_1 year');
await PageObjects.header.waitUntilLoadingHasFinished();

// check at least one visualization
await renderable.waitForRender();
log.debug('Checking pie charts rendered');
await pieChart.expectPieSliceCount(4);

await appMenu.clickLink('Discover');
await retry.try(async function() {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking pie charts rendered');
await pieChart.expectPieSliceCount(4);
});

it('toggle from Discover to Dashboard attempt 1', async () => {
await appMenu.clickLink('Discover');
await retry.try(async function() {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking pie charts rendered');
await pieChart.expectPieSliceCount(4);
});

it('toggle from Discover to Dashboard attempt 2', async () => {
await appMenu.clickLink('Discover');
await retry.try(async function() {
const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10);
expect(hitCount).to.be.greaterThan(0);
});
await appMenu.clickLink('Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
log.debug('Checking pie charts rendered');
await pieChart.expectPieSliceCount(4);
});

// since we're loading sameple data and not picking a time range which is guaranteed to
// contain all the sample data, we probably can't check all of these

// log.debug('Checking area, bar and heatmap charts rendered');
// await dashboardExpect.seriesElementCount(15);
// log.debug('Checking saved searches rendered');
// await dashboardExpect.savedSearchRowCount(50);
// log.debug('Checking input controls rendered');
// await dashboardExpect.inputControlItemCount(3);
// log.debug('Checking tag cloud rendered');
// await dashboardExpect.tagCloudWithValuesFound(['Sunny', 'Rain', 'Clear', 'Cloudy', 'Hail']);
// log.debug('Checking vega chart rendered');
// const tsvb = await find.existsByCssSelector('.vgaVis__view');
// expect(tsvb).to.be(true);
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default function({ loadTestFile }: FtrProviderContext) {

loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./preserve_url'));
loadTestFile(require.resolve('./_async_dashboard'));
});
}

0 comments on commit 7535d01

Please sign in to comment.