[Discover][Visualize] Fix visualizing a selected field in discover search (#61226) (#61407)

* Fix visualize a discover search

* Move deep clone into vis.ts

* Add functional tests

* Fix passing filters to visualize

* Revert fixing filters
This commit is contained in:
Daniil Suleiman 2020-03-26 13:23:41 +03:00 committed by GitHub
parent 8aeec54988
commit 7f3e5e6afa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 2 deletions

View file

@ -132,8 +132,10 @@ export class Vis {
this.data.savedSearchId = state.data.savedSearchId;
}
if (state.data && state.data.aggs) {
let configStates = state.data.aggs;
configStates = this.initializeDefaultsFromSchemas(configStates, this.type.schemas.all || []);
const configStates = this.initializeDefaultsFromSchemas(
cloneDeep(state.data.aggs),
this.type.schemas.all || []
);
if (!this.data.indexPattern) {
if (state.data.aggs.length) {
throw new Error('trying to initialize aggs without index pattern');

View file

@ -0,0 +1,80 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const inspector = getService('inspector');
const kibanaServer = getService('kibanaServer');
const log = getService('log');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
const defaultSettings = {
defaultIndex: 'logstash-*',
};
describe('discover field visualize button', () => {
before(async function() {
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
// and load a set of makelogs data
await esArchiver.loadIfNeeded('logstash_functional');
await kibanaServer.uiSettings.replace(defaultSettings);
});
beforeEach(async () => {
log.debug('go to discover');
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
});
it('should visualize a field in area chart', async () => {
await PageObjects.discover.clickFieldListItem('phpmemory');
log.debug('visualize a phpmemory field');
await PageObjects.discover.clickFieldListItemVisualize('phpmemory');
await PageObjects.header.waitUntilLoadingHasFinished();
const expectedTableData = [
['0', '10'],
['58,320', '2'],
['171,080', '2'],
['3,240', '1'],
['3,520', '1'],
['3,880', '1'],
['4,120', '1'],
['4,640', '1'],
['4,760', '1'],
['5,680', '1'],
['7,160', '1'],
['7,400', '1'],
['8,400', '1'],
['8,800', '1'],
['8,960', '1'],
['9,400', '1'],
['10,280', '1'],
['10,840', '1'],
['13,080', '1'],
['13,360', '1'],
];
await inspector.open();
await inspector.expectTableData(expectedTableData);
await inspector.close();
});
});
}

View file

@ -35,6 +35,7 @@ export default function({ getService, loadTestFile }) {
loadTestFile(require.resolve('./_saved_queries'));
loadTestFile(require.resolve('./_discover'));
loadTestFile(require.resolve('./_discover_histogram'));
loadTestFile(require.resolve('./_field_visualize'));
loadTestFile(require.resolve('./_filter_editor'));
loadTestFile(require.resolve('./_errors'));
loadTestFile(require.resolve('./_field_data'));