Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Dashboard doesn't display results if user navigates to open dashboard from discover" - Option 2 #64999

Merged
merged 6 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
});
}