WIP Visualize tests. Moving getSpinerDone from DiscoverPage to HeaderPage.

This commit is contained in:
LeeDr 2015-11-20 11:47:35 -06:00
parent 43eb32b6d6
commit 3af604d9fb
14 changed files with 2172 additions and 9 deletions

View file

@ -0,0 +1,210 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
});
bdd.before(function () {
var fromTime = '2015-09-19 06:31:44.000';
var toTime = '2015-09-23 18:31:44.000';
return scenarioManager.reload('emptyKibana')
.then(function () {
common.debug('navigateTo');
return settingsPage.navigateTo();
})
.then(function () {
common.debug('createIndexPattern');
return settingsPage.createIndexPattern();
})
.then(function () {
common.debug('navigateToApp visualize');
return common.navigateToApp('visualize');
})
.then(function () {
return common.sleep(2000);
})
.then(function () {
common.debug('clickAreaChart');
return visualizePage.clickAreaChart();
})
.then(function clickNewSearch() {
common.debug('clickNewSearch');
return visualizePage.clickNewSearch();
})
.then(function clickTimepicker() {
common.debug('clickTimepicker');
return common.tryForTime(5000, function () {
return headerPage.clickTimepicker();
});
})
.then(function setAbsoluteRange() {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function collapseTimepicker() {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function clickBucket() {
common.debug('Click X-Axis');
return visualizePage.clickBucket('X-Axis');
})
.then(function selectAggregation() {
common.debug('Click Date Histogram');
return visualizePage.selectAggregation('Date Histogram');
})
.then(function getField() {
common.debug('Check field value');
return visualizePage.getField();
})
.then(function (fieldValue) {
common.debug('fieldValue = ' + fieldValue);
expect(fieldValue).to.be('@timestamp');
})
.then(function getInterval() {
return visualizePage.getInterval();
})
.then(function (intervalValue) {
common.debug('intervalValue = ' + intervalValue);
expect(intervalValue).to.be('Auto');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function getSpinnerDone() {
common.debug('Waiting...');
return headerPage.getSpinnerDone();
});
});
bdd.describe('area charts', function indexPatternCreation() {
bdd.it('should save and load, take screenshot', function pageHeader() {
var testSubName = 'AreaChart';
var vizName1 = 'Visualization ' + testSubName;
this.timeout = 60000;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function loadSavedVisualization() {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function getSpinnerDone() {
common.debug('Waiting...');
return headerPage.getSpinnerDone();
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct data', function pageHeader() {
this.timeout = 60000;
var expectedTableData = ['September 19th 2015, 18:00:00.000 15',
'September 19th 2015, 21:00:00.000 105', 'September 20th 2015, 00:00:00.000 518',
'September 20th 2015, 03:00:00.000 1,261', 'September 20th 2015, 06:00:00.000 1,485',
'September 20th 2015, 09:00:00.000 982', 'September 20th 2015, 12:00:00.000 322',
'September 20th 2015, 15:00:00.000 65', 'September 20th 2015, 18:00:00.000 29',
'September 20th 2015, 21:00:00.000 104', 'September 21st 2015, 00:00:00.000 483',
'September 21st 2015, 03:00:00.000 1,163', 'September 21st 2015, 06:00:00.000 1,507',
'September 21st 2015, 09:00:00.000 958', 'September 21st 2015, 12:00:00.000 317',
'September 21st 2015, 15:00:00.000 55', 'September 21st 2015, 18:00:00.000 17',
'September 21st 2015, 21:00:00.000 88', 'September 22nd 2015, 00:00:00.000 498',
'September 22nd 2015, 03:00:00.000 1,209', 'September 22nd 2015, 06:00:00.000 1,488',
'September 22nd 2015, 09:00:00.000 949', 'September 22nd 2015, 12:00:00.000 308',
'September 22nd 2015, 15:00:00.000 74', 'September 22nd 2015, 18:00:00.000 4'
];
return visualizePage.collapseChart()
.then(function setPageSize() {
return settingsPage.setPageSize('All');
})
.then(function getDataTableData() {
return visualizePage.getDataTableData();
})
.then(function showData(data) {
common.debug('getDataTableData = ' + data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedTableData);
})
.then(function collapseChart() {
return visualizePage.collapseChart();
})
.then(function sleep() {
return common.sleep(2000);
})
.catch(common.handleError(this));
});
bdd.it('should show correct chart', function pageHeader() {
this.timeout = 60000;
var chartHeight = 0;
var xAxisLabels = ['2015-09-19 19:00', '2015-09-20 19:00', '2015-09-21 19:00', '2015-09-22 19:00'];
var yAxisLabels = ['0','200','400','600','800','1,000','1,200','1,400','1,600'];
var expectedAreaChartData = [15, 105, 518, 1261, 1485, 982, 322, 65, 29,
104, 483, 1163, 1507, 958, 317, 55, 17, 88, 498, 1209, 1488, 949, 308, 74, 4
];
return visualizePage.getXAxisLabels()
.then(function (labels) {
common.debug('X-Axis labels = ' + labels);
expect(labels).to.eql(xAxisLabels);
})
.then(function getYAxisLabels() {
return visualizePage.getYAxisLabels();
})
.then(function (labels) {
common.debug('Y-Axis labels = ' + labels);
expect(labels).to.eql(yAxisLabels);
})
.then(function getAreaChartData() {
//return common.tryForTime(500, function () {
return visualizePage.getAreaChartData();
})
.then(function (paths) {
common.debug('expectedAreaChartData = ' + expectedAreaChartData);
common.debug('actual chart data = ' + paths);
expect(paths).to.eql(expectedAreaChartData);
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,58 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var settingsPage;
var visualizePage;
bdd.before(function () {
common = new Common(this.remote);
settingsPage = new SettingsPage(this.remote);
visualizePage = new VisualizePage(this.remote);
return scenarioManager.reload('emptyKibana')
.then(function () {
common.debug('navigateTo');
return settingsPage.navigateTo();
})
.then(function () {
common.debug('createIndexPattern');
return settingsPage.createIndexPattern();
})
.then(function () {
common.debug('navigateToApp visualize');
return common.navigateToApp('visualize');
})
.then(function () {
return common.sleep(2000);
});
});
bdd.describe('chart types', function indexPatternCreation() {
bdd.it('should show the correct chart types', function pageHeader() {
var expectedChartTypes = [
'Area chart', 'Data table', 'Line chart', 'Markdown widget',
'Metric', 'Pie chart', 'Tile map', 'Vertical bar chart'
];
// find all the chart types and make sure there all there
return visualizePage.getChartTypes()
.then(function testChartTypes(chartTypes) {
common.debug('returned chart types = ' + chartTypes);
common.debug('expected chart types = ' + expectedChartTypes);
expect(chartTypes).to.eql(expectedChartTypes);
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,118 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
var fromTime;
var toTime;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
fromTime = '2015-09-19 06:31:44.000';
toTime = '2015-09-23 18:31:44.000';
});
bdd.beforeEach(function () {
return visualizePage.clickDataTable()
.then(function clickNewSearch() {
return visualizePage.clickNewSearch();
})
.then(function clickTimepicker() {
return common.tryForTime(5000, function () {
return discoverPage.clickTimepicker();
});
})
.then(function setAbsoluteRange() {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function collapseTimepicker() {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function clickBucket() {
common.debug('Bucket = Split Rows');
return visualizePage.clickBucket('Split Rows');
})
.then(function selectAggregation() {
common.debug('Aggregation = Histogram');
return visualizePage.selectAggregation('Histogram');
})
.then(function selectField() {
common.debug('Field = bytes');
return visualizePage.selectField('bytes');
})
.then(function setInterval() {
common.debug('Interval = 2000');
return visualizePage.setNumericInterval('2000');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return headerPage.getSpinnerDone();
});
});
bdd.describe('data table', function indexPatternCreation() {
bdd.it('should be able to save and load, take screenshot', function pageHeader() {
var testSubName = 'DataTable';
var vizName1 = 'Visualization ' + testSubName;
this.timeout = 60000;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct data', function pageHeader() {
var chartHeight = 0;
var expectedChartData = [ '0 2,088', '2,000 2,748', '4,000 2,707', '6,000 2,876',
'8,000 2,863', '10,000 147', '12,000 148', '14,000 129', '16,000 161', '18,000 137'
];
this.timeout = 60000;
return visualizePage.getDataTableData()
.then(function showData(data) {
common.debug(data.split('\n'));
expect(data.split('\n')).to.eql(expectedChartData);
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,160 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
var fromTime = '2015-09-19 06:31:44.000';
var toTime = '2015-09-23 18:31:44.000';
return scenarioManager.reload('emptyKibana')
.then(function () {
common.debug('navigateTo');
return settingsPage.navigateTo();
})
.then(function () {
common.debug('createIndexPattern');
return settingsPage.createIndexPattern();
})
.then(function () {
common.debug('navigateToApp visualize');
return common.navigateToApp('visualize');
})
.then(function () {
return common.sleep(2000);
})
.then(function () {
common.debug('clickLineChart');
return visualizePage.clickLineChart();
})
.then(function clickNewSearch() {
return visualizePage.clickNewSearch();
})
.then(function sleep() {
return common.sleep(1000);
})
.then(function clickTimepicker() {
common.debug('Click time picker');
return headerPage.clickTimepicker();
})
.then(function setAbsoluteRange() {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function collapseTimepicker() {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function clickBucket() {
common.debug('Bucket = Split Chart');
return visualizePage.clickBucket('Split Chart');
})
.then(function selectAggregation() {
common.debug('Aggregation = Terms');
return visualizePage.selectAggregation('Terms');
})
.then(function selectField() {
common.debug('Field = extension');
return visualizePage.selectField('extension');
})
.then(function setInterval() {
common.debug('switch from Rows to Columns');
return visualizePage.clickColumns();
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return headerPage.getSpinnerDone(); // only matches the hidden spinner
});
});
bdd.describe('line charts', function indexPatternCreation() {
bdd.it('should be able to save and load, take screenshot', function pageHeader() {
var testSubName = 'LineChart';
common.debug('Start of test' + testSubName + 'Visualization');
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
// take a snapshot just as an example.
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct data', function pageHeader() {
var remote = this.remote;
var expectedChartData = ['jpg 9,109', 'css 2,159', 'png 1,373', 'gif 918', 'php 445'];
return visualizePage.collapseChart()
.then(function getDataTableData() {
return visualizePage.getDataTableData();
})
.then(function showData(data) {
common.debug(data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedChartData);
})
.catch(common.handleError(this));
});
bdd.it('should show correct chart', function pageHeader() {
this.timeout = 60000;
var remote = this.remote;
var expectedChartData = ['jpg 9,109', 'css 2,159', 'png 1,373', 'gif 918', 'php 445'];
return visualizePage.getLineChartData()
.then(function showData(data) {
var tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1%
for (var x = 0; x < data.length; x++) {
common.debug('x=' + x + ' expectedChartData[x].split(\' \')[1] = ' +
(expectedChartData[x].split(' ')[1]).replace(',', '') + ' data[x]=' + data[x] +
' diff=' + Math.abs(expectedChartData[x].split(' ')[1].replace(',', '') - data[x]));
expect(Math.abs(expectedChartData[x].split(' ')[1].replace(',', '') - data[x]) < tolerance).to.be.ok();
}
common.debug('Done');
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,339 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
var fromTime;
var toTime;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
fromTime = '2015-09-19 06:31:44.000';
toTime = '2015-09-23 18:31:44.000';
var testSubName = 'MetricChart';
common.debug('Start of test' + testSubName + 'Visualization');
var vizName1 = 'Visualization ' + testSubName;
this.timeout = 60000;
});
bdd.beforeEach(function () {
return visualizePage.clickMetric()
.then(function clickNewSearch() {
return visualizePage.clickNewSearch();
})
.then(function sleep() {
return common.sleep(1000);
})
.then(function clickTimepicker() {
common.debug('Click time picker');
return discoverPage.clickTimepicker();
})
.then(function setAbsoluteRange() {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function collapseTimepicker() {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
});
});
bdd.describe('metric chart', function indexPatternCreation() {
bdd.it('should show "Count"', function pageHeader() {
var expectedCount = ['14,004', 'Count'];
// initial metric of "Count" is selected by default
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(expectedCount).to.eql(metricValue.split('\n'));
});
});
});
bdd.it('should show "Average"', function pageHeader() {
var avgMachineRam = ['13,104,036,080.615', 'Average machine.ram'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Average');
return visualizePage.selectAggregation('Average');
})
.then(function selectField() {
common.debug('Field = machine.ram');
return visualizePage.selectField('machine.ram');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(avgMachineRam).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Sum"', function pageHeader() {
var sumPhpMemory = ['85,865,880', 'Sum of phpmemory'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Sum');
return visualizePage.selectAggregation('Sum');
})
.then(function selectField() {
common.debug('Field = phpmemory');
return visualizePage.selectField('phpmemory');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(sumPhpMemory).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Median"', function pageHeader() {
var medianBytes = ['5,565.263', '50th percentile of bytes'];
// For now, only comparing the text label part of the metric
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Median');
return visualizePage.selectAggregation('Median');
})
.then(function selectField() {
common.debug('Field = bytes');
return visualizePage.selectField('bytes');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
// only comparing the text label!
expect(medianBytes[1]).to.eql(metricValue.split('\n')[1]);
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Min"', function pageHeader() {
var minTimestamp = ['September 19th 2015, 19:00:00.000', 'Min @timestamp'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Min');
return visualizePage.selectAggregation('Min');
})
.then(function selectField() {
common.debug('Field = @timestamp');
return visualizePage.selectField('@timestamp');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(minTimestamp).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Max"', function pageHeader() {
var maxRelatedContentArticleModifiedTime = ['April 3rd 2015, 19:54:41.000', 'Max relatedContent.article:modified_time'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Max');
return visualizePage.selectAggregation('Max');
})
.then(function selectField() {
common.debug('Field = relatedContent.article:modified_time');
return visualizePage.selectField('relatedContent.article:modified_time');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(maxRelatedContentArticleModifiedTime).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Standard Deviation"', function pageHeader() {
var standardDeviationBytes = [ '-1,435.138', 'Lower Standard Deviation of bytes',
'5,727.314', 'Average of bytes', '12,889.766', 'Upper Standard Deviation of bytes'
];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Standard Deviation');
return visualizePage.selectAggregation('Standard Deviation');
})
.then(function selectField() {
common.debug('Field = bytes');
return visualizePage.selectField('bytes');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(standardDeviationBytes).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Unique Count"', function pageHeader() {
var uniqueCountClientip = ['1,000', 'Unique count of clientip'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Unique Count');
return visualizePage.selectAggregation('Unique Count');
})
.then(function selectField() {
common.debug('Field = clientip');
return visualizePage.selectField('clientip');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(uniqueCountClientip).to.eql(metricValue.split('\n'));
});
});
})
.then(function () {
return visualizePage.getMetric()
.then(function (metricValue) {
common.debug('metricValue=' + metricValue.split('\n'));
expect(uniqueCountClientip).to.eql(metricValue.split('\n'));
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Percentiles"', function pageHeader() {
var percentileMachineRam = ['2,147,483,648', '1st percentile of machine.ram', '3,221,225,472',
'5th percentile of machine.ram', '7,516,192,768', '25th percentile of machine.ram', '12,884,901,888',
'50th percentile of machine.ram', '18,253,611,008', '75th percentile of machine.ram',
'32,212,254,720', '95th percentile of machine.ram', '32,212,254,720', '99th percentile of machine.ram'
];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Percentiles');
return visualizePage.selectAggregation('Percentiles');
})
.then(function selectField() {
common.debug('Field = machine.ram');
return visualizePage.selectField('machine.ram');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(percentileMachineRam).to.eql(metricValue.split('\n'));
});
});
})
.catch(common.handleError(this));
});
bdd.it('should show "Percentile Ranks"', function pageHeader() {
var percentileRankBytes = [ '2.036%', 'Percentile rank 99 of "memory"'];
return visualizePage.clickMetricEditor()
.then(function () {
common.debug('Aggregation = Percentile Ranks');
return visualizePage.selectAggregation('Percentile Ranks');
})
.then(function selectField() {
common.debug('Field = bytes');
return visualizePage.selectField('memory');
})
.then(function selectField() {
common.debug('Values = 99');
return visualizePage.setValue('99');
})
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return common.tryForTime(2000, function () {
return visualizePage.getMetric()
.then(function (metricValue) {
expect(percentileRankBytes).to.eql(metricValue.split('\n'));
});
});
// })
// .then(function saveVisualization() {
// return visualizePage.saveVisualization(vizName1)
// .then(function (message) {
// common.debug('Saved viz message = ' + message);
// expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
// });
// })
// .then(function testVisualizeWaitForToastMessageGone() {
// return visualizePage.waitForToastMessageGone();
// })
// .then(function () {
// return visualizePage.loadSavedVisualization(vizName1)
// // take a snapshot just as an example. Probably need to change the location to save them...
// .takeScreenshot()
// .then(function (data) {
// fs.writeFileSync('./screenshot-' + testSubName + '.png', data);
// });
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,195 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
});
bdd.before(function () {
var fromTime = '2015-09-19 06:31:44.000';
var toTime = '2015-09-23 18:31:44.000';
return scenarioManager.reload('emptyKibana')
.then(function () {
common.debug('navigateTo');
return settingsPage.navigateTo();
})
.then(function () {
common.debug('createIndexPattern');
return settingsPage.createIndexPattern();
})
.then(function () {
common.debug('navigateToApp visualize');
return common.navigateToApp('visualize');
})
.then(function () {
return common.sleep(2000);
})
.then(function () {
common.debug('clickPieChart');
return visualizePage.clickPieChart();
})
.then(function () {
return visualizePage.clickNewSearch();
})
.then(function () {
common.debug('clickTimepicker');
return common.tryForTime(5000, function () {
return headerPage.clickTimepicker();
});
})
.then(function () {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function () {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function () {
common.debug('select bucket Split Slices');
return visualizePage.clickBucket('Split Slices');
})
.then(function () {
common.debug('Click aggregation Histogram');
return visualizePage.selectAggregation('Histogram');
})
.then(function () {
common.debug('Click field memory');
return visualizePage.selectField('memory');
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function sleep() {
return common.sleep(1003);
})
.then(function () {
common.debug('setNumericInterval 4000');
return visualizePage.setNumericInterval('40000');
})
.then(function () {
common.debug('clickGo');
return visualizePage.clickGo();
})
.then(function () {
return headerPage.getSpinnerDone();
});
});
bdd.describe('pie chart', function indexPatternCreation() {
bdd.it('should save and load, take screenshot', function pageHeader() {
var testSubName = 'PieChart';
common.debug('Start of test' + testSubName + 'Visualization');
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct data', function pageHeader() {
var remote = this.remote;
var expectedTableData = [ '0 55', '40,000 50', '80,000 41', '120,000 43',
'160,000 44', '200,000 40', '240,000 46', '280,000 39', '320,000 40', '360,000 47'
];
return visualizePage.collapseChart()
.then(function () {
return settingsPage.setPageSize('All');
})
.then(function getDataTableData() {
return visualizePage.getDataTableData();
})
.then(function showData(data) {
common.debug(data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedTableData);
})
// expandChart (toggle)
.then(function () {
return visualizePage.collapseChart();
})
.then(function sleep() {
return common.sleep(500);
})
.catch(common.handleError(this));
});
bdd.it('should show 10 slices in pie chart', function pageHeader() {
var remote = this.remote;
var expectedPieChartSliceCount = 10;
return visualizePage.getPieChartData()
.then(function (pieData) {
var barHeightTolerance = 1;
common.debug('pieData.length = ' + pieData.length);
expect(pieData.length).to.be(expectedPieChartSliceCount);
})
.catch(common.handleError(this));
});
bdd.it('should show correct pie chart', function pageHeader() {
var remote = this.remote;
var expectedPieChartData = [ 'M1.6578656043457293e-14,-270.75A270.75,270.75 0 0,1 189.75224728469635,-193.1311656631509L0,0Z',
'M189.75224728469635,-193.1311656631509A270.75,270.75 0 0,1 269.6964470665495,-23.861872090845115L0,0Z',
'M269.6964470665495,-23.861872090845115A270.75,270.75 0 0,1 238.80833406479468,127.57798431233117L0,0Z',
'M238.80833406479468,127.57798431233117A270.75,270.75 0 0,1 123.34351021859935,241.02269807417366L0,0Z',
'M123.34351021859935,241.02269807417366A270.75,270.75 0 0,1 -39.99314183930237,267.77996770823137L0,0Z',
'M-39.99314183930237,267.77996770823137A270.75,270.75 0 0,1 -177.10647583455636,204.78979153625724L0,0Z',
'M-177.10647583455636,204.78979153625724A270.75,270.75 0 0,1 -264.8995143221307,55.98044133355214L0,0Z',
'M-264.8995143221307,55.98044133355214A270.75,270.75 0 0,1 -255.0335453610437,-90.90353810813123L0,0Z',
'M-255.0335453610437,-90.90353810813123A270.75,270.75 0 0,1 -166.77401090750624,-213.28851770740727L0,0Z',
'M-166.77401090750624,-213.28851770740727A270.75,270.75 0 0,1 -4.973596813037188e-14,-270.75L0,0Z'
];
return visualizePage.getPieChartData()
.then(function (pieData) {
for (var x = 0; x < expectedPieChartData.length; x++) {
common.log('expected[' + x + '] = ' + expectedPieChartData[x] +
'\n actual = ' + pieData[x]
);
expect(expectedPieChartData[x]).to.be(pieData[x]);
}
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,133 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
var fromTime;
var toTime;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
fromTime = '2015-09-19 06:31:44.000';
toTime = '2015-09-23 18:31:44.000';
});
bdd.beforeEach(function () {
return visualizePage.clickTileMap()
.then(function () {
return visualizePage.clickNewSearch();
})
.then(function () {
return common.tryForTime(5000, function () {
return discoverPage.clickTimepicker();
});
})
.then(function () {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function () {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function () {
common.debug('select bucket Geo Coordinates');
return visualizePage.clickBucket('Geo Coordinates');
})
.then(function () {
common.debug('Click aggregation Geohash');
return visualizePage.selectAggregation('Geohash');
})
.then(function () {
common.debug('Click field geo.coordinates');
return common.tryForTime(1000, function () {
return visualizePage.selectField('geo.coordinates');
});
})
.then(function () {
return visualizePage.clickGo();
})
.then(function () {
return headerPage.getSpinnerDone();
});
});
bdd.describe('tile map chart', function indexPatternCreation() {
bdd.it('should save and load, take screenshot', function pageHeader() {
var testSubName = 'TileMap';
common.debug('Start of test' + testSubName + 'Visualization');
this.timeout = 60000;
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct tile map data', function pageHeader() {
var testSubName = 'TileMap';
common.debug('Start of test' + testSubName + 'Visualization');
this.timeout = 60000;
var remote = this.remote;
var expectedTableData = [ 'dn 1,429', 'dp 1,418', '9y 1,215', '9z 1,099', 'dr 1,076',
'dj 982', '9v 938', '9q 722', '9w 475', 'cb 457', 'c2 453', '9x 420', 'dq 399',
'9r 396', '9t 274', 'c8 271', 'dh 214', 'b6 207', 'bd 206', 'b7 167', 'f0 141',
'be 128', '9m 126', 'bf 85', 'de 73', 'bg 71', '9p 71', 'c1 57', 'c4 50', '9u 48',
'f2 46', '8e 45', 'b3 38', 'bs 36', 'c0 31', '87 28', 'bk 23', '8f 18', 'b5 14',
'84 14', 'dx 9', 'bu 9', 'b1 9', 'b4 6', '9n 3', '8g 3'
];
return visualizePage.collapseChart()
.then(function () {
return settingsPage.setPageSize('All');
})
.then(function getDataTableData() {
return visualizePage.getDataTableData()
.then(function showData(data) {
common.debug(data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedTableData);
});
})
.then(function () {
return visualizePage.collapseChart();
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,154 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var VisualizePage = require('../../../support/pages/VisualizePage');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('visualize app', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var visualizePage;
var remote;
var fromTime;
var toTime;
bdd.beforeEach(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
visualizePage = new VisualizePage(this.remote);
remote = this.remote;
fromTime = '2015-09-19 06:31:44.000';
toTime = '2015-09-23 18:31:44.000';
return visualizePage.clickVerticalBarChart()
.then(function clickNewSearch() {
return visualizePage.clickNewSearch();
})
.then(function sleep() {
return common.sleep(1000);
})
.then(function clickTimepicker() {
common.debug('Click time picker');
return discoverPage.clickTimepicker();
})
.then(function setAbsoluteRange() {
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"');
return headerPage.setAbsoluteRange(fromTime, toTime);
})
.then(function collapseTimepicker() {
common.debug('Collapse Time Picker pane');
return headerPage.collapseTimepicker();
})
.then(function clickBucket() {
common.debug('Bucket = X-Axis');
return visualizePage.clickBucket('X-Axis');
})
.then(function selectAggregation() {
common.debug('Aggregation = Date Histogram');
return visualizePage.selectAggregation('Date Histogram');
})
.then(function selectField() {
common.debug('Field = @timestamp');
return visualizePage.selectField('@timestamp');
})
// leaving Interval set to Auto
.then(function clickGo() {
return visualizePage.clickGo();
})
.then(function () {
return headerPage.getSpinnerDone(); // only matches the hidden spinner
})
.then(function sleep() {
return common.sleep(1000);
});
});
bdd.describe('vertical bar chart', function indexPatternCreation() {
bdd.it('should save and load, take screenshot', function pageHeader() {
var testSubName = 'VerticalBarChart';
common.debug('Start of test' + testSubName + 'Visualization');
this.timeout = 60000;
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});
bdd.it('should show correct data', function pageHeader() {
var testSubName = 'VerticalBarChart';
this.timeout = 60000;
// this is only the first page of the tabular data.
var expectedChartData = [ 'September 19th 2015, 18:00:00.000 15',
'September 19th 2015, 21:00:00.000 105',
'September 20th 2015, 00:00:00.000 518',
'September 20th 2015, 03:00:00.000 1,261',
'September 20th 2015, 06:00:00.000 1,485',
'September 20th 2015, 09:00:00.000 982',
'September 20th 2015, 12:00:00.000 322',
'September 20th 2015, 15:00:00.000 65',
'September 20th 2015, 18:00:00.000 29',
'September 20th 2015, 21:00:00.000 104'
];
return visualizePage.collapseChart()
.then(function showData(data) {
return visualizePage.getDataTableData();
})
.then(function showData(data) {
common.debug(data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedChartData);
})
.catch(common.handleError(this));
});
bdd.it('should show correct chart', function pageHeader() {
this.timeout = 60000;
var expectedChartValues = [15, 105, 518, 1261, 1485, 982, 322, 65, 29, 104,
483, 1163, 1507, 958, 317, 55, 17, 88, 498, 1209, 1488, 949, 308, 74, 4
];
return visualizePage.getBarChartData()
.then(function showData(data) {
common.debug('data=' + data);
common.debug('data.length=' + data.length);
expect(data).to.eql(expectedChartValues);
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -0,0 +1,70 @@
define(function (require) {
var bdd = require('intern!bdd');
var expect = require('intern/dojo/node!expect.js');
var config = require('intern').config;
var url = require('intern/dojo/node!url');
var _ = require('intern/dojo/node!lodash');
var Common = require('../../../support/pages/Common');
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var chartTypeTest = require('./_chart_types');
var areaChartTest = require('./_area_chart');
var lineChartTest = require('./_line_chart');
var dataTableTest = require('./_data_table');
var metricChartTest = require('./_metric_chart');
var pieChartTest = require('./_pie_chart');
var tileMapTest = require('./_tile_map');
var verticalBarChartTest = require('./_vertical_bar_chart');
bdd.describe('visualize app', function () {
var common;
var scenarioManager;
var remote;
var headerPage;
var settingsPage;
var scenarioManager = new ScenarioManager(url.format(config.servers.elasticsearch));
// on setup, we create an settingsPage instance
// that we will use for all the tests
bdd.before(function () {
common = new Common(this.remote);
remote = this.remote;
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
});
bdd.before(function () {
common.debug('running bdd.beforeEach');
this.timeout = 120000;
// start each test with an empty kibana index
return scenarioManager.reload('emptyKibana')
// and load a minimal set of makelogs data
.then(function loadIfEmptyMakelogs() {
return scenarioManager.loadIfEmpty('logstashFunctional');
});
});
// bdd.after(function unloadMakelogs() {
// return scenarioManager.unload('logstashFunctional');
// });
// chartTypeTest(bdd, scenarioManager); good
// areaChartTest(bdd, scenarioManager); // good
// lineChartTest(bdd, scenarioManager);
//
// dataTableTest(bdd, scenarioManager);
//
// metricChartTest(bdd, scenarioManager);
//
pieChartTest(bdd, scenarioManager);
//
// tileMapTest(bdd, scenarioManager);
//
// verticalBarChartTest(bdd);
});
});

View file

@ -15,7 +15,8 @@ define(function (require) {
functionalSuites: [
'test/functional/status_page/index',
'test/functional/apps/settings/index',
'test/functional/apps/discover/index'
'test/functional/apps/discover/index',
'test/functional/apps/visualize/index'
],
excludeInstrumentation: /(fixtures|node_modules)\//,
loaderOptions: {

View file

@ -61,11 +61,12 @@ define(function (require) {
var lastUrl = currentUrl;
return self.tryForTime(defaultTimeout, function () {
// give the app time to update the URL
return self.sleep(500)
return self.sleep(501)
.then(function () {
return self.remote.getCurrentUrl();
})
.then(function (currentUrl) {
self.debug('in doNavigation url = ' + currentUrl);
if (lastUrl !== currentUrl) {
lastUrl = currentUrl;
throw new Error('URL changed, waiting for it to settle');
@ -133,7 +134,7 @@ define(function (require) {
tryForTime: function (timeout, block) {
var self = this;
var start = Date.now();
var retryDelay = 500;
var retryDelay = 502;
var lastTry = 0;
var tempMessage;

View file

@ -111,11 +111,6 @@ define(function (require) {
.then(function () {
return barArray;
});
},
getSpinnerDone: function getSpinnerDone() {
common.debug('--getSpinner done method');
return thisTime.findByCssSelector('span.spinner.ng-hide');
}
};

View file

@ -123,8 +123,19 @@ define(function (require) {
}
});
});
}
},
getSpinnerDone: function getSpinnerDone() {
var self = this;
return this.remote
.setFindTimeout(defaultTimeout * 10)
.findByCssSelector('span.spinner.ng-hide');
// .then(function () {
// return self.remote
// .setFindTimeout(defaultTimeout * 10)
// .findByCssSelector('div.spinner.large.ng-hide');
// });
}
};

View file

@ -0,0 +1,718 @@
define(function (require) {
var registerSuite = require('intern!object');
var Common = require('./Common');
var defaultTimeout = 5000;
var common;
function VisualizePage(remote) {
this.remote = remote;
common = new Common(this.remote);
}
VisualizePage.prototype = {
constructor: VisualizePage,
clickAreaChart: function clickAreaChart() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Area chart')
.click();
},
clickDataTable: function clickDataTable() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Data table')
.click();
},
clickLineChart: function clickLineChart() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Line chart')
.click();
},
clickMarkdownWidget: function clickMarkdownWidget() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Markdown widget')
.click();
},
clickMetric: function clickMetric() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Metric')
.click();
},
clickPieChart: function clickPieChart() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Pie chart')
.click();
},
clickTileMap: function clickTileMap() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Tile map')
.click();
},
clickVerticalBarChart: function clickVerticalBarChart() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByPartialLinkText('Vertical bar chart')
.click();
},
//////////////////////////
getChartTypeCount: function getChartTypeCount() {
return this.remote
.setFindTimeout(defaultTimeout)
.findAllByCssSelector('a.wizard-vis-type.ng-scope')
.length;
},
getChartTypes: function getChartTypes() {
var types = [];
return this.remote
.setFindTimeout(defaultTimeout)
.findAllByCssSelector('a.wizard-vis-type.ng-scope h4')
.then(function (chartTypes) {
function getChartType(chart) {
return chart.getVisibleText();
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function (texts) {
return texts;
});
},
//
clickTimepicker: function clickTimepicker() {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByClassName('navbar-timepicker-time-desc')
.then(function (picker) {
return picker.click();
});
},
clickAbsoluteButton: function clickAbsoluteButton() {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByCssSelector('ul.nav.nav-pills.nav-stacked.kbn-timepicker-modes:contains("absolute")')
.click();
},
setFromTime: function setFromTime(timeString) {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByCssSelector('input[ng-model="absolute.from"]')
.type('\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' +
'\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' +
'\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + timeString);
},
setToTime: function setToTime(timeString) {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByCssSelector('input[ng-model="absolute.to"]')
.type('\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' +
'\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' +
'\b' + '\b' + '\b' + '\b' + '\b' + '\b' + '\b' + timeString);
},
clickGoButton: function clickGoButton() {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByClassName('kbn-timepicker-go')
.click();
},
setAbsoluteRange: function setAbsoluteRange(fromTime, toTime) {
var self = this;
common.debug('--Clicking Absolute button');
return self.clickAbsoluteButton()
.then(function () {
common.debug('--Setting From Time : ' + fromTime);
return self.setFromTime(fromTime);
})
.then(function () {
common.debug('--Setting To Time : ' + toTime);
return self.setToTime(toTime);
})
.then(function () {
return self.clickGoButton();
});
},
collapseChart: function collapseChart() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('div.visualize-show-spy > div > i')
.click();
},
collapseTimepicker: function collapseTimepicker() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('i.fa.fa-chevron-up')
.click();
},
getMetric: function getMetric() {
return this.remote
.setFindTimeout(defaultTimeout)
// .findByCssSelector('div[ng-repeat="metric in metrics"')
.findByCssSelector('div[ng-controller="KbnMetricVisController"]')
.getVisibleText();
},
clickMetricEditor: function clickMetricEditor() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('button[aria-label="Open Editor"]')
.click();
},
clickNewSearch: function clickNewSearch() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('li[ng-click="stepTwoMode=\'new\'"]')
.click();
},
setValue: function setValue(newValue) {
var self = this.remote;
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByCssSelector('button[ng-click="numberListCntr.add()"]')
.click()
.then(function () {
return self
.setFindTimeout(defaultTimeout)
.findByCssSelector('input[ng-model="numberListCntr.getList()[$index]"]')
.clearValue();
})
.then(function () {
return self
.setFindTimeout(defaultTimeout)
.findByCssSelector('input[ng-model="numberListCntr.getList()[$index]"]')
.type(newValue);
});
},
clickSavedSearch: function clickSavedSearch() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('li[ng-click="stepTwoMode=\'saved\'"]')
.click();
},
selectSearch: function selectSearch(searchName) {
return this.remote
.setFindTimeout(defaultTimeout)
.findByLinkText(searchName)
.click();
},
getErrorMessage: function getErrorMessage() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('.item>h4')
.getVisibleText();
},
// clickBucket(bucketType) 'X-Axis', 'Split Area', 'Split Chart'
clickBucket: function clickBucket(bucketName) {
return this.remote
.setFindTimeout(defaultTimeout)
.findAllByCssSelector('li.list-group-item.list-group-menu-item.ng-binding.ng-scope')
.then(function (chartTypes) {
common.debug('found bucket types ' + chartTypes.length);
function getChartType(chart) {
return chart
.getVisibleText()
.then(function (chartString) {
//common.debug(chartString);
if (chartString === bucketName) {
chart.click();
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
});
},
selectAggregation: function selectAggregation(myString) {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('option[label="' + myString + '"]')
.click();
},
getField: function getField() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('.ng-valid-required[name="field"] option[selected="selected"]')
.getVisibleText();
},
selectField: function selectField(fieldValue) {
return this.remote
.setFindTimeout(defaultTimeout)
// the css below should be more selective
.findByCssSelector('option[label="' + fieldValue + '"]')
.click();
},
orderBy: function orderBy(fieldValue) {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('select.form-control.ng-pristine.ng-valid.ng-untouched.ng-valid-required[ng-model="agg.params.orderBy"] ' +
'option.ng-binding.ng-scope:contains("' + fieldValue + '")'
)
.click();
},
getInterval: function getInterval() {
var self = this;
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('select[ng-model="agg.params.interval"]')
.getProperty('selectedIndex')
.then(function (selectedIndex) {
return self.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('select[ng-model="agg.params.interval"] option:nth-child(' + (selectedIndex + 1) + ')')
.getProperty('label');
});
},
setInterval: function setInterval(newValue) {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('select[ng-model="agg.params.interval"]')
.type(newValue);
},
setNumericInterval: function setNumericInterval(newValue) {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('input.form-control:nth-child(2)')
.type(newValue);
},
clickGo: function clickGo() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('.btn-success')
.click();
},
clickNewVisualization: function clickNewVisualization() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('button.ng-scope[aria-label="New Visualization"]')
.click();
},
saveVisualization: function saveVisualization(vizName) {
var self = this;
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('button.ng-scope[aria-label="Save Visualization"]')
.click()
.then(function () {
common.debug('saveButton button clicked');
return self.remote
.setFindTimeout(defaultTimeout)
.findByName('visTitle')
.type(vizName);
})
// // click save button
.then(function () {
return self.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('.btn-primary')
.click();
})
// verify that green message at the top of the page.
// it's only there for about 5 seconds
.then(function () {
return self.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('kbn-truncated.toast-message.ng-isolate-scope')
.getVisibleText();
});
},
// saved visualizations are paginated 5 to a page!
loadSavedVisualization: function loadSavedVisualization(vizName) {
var self = this;
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('button.ng-scope[aria-label="Load Saved Visualization"]')
.click()
.then(function findVizByLinkedText() {
common.debug('Load Saved Vis button clicked');
return self.remote
.setFindTimeout(defaultTimeout)
.findByLinkText(vizName)
.click()
.then(function getSpinnerDone() {
return self.getSpinnerDone(); // only matches the hidden spinners
})
.catch(function () {
common.debug('didn\'t find vis name on first page');
return;
});
});
},
getXAxisLabels: function getXAxisLabels() {
return this.remote
.setFindTimeout(defaultTimeout)
.findAllByCssSelector('.x > g')
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getVisibleText()
.then(function (theText) {
return theText;
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function (texts) {
// common.debug('returning types array ' + texts + ' array length =' + texts.length);
return texts;
});
},
getYAxisLabels: function getYAxisLabels() {
return this.remote
.setFindTimeout(defaultTimeout)
.findAllByCssSelector('.y > g')
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getVisibleText()
.then(function (theText) {
return theText;
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function (texts) {
// common.debug('returning types array ' + texts + ' array length =' + texts.length);
return texts;
});
},
/*
** This method gets the chart data and scales it based on chart height and label.
** Returns an array of height values
*/
getAreaChartData: function getAreaChartData() {
var self = this.remote;
var chartData = [];
var tempArray = [];
var chartSections = 0;
var chartMap = {};
var height = 0;
var yAxisLabel = 0;
var yAxisHeight = 0;
// 1). get the maximim chart Y-Axis marker value
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('div.y-axis-div-wrapper > div > svg > g > g:last-of-type')
.then(function setYAxisLabel(y) {
return y.getVisibleText();
})
.then(function (yLabel) {
yAxisLabel = yLabel.replace(',', '');
common.debug('yAxisLabel = ' + yAxisLabel);
return yLabel;
})
// 2). find and save the y-axis pixel size (the chart height)
.then(function () {
return self
.setFindTimeout(defaultTimeout)
.findByCssSelector('rect.background'); // different here
})
.then(function (chartAreaObj) {
return chartAreaObj.getAttribute('height');
})
.then(function (chartH) {
yAxisHeight = chartH;
common.debug('height --------- ' + yAxisHeight);
})
.then(function () {
return self.setFindTimeout(defaultTimeout * 2)
.findAllByCssSelector('path')
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getAttribute('data-label')
.then(function (chartString) {
//common.debug('data-label = ' + chartString);
if (chartString === 'Count') {
return chart.getAttribute('d')
.then(function (data) {
common.debug(data);
tempArray = data.split('L');
chartSections = tempArray.length / 2;
common.debug('chartSections = ' + chartSections + ' height = ' + yAxisHeight + ' yAxisLabel = ' + yAxisLabel);
chartData[0] = Math.round((yAxisHeight - tempArray[0].split(',')[1]) / yAxisHeight * yAxisLabel);
common.debug('chartData[0] =' + chartData[0]);
for (var i = 1; i < chartSections; i++) {
chartData[i] = Math.round((yAxisHeight - tempArray[i].split(',')[1]) / yAxisHeight * yAxisLabel);
common.debug('chartData[i] =' + chartData[i]);
}
return chartData;
});
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
});
})
.then(function (chartData) {
return chartData[1]; // MAGIC NUMBER - we find multiple 'path's and only one of them is the right one.
});
},
// The current test shows dots, not a line. This function gets the dots and normalizes their height.
getLineChartData: function getLineChartData() {
var self = this.remote;
var yAxisLabel = 0;
var yAxisHeight;
// 1). get the maximim chart Y-Axis marker value
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('div.y-axis-div-wrapper > div > svg > g > g:last-of-type')
.then(function setYAxisLabel(y) {
return y
.getVisibleText();
})
.then(function (yLabel) {
yAxisLabel = yLabel.replace(',', '');
common.debug('yAxisLabel = ' + yAxisLabel);
return yLabel;
})
// 2). find and save the y-axis pixel size (the chart height)
.then(function getRect() {
return self
.setFindTimeout(defaultTimeout)
.findByCssSelector('clipPath rect')
.then(function getRectHeight(chartAreaObj) {
return chartAreaObj
.getAttribute('height');
})
.then(function (theHeight) {
yAxisHeight = theHeight - 5; // MAGIC NUMBER - clipPath extends a bit above the top of the y-axis and below x-axis
common.debug('theHeight = ' + theHeight);
return theHeight;
});
})
// 3). get the chart-wrapper elements
.then(function getChartWrapper() {
return self
.setFindTimeout(defaultTimeout * 2)
.findAllByCssSelector('.chart-wrapper')
.then(function (chartTypes) {
// 5). for each chart element, find the green circle, then the cy position
function getChartType(chart) {
return chart
.findByCssSelector('circle[fill="#57c17b"]')
.then(function (circleObject) {
// common.debug('circleObject = ' + circleObject + ' yAxisHeight= ' + yAxisHeight + ' yAxisLabel= ' + yAxisLabel);
return circleObject
.getAttribute('cy');
})
.then(function (cy) {
// common.debug(' yAxisHeight=' + yAxisHeight + ' yAxisLabel=' + yAxisLabel + ' cy=' + cy +
// ' ((yAxisHeight - cy)/yAxisHeight * yAxisLabel)=' + ((yAxisHeight - cy) / yAxisHeight * yAxisLabel));
return Math.round((yAxisHeight - cy) / yAxisHeight * yAxisLabel);
});
}
// 4). pass the chartTypes to the getChartType function
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
});
})
.then(function (yCoords) {
return yCoords;
});
},
// this is ALMOST identical to DiscoverPage.getBarChartData
getBarChartData: function getBarChartData() {
var self = this.remote;
var yAxisLabel = 0;
var yAxisHeight;
// 1). get the maximim chart Y-Axis marker value
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('div.y-axis-div-wrapper > div > svg > g > g:last-of-type')
.then(function setYAxisLabel(y) {
return y
.getVisibleText()
.then(function (yLabel) {
yAxisLabel = yLabel.replace(',', '');
common.debug('yAxisLabel = ' + yAxisLabel);
return yLabel;
});
})
// 2). find and save the y-axis pixel size (the chart height)
.then(function getRect() {
return self
.setFindTimeout(defaultTimeout)
.findByCssSelector('rect.background')
.then(function getRectHeight(chartAreaObj) {
return chartAreaObj
.getAttribute('height')
.then(function (theHeight) {
yAxisHeight = theHeight; // - 5; // MAGIC NUMBER - clipPath extends a bit above the top of the y-axis and below x-axis
common.debug('theHeight = ' + theHeight);
return theHeight;
});
});
})
// 3). get the chart-wrapper elements
.then(function () {
return self
.setFindTimeout(defaultTimeout * 2)
// #kibana-body > div.content > div > div > div > div.vis-editor-canvas > visualize > div.visualize-chart > div > div.vis-col-wrapper > div.chart-wrapper > div > svg > g > g.series.\30 > rect:nth-child(1)
.findAllByCssSelector('svg > g > g.series.\\30 > rect') // rect
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getAttribute('fill')
.then(function (fillColor) {
// we're only getting the Green Bars
if (fillColor === '#57c17b') {
return chart
.getAttribute('height')
.then(function (barHeight) {
return Math.round(barHeight / yAxisHeight * yAxisLabel);
});
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function (bars) {
return bars;
});
});
},
// https://jbkflex.wordpress.com/2011/07/28/creating-a-svg-pie-chart-html5/
// http://www.w3.org/TR/SVG2/paths.html#PathDataEllipticalArcCommands
getPieChartData: function getPieChartData() {
var self = this.remote;
// 1). get the maximim chart Y-Axis marker value
return this.remote
.setFindTimeout(defaultTimeout * 2)
// path.slice:nth-child(11)
.findAllByCssSelector('path.slice')
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getAttribute('d')
.then(function (slice) {
return slice;
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function (slices) {
common.debug('slices=' + slices);
return slices;
});
},
getChartAreaWidth: function getChartAreaWidth() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('clipPath rect')
.getAttribute('width');
},
getChartAreaHeight: function getChartAreaHeight() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('clipPath rect')
.getAttribute('height');
},
getDataTableData: function getDataTableData() {
return this.remote
.setFindTimeout(defaultTimeout * 2)
.findByCssSelector('table.table.table-condensed tbody')
.getVisibleText();
},
clickColumns: function clickColumns() {
return this.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('div.schemaEditors.ng-scope > div > div > button:nth-child(2)')
.click();
},
waitForToastMessageGone: function waitForToastMessageGone() {
var self = this;
return common.tryForTime(defaultTimeout * 5, function tryingForTime() {
return self.remote
.setFindTimeout(100)
.findAllByCssSelector('kbn-truncated.toast-message.ng-isolate-scope')
.then(function toastMessage(messages) {
if (messages.length > 0) {
throw new Error('waiting for toast message to clear');
} else {
common.debug('now messages = 0 "' + messages + '"');
return messages;
}
});
});
}
};
return VisualizePage;
});