functional tests for input control range (#42483)

* [apps/visualize] functional tests for input control range

* update jest test to have 100% combined coverage with functional
This commit is contained in:
Dmitry Lemeshko 2019-08-21 17:22:54 +02:00 committed by GitHub
parent a9032035b0
commit 9b9801f470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 572 additions and 6 deletions

View file

@ -88,6 +88,7 @@ exports[`renders ControlsTab 1`] = `
<EuiSelect
aria-label="Select control type"
compressed={false}
data-test-subj="selectControlType"
fullWidth={false}
hasNoInitialSelection={false}
isLoading={false}

View file

@ -136,6 +136,7 @@ class ControlsTabUi extends Component {
id="selectControlType"
>
<EuiSelect
data-test-subj="selectControlType"
options={[
{ value: 'range', text: intl.formatMessage({
id: 'inputControl.editor.controlsTab.select.rangeDropDownOptionLabel',

View file

@ -79,8 +79,8 @@ describe('RangeFilterManager', function () {
{
range: {
field1: {
gte: 1,
lte: 3
gt: 1,
lt: 3
}
}
}

View file

@ -29,7 +29,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
describe('visualize app', () => {
before(async () => {
log.debug('Starting visualize before method');
browser.setWindowSize(1280, 800);
await browser.setWindowSize(1280, 800);
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.loadIfNeeded('long_window_logstash');
await esArchiver.load('visualize');

View file

@ -22,5 +22,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./input_control_options'));
loadTestFile(require.resolve('./dynamic_options'));
loadTestFile(require.resolve('./chained_controls'));
loadTestFile(require.resolve('./input_control_range'));
});
}

View file

@ -0,0 +1,82 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const find = getService('find');
const { visualize } = getPageObjects(['visualize']);
describe('input control range', () => {
before(async () => {
await esArchiver.load('kibana_sample_data_flights_index_pattern');
await visualize.navigateToNewVisualization();
await visualize.clickInputControlVis();
});
it('should add filter with scripted field', async () => {
await visualize.addInputControl('range');
await visualize.setFilterParams({
indexPattern: 'kibana_sample_data_flights',
field: 'hour_of_day',
});
await visualize.clickGo();
await visualize.setFilterRange({
min: '7',
max: '10',
});
await visualize.inputControlSubmit();
const controlFilters = await find.allByCssSelector('[data-test-subj^="filter"]');
expect(controlFilters).to.have.length(1);
expect(await controlFilters[0].getVisibleText()).to.equal('hour_of_day: 7 to 10');
});
it('should add filter with price field', async () => {
await visualize.addInputControl('range');
await visualize.setFilterParams({
aggNth: 1,
indexPattern: 'kibana_sample_data_flights',
field: 'AvgTicketPrice',
});
await visualize.clickGo();
await visualize.setFilterRange({
aggNth: 1,
min: '400',
max: '999',
});
await visualize.inputControlSubmit();
const controlFilters = await find.allByCssSelector('[data-test-subj^="filter"]');
expect(controlFilters).to.have.length(2);
expect(await controlFilters[1].getVisibleText()).to.equal('AvgTicketPrice: $400 to $999');
});
after(async () => {
await esArchiver.unload('kibana_sample_data_flights_index_pattern');
// loading back default data
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.loadIfNeeded('long_window_logstash');
await esArchiver.load('visualize');
await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' });
});
});
}

View file

@ -0,0 +1,464 @@
{
"type": "index",
"value": {
"aliases": {
".kibana": {
}
},
"index": ".kibana_1",
"mappings": {
"_meta": {
"migrationMappingPropertyHashes": {
"config": "87aca8fdb053154f11383fce3dbf3edf",
"dashboard": "d00f614b29a80360e1190193fd333bab",
"index-pattern": "66eccb05066c5a89924f48a9e9736499",
"kql-telemetry": "d12a98a6f19a2d273696597547e064ee",
"migrationVersion": "4a1746014a75ade3a714e1db5763276f",
"namespace": "2f4316de49999235636386fe51dc06c1",
"references": "7997cf5a56cc02bdc9c93361bde732b0",
"sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4",
"search": "181661168bbadd1eff5902361e2a0d5c",
"server": "ec97f1c5da1a19609a60874e5af1100c",
"timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf",
"type": "2f4316de49999235636386fe51dc06c1",
"ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3",
"updated_at": "00da57df13e94e9d98437d13ace4bfe0",
"url": "c7f66a0df8b1b52f17c28c4adb111105",
"visualization": "52d7a13ad68a150c4525b292d23e12cc"
}
},
"dynamic": "strict",
"properties": {
"config": {
"dynamic": "true",
"properties": {
"buildNum": {
"type": "keyword"
},
"defaultIndex": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"dashboard": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"optionsJSON": {
"type": "text"
},
"panelsJSON": {
"type": "text"
},
"refreshInterval": {
"properties": {
"display": {
"type": "keyword"
},
"pause": {
"type": "boolean"
},
"section": {
"type": "integer"
},
"value": {
"type": "integer"
}
}
},
"timeFrom": {
"type": "keyword"
},
"timeRestore": {
"type": "boolean"
},
"timeTo": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"index-pattern": {
"properties": {
"fieldFormatMap": {
"type": "text"
},
"fields": {
"type": "text"
},
"intervalName": {
"type": "keyword"
},
"notExpandable": {
"type": "boolean"
},
"sourceFilters": {
"type": "text"
},
"timeFieldName": {
"type": "keyword"
},
"title": {
"type": "text"
},
"type": {
"type": "keyword"
},
"typeMeta": {
"type": "keyword"
}
}
},
"kql-telemetry": {
"properties": {
"optInCount": {
"type": "long"
},
"optOutCount": {
"type": "long"
}
}
},
"migrationVersion": {
"dynamic": "true",
"properties": {
"dashboard": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"index-pattern": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"search": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"visualization": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"namespace": {
"type": "keyword"
},
"references": {
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
},
"type": "nested"
},
"sample-data-telemetry": {
"properties": {
"installCount": {
"type": "long"
},
"unInstallCount": {
"type": "long"
}
}
},
"search": {
"properties": {
"columns": {
"type": "keyword"
},
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"sort": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"server": {
"properties": {
"uuid": {
"type": "keyword"
}
}
},
"timelion-sheet": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"timelion_chart_height": {
"type": "integer"
},
"timelion_columns": {
"type": "integer"
},
"timelion_interval": {
"type": "keyword"
},
"timelion_other_interval": {
"type": "keyword"
},
"timelion_rows": {
"type": "integer"
},
"timelion_sheet": {
"type": "text"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"type": {
"type": "keyword"
},
"ui-metric": {
"properties": {
"count": {
"type": "integer"
}
}
},
"updated_at": {
"type": "date"
},
"url": {
"properties": {
"accessCount": {
"type": "long"
},
"accessDate": {
"type": "date"
},
"createDate": {
"type": "date"
},
"url": {
"fields": {
"keyword": {
"ignore_above": 2048,
"type": "keyword"
}
},
"type": "text"
}
}
},
"visualization": {
"properties": {
"description": {
"type": "text"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"savedSearchRefName": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
},
"visState": {
"type": "text"
}
}
}
}
},
"settings": {
"index": {
"auto_expand_replicas": "0-1",
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}
{
"type": "index",
"value": {
"aliases": {
},
"index": "kibana_sample_data_flights",
"mappings": {
"properties": {
"AvgTicketPrice": {
"type": "float"
},
"Cancelled": {
"type": "boolean"
},
"Carrier": {
"type": "keyword"
},
"Dest": {
"type": "keyword"
},
"DestAirportID": {
"type": "keyword"
},
"DestCityName": {
"type": "keyword"
},
"DestCountry": {
"type": "keyword"
},
"DestLocation": {
"type": "geo_point"
},
"DestRegion": {
"type": "keyword"
},
"DestWeather": {
"type": "keyword"
},
"DistanceKilometers": {
"type": "float"
},
"DistanceMiles": {
"type": "float"
},
"FlightDelay": {
"type": "boolean"
},
"FlightDelayMin": {
"type": "integer"
},
"FlightDelayType": {
"type": "keyword"
},
"FlightNum": {
"type": "keyword"
},
"FlightTimeHour": {
"type": "keyword"
},
"FlightTimeMin": {
"type": "float"
},
"Origin": {
"type": "keyword"
},
"OriginAirportID": {
"type": "keyword"
},
"OriginCityName": {
"type": "keyword"
},
"OriginCountry": {
"type": "keyword"
},
"OriginLocation": {
"type": "geo_point"
},
"OriginRegion": {
"type": "keyword"
},
"OriginWeather": {
"type": "keyword"
},
"dayOfWeek": {
"type": "integer"
},
"timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"auto_expand_replicas": "0-1",
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

View file

@ -324,14 +324,18 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
return await find.byCssSelector('div.vgaVis__controls');
}
async addInputControl() {
async addInputControl(type) {
if (type) {
const selectInput = await testSubjects.find('selectControlType');
await selectInput.type(type);
}
await testSubjects.click('inputControlEditorAddBtn');
await PageObjects.header.waitUntilLoadingHasFinished();
}
async inputControlSubmit() {
await testSubjects.click('inputControlSubmitBtn');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.clickWhenNotDisabled('inputControlSubmitBtn');
await this.waitForVisualizationRenderingStabilized();
}
async inputControlClear() {
@ -1271,6 +1275,19 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
async removeDimension(agg) {
await testSubjects.click(`visEditorAggAccordion${agg} removeDimensionBtn`);
}
async setFilterParams({ aggNth = 0, indexPattern, field }) {
await comboBox.set(`indexPatternSelect-${aggNth}`, indexPattern);
await comboBox.set(`fieldSelect-${aggNth}`, field);
}
async setFilterRange({ aggNth = 0, min, max }) {
const control = await testSubjects.find(`inputControl${aggNth}`);
const inputMin = await control.findByCssSelector('[name$="minValue"]');
await inputMin.type(min);
const inputMax = await control.findByCssSelector('[name$="maxValue"]');
await inputMax.type(max);
}
}
return new VisualizePage();