Skip to content

Commit

Permalink
Final improvements on 12 new tests for 1 expression and 2 painless sc…
Browse files Browse the repository at this point in the history
…ripted fields
  • Loading branch information
LeeDr committed Dec 9, 2016
1 parent 4590fcb commit 7e85c64
Showing 1 changed file with 48 additions and 44 deletions.
92 changes: 48 additions & 44 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Tests for 3 scripted fields;
// 1. Lucene expression (number type)
// 2. Painless (number type)
// 3. Painless (string type)
//
// Each of these scripted fields has 4 tests (12 tests total);
// 1. Create scripted field
// 2. See the expected value of the scripted field in Discover doc view
// 3. Filter in Discover by the scripted field
// 4. Visualize with aggregation on the scripted field by clicking discover.clickFieldListItemVisualize

import expect from 'expect.js';

Expand All @@ -9,11 +19,11 @@ import {

import PageObjects from '../../../support/page_objects';

bdd.describe('creating and using scripted fields', function describeIndexTests() {
bdd.describe('creating and using Lucence expression scripted fields', function describeIndexTests() {

const scriptedExpressionFieldName = 'ram_expr1';

bdd.it('should create Lucence expression scripted field', async function () {
bdd.it('should create scripted field', async function () {
// delete .kibana index and then wait for Kibana to re-create it
await esClient.deleteAndUpdateConfigDoc();
await PageObjects.settings.navigateTo();
Expand All @@ -22,7 +32,6 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
await PageObjects.settings.clickScriptedFieldsTab();
await PageObjects.common.debug('add scripted field');
await PageObjects.settings
// .addScriptedField(scriptedExpressionFieldName, 'painless', 'number', null, '1', 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)');
.addScriptedField(scriptedExpressionFieldName,
'expression', 'number', null, '1', 'doc[\'machine.ram\'].value / (1024 * 1024 * 1024)'
);
Expand All @@ -31,7 +40,7 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
});
});

bdd.it('should see Lucence expression scripted field value in Discover', async function () {
bdd.it('should see scripted field value in Discover', async function () {
const fromTime = '2015-09-17 06:31:44.000';
const toTime = '2015-09-18 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
Expand All @@ -49,7 +58,7 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
expect(rowData).to.be('September 18th 2015, 16:08:20.320 30');
});

bdd.it('should filter by expression scripted field value in Discover', async function () {
bdd.it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedExpressionFieldName);
await PageObjects.common.debug('filter by the first value (14) in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedExpressionFieldName, '14');
Expand All @@ -60,20 +69,15 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
});
});

bdd.it('should visualize Lucence expression scripted field in vertical bar chart', async function () {
const expectedChartValues = [ 28, 28, 24, 23, 22, 22, 20, 20, 19, 18, 18, 17,
16, 15, 14, 13, 12, 12, 9, 9
bdd.it('should visualize scripted field in vertical bar chart', async function () {
const expectedChartValues = [ '10 29', '14 29', '12 24', '19 23', '7 22', '11 22', '17 20', '30 20',
'20 19', '13 18', '18 18', '6 17', '16 16', '5 15', '8 14', '2 13', '3 12', '15 12', '4 9', '9 9'
];
await PageObjects.discover.removeAllFilters();
await PageObjects.discover.clickFieldListItem(scriptedExpressionFieldName);
await PageObjects.discover.clickFieldListItemVisualize(scriptedExpressionFieldName);
await PageObjects.header.isGlobalLoadingIndicatorHidden();
await PageObjects.visualize.waitForVisualization();
// const data = await PageObjects.visualize.getBarChartData();
// await PageObjects.common.debug('data=' + data);
// await PageObjects.common.debug('data.length=' + data.length);
// await PageObjects.common.saveScreenshot('Visualize-vertical-bar-chart');
// expect(data).to.eql(expectedChartValues);
await PageObjects.visualize.collapseChart();
await PageObjects.settings.setPageSize('All');
var data = await PageObjects.visualize.getDataTableData();
Expand All @@ -84,10 +88,14 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
expect(data.trim().split('\n')).to.eql(expectedChartValues);
});

// ///////////////////////////////////////////////////
});

bdd.describe('creating and using Painless numeric scripted fields', function describeIndexTests() {

const scriptedExpressionFieldName = 'ram_expr1';
const scriptedPainlessFieldName = 'ram_Pain1';

bdd.it('should create Painless expression scripted field', async function () {
bdd.it('should create scripted field', async function () {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndicies();
await PageObjects.settings.clickScriptedFieldsTab();
Expand All @@ -99,7 +107,7 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
});
});

bdd.it('should see Lucence expression scripted field value in Discover', async function () {
bdd.it('should see scripted field value in Discover', async function () {
const fromTime = '2015-09-17 06:31:44.000';
const toTime = '2015-09-18 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
Expand All @@ -117,7 +125,7 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
expect(rowData).to.be('September 18th 2015, 16:08:20.320 30');
});

bdd.it('should filter by expression scripted field value in Discover', async function () {
bdd.it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
await PageObjects.common.debug('filter by the first value (14) in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName, '14');
Expand All @@ -128,20 +136,15 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
});
});

bdd.it('should visualize Lucence expression scripted field in vertical bar chart', async function () {
const expectedChartValues = [ 28, 28, 24, 23, 22, 22, 20, 20, 19, 18, 18, 17,
16, 15, 14, 13, 12, 12, 9, 9
bdd.it('should visualize scripted field in vertical bar chart', async function () {
const expectedChartValues = [ '10 29', '14 29', '12 24', '19 23', '7 22', '11 22', '17 20', '30 20',
'20 19', '13 18', '18 18', '6 17', '16 16', '5 15', '8 14', '2 13', '3 12', '15 12', '4 9', '9 9'
];
await PageObjects.discover.removeAllFilters();
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName);
await PageObjects.header.isGlobalLoadingIndicatorHidden();
await PageObjects.visualize.waitForVisualization();
// const data = await PageObjects.visualize.getBarChartData();
// await PageObjects.common.debug('data=' + data);
// await PageObjects.common.debug('data.length=' + data.length);
// await PageObjects.common.saveScreenshot('Visualize-vertical-bar-chart');
// expect(data).to.eql(expectedChartValues);
await PageObjects.visualize.collapseChart();
await PageObjects.settings.setPageSize('All');
var data = await PageObjects.visualize.getDataTableData();
Expand All @@ -152,24 +155,26 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
expect(data.trim().split('\n')).to.eql(expectedChartValues);
});

// ///////////////////////////////////////////////////
});

bdd.describe('creating and using Painless string scripted fields', function describeIndexTests() {

const scriptedPainlessFieldName2 = 'painString';

bdd.it('should create Painless expression scripted field', async function () {
bdd.it('should create scripted field', async function () {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndicies();
await PageObjects.settings.clickScriptedFieldsTab();
await PageObjects.common.debug('add scripted field');
await PageObjects.settings
.addScriptedField(scriptedPainlessFieldName2, 'painless', 'string', null, '1',
'if (doc[\'response.raw\'].value == \'200\') { return \'good\'} else { return \'bad\'}');
// 'if (doc[\'response.raw\'].value === 200) { return \'good\'} else { return \'bad\'}');
await PageObjects.common.try(async function() {
expect(await PageObjects.settings.getScriptedFieldsTabCount()).to.be('3');
});
});

bdd.it('should see Lucence expression scripted field value in Discover', async function () {
bdd.it('should see scripted field value in Discover', async function () {
const fromTime = '2015-09-17 06:31:44.000';
const toTime = '2015-09-18 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
Expand All @@ -187,20 +192,20 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
expect(rowData).to.be('September 18th 2015, 16:08:20.320 good');
});

// bdd.it('should filter by expression scripted field value in Discover', async function () {
// await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
// await PageObjects.common.debug('filter by the first value (14) in the expanded scripted field list');
// await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName2, 'bad');
// await PageObjects.header.isGlobalLoadingIndicatorHidden();
// await PageObjects.visualize.waitForVisualization();
// await PageObjects.common.try(async function() {
// expect(await PageObjects.discover.getHitCount()).to.be('29');
// });
// await PageObjects.discover.removeAllFilters();
// });

bdd.it('should visualize Lucence expression scripted field in vertical bar chart', async function () {
const expectedChartValues = [ 334, 25 ];
bdd.it('should filter by expression scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await PageObjects.common.debug('filter by "bad" in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName2, 'bad');
await PageObjects.header.isGlobalLoadingIndicatorHidden();
await PageObjects.visualize.waitForVisualization();
await PageObjects.common.try(async function() {
expect(await PageObjects.discover.getHitCount()).to.be('26');
});
await PageObjects.discover.removeAllFilters();
});

bdd.it('should visualize scripted field in vertical bar chart', async function () {
const expectedChartValues = [ 'good 341', 'bad 26' ];
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2);
await PageObjects.header.isGlobalLoadingIndicatorHidden();
Expand All @@ -211,7 +216,6 @@ bdd.describe('creating and using scripted fields', function describeIndexTests()
await PageObjects.common.debug('getDataTableData = ' + data.split('\n'));
await PageObjects.common.debug('data=' + data);
await PageObjects.common.debug('data.length=' + data.length);
// await PageObjects.common.saveScreenshot('Visualize-vertical-bar-chart');
expect(data.trim().split('\n')).to.eql(expectedChartValues);
});

Expand Down

0 comments on commit 7e85c64

Please sign in to comment.