mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Added Discover app tests.
This commit is contained in:
parent
ed244f33a6
commit
050de6c923
4 changed files with 356 additions and 1 deletions
119
test/functional/apps/discover/_discover.js
Normal file
119
test/functional/apps/discover/_discover.js
Normal file
|
@ -0,0 +1,119 @@
|
|||
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 expect = require('intern/dojo/node!expect.js');
|
||||
//var Promise = require('bluebird');
|
||||
|
||||
return function (bdd) {
|
||||
bdd.describe('discover app', function describeIndexTests() {
|
||||
var common;
|
||||
var headerPage;
|
||||
var settingsPage;
|
||||
var discoverPage;
|
||||
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);
|
||||
remote = this.remote;
|
||||
fromTime = '2015-09-19 06:31:44.000';
|
||||
toTime = '2015-09-23 18:31:44.000';
|
||||
});
|
||||
|
||||
bdd.beforeEach(function be() {
|
||||
return settingsPage.createIndex()
|
||||
.then(function () {
|
||||
return headerPage.clickDiscover()
|
||||
.then(function () {
|
||||
return discoverPage.clickTimepicker();
|
||||
})
|
||||
.then(function () {
|
||||
return discoverPage.setAbsoluteRange(fromTime, toTime);
|
||||
})
|
||||
.then(function () {
|
||||
return discoverPage.collapseTimepicker();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// bdd.afterEach(function ae() {
|
||||
// return settingsPage.removeIndex();
|
||||
// });
|
||||
|
||||
|
||||
bdd.describe('query', function indexPatternCreation() {
|
||||
|
||||
bdd.it('should save and re-open', function pageHeader() {
|
||||
|
||||
// this.timeout = 80000;
|
||||
|
||||
var expectedTimeRangeString =
|
||||
'September 19th 2015, 06:31:44.000 to September 23rd 2015, 18:31:44.000';
|
||||
var queryName1 = 'Query # 1';
|
||||
|
||||
return discoverPage.getTimespanText()
|
||||
.then(function (actualTimeString) {
|
||||
common.debug('actualTimeString = ' + actualTimeString);
|
||||
expect(actualTimeString).to.be(expectedTimeRangeString);
|
||||
})
|
||||
.then(function () {
|
||||
return discoverPage.saveSearch(queryName1);
|
||||
})
|
||||
.then(function () {
|
||||
return common.sleep(2000);
|
||||
})
|
||||
.then(function () {
|
||||
common.debug('getCurrentQueryName');
|
||||
return common.tryForTime(5000, function () {
|
||||
return discoverPage.getCurrentQueryName()
|
||||
.then(function (actualQueryNameString) {
|
||||
expect(actualQueryNameString).to.be(queryName1);
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(common.handleError(this));
|
||||
});
|
||||
|
||||
|
||||
bdd.it('should show the correct bar chart', function pageHeader() {
|
||||
|
||||
// this.timeout = 80000;
|
||||
|
||||
var expectedBarChartData = [0,0,0,0,1.0968749999999972,7.6781250000000085,
|
||||
37.87875,92.210625,108.590625,71.80875,23.54625,4.753124999999997,
|
||||
2.1206249999999898,7.60499999999999,35.319374999999994,85.044375,110.199375,
|
||||
70.05375000000001,23.180625000000006,4.0218750000000085,1.2431250000000063,
|
||||
6.435000000000002,36.416250000000005,88.408125,108.81,
|
||||
69.395625,22.522499999999994,5.4112499999999955,0.29249999999998977,0,0,0,0,0,0,0,0];
|
||||
|
||||
return common.sleep(2000)
|
||||
.then(function () {
|
||||
common.debug(' Get Bar Chart data');
|
||||
return discoverPage.getBarChartData();
|
||||
})
|
||||
.then(function compareData(paths) {
|
||||
common.debug('Expected Bar Chart data = ' + expectedBarChartData);
|
||||
common.debug('Actual Bar Chart data = ' + paths);
|
||||
var barHeightTolerance = 1; // the largest bars are over 100 pixels high so this is less than 1% tolerance
|
||||
for (var x = 0; x < expectedBarChartData.size; x++) {
|
||||
common.debug(x + ' Expected: ' + expectedBarChartData[x] + ' Actual: ' +
|
||||
paths[x] + ' diff =' + (expectedBarChartData[x] - paths[x]) + '\n');
|
||||
expect(Math.abs(expectedBarChartData[x] - paths[x]) < barHeightTolerance).to.be.ok();
|
||||
}
|
||||
common.debug('Done');
|
||||
})
|
||||
.catch(common.handleError(this));
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
63
test/functional/apps/discover/index.js
Normal file
63
test/functional/apps/discover/index.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
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 pollUntil = require('intern/dojo/node!leadfoot/helpers/pollUntil');
|
||||
var discoverTest = require('./_discover');
|
||||
|
||||
bdd.describe('discover app', function () {
|
||||
var common;
|
||||
var scenarioManager;
|
||||
var remote;
|
||||
|
||||
// on setup, we create an settingsPage instance
|
||||
// that we will use for all the tests
|
||||
bdd.before(function () {
|
||||
common = new Common(this.remote);
|
||||
scenarioManager = new ScenarioManager(url.format(config.elasticsearch));
|
||||
remote = this.remote;
|
||||
});
|
||||
|
||||
bdd.beforeEach(function () {
|
||||
common.debug('running bdd.beforeEach');
|
||||
// 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');
|
||||
})
|
||||
.then(function () {
|
||||
return common.sleep(3000);
|
||||
})
|
||||
.then(function () {
|
||||
return common.tryForTime(25000, function () {
|
||||
return remote.get(url.format(_.assign(config.kibana, {
|
||||
pathname: ''
|
||||
})))
|
||||
.then(function () {
|
||||
// give angular enough time to update the URL
|
||||
return common.sleep(2000);
|
||||
})
|
||||
.then(function () {
|
||||
return remote.getCurrentUrl()
|
||||
.then(function (currentUrl) {
|
||||
expect(currentUrl).to.contain('settings');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// bdd.after(function unloadMakelogs() {
|
||||
// return scenarioManager.unload('logstashFunctional');
|
||||
// });
|
||||
|
||||
discoverTest(bdd);
|
||||
|
||||
});
|
||||
});
|
|
@ -14,7 +14,8 @@ define(function (require) {
|
|||
tunnelOptions: serverConfig.servers.webdriver,
|
||||
functionalSuites: [
|
||||
'test/functional/status_page/index',
|
||||
'test/functional/apps/settings/index'
|
||||
'test/functional/apps/settings/index',
|
||||
'test/functional/apps/discover/index'
|
||||
],
|
||||
excludeInstrumentation: /(fixtures|node_modules)\//,
|
||||
loaderOptions: {
|
||||
|
|
172
test/support/pages/DiscoverPage.js
Normal file
172
test/support/pages/DiscoverPage.js
Normal file
|
@ -0,0 +1,172 @@
|
|||
// in test/support/pages/DiscoverPage.js
|
||||
define(function (require) {
|
||||
// the page object is created as a constructor
|
||||
// so we can provide the remote Command object
|
||||
// at runtime
|
||||
var Common = require('./Common');
|
||||
|
||||
var defaultTimeout = 5000;
|
||||
var common;
|
||||
|
||||
function DiscoverPage(remote) {
|
||||
this.remote = remote;
|
||||
common = new Common(this.remote);
|
||||
}
|
||||
|
||||
DiscoverPage.prototype = {
|
||||
constructor: DiscoverPage,
|
||||
|
||||
clickTimepicker: function clickTimepicker() {
|
||||
return this.remote.setFindTimeout(defaultTimeout * 3)
|
||||
.findByClassName('navbar-timepicker-time-desc')
|
||||
.click();
|
||||
},
|
||||
|
||||
clickAbsoluteButton: function clickAbsoluteButton() {
|
||||
return this.remote.setFindTimeout(defaultTimeout * 2)
|
||||
.findByCssSelector('a[ng-click="setMode(\'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)
|
||||
.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();
|
||||
});
|
||||
},
|
||||
|
||||
collapseTimepicker: function collapseTimepicker() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('.fa.fa-chevron-up')
|
||||
.click();
|
||||
},
|
||||
|
||||
getQueryField: function getQueryField() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('input[ng-model=\'state.query\']');
|
||||
},
|
||||
|
||||
getQuerySearchButton: function getQuerySearchButton() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('button[aria-label=\'Search\']');
|
||||
},
|
||||
|
||||
getTimespanText: function getTimespanText() {
|
||||
return this.remote.setFindTimeout(defaultTimeout * 2)
|
||||
.findByCssSelector('a.navbar-timepicker-time-desc pretty-duration.ng-isolate-scope')
|
||||
.getVisibleText();
|
||||
},
|
||||
|
||||
saveSearch: function saveSearch(searchName) {
|
||||
var self = this;
|
||||
return self
|
||||
.clickSaveSearchButton()
|
||||
.then(function () {
|
||||
common.debug('--saveSearch button clicked');
|
||||
return self.remote.setFindTimeout(defaultTimeout)
|
||||
.findById('SaveSearch')
|
||||
.type(searchName);
|
||||
})
|
||||
// // click save button
|
||||
.then(function clickSave() {
|
||||
common.debug('--find save button');
|
||||
return self.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('button[ng-disabled="!opts.savedSearch.title"]')
|
||||
.click();
|
||||
});
|
||||
},
|
||||
|
||||
clickNewSearchButton: function clickNewSearchButton() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('button[aria-label="New Search"]')
|
||||
.click();
|
||||
},
|
||||
clickSaveSearchButton: function clickSaveSearchButton() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('button[aria-label="Save Search"]')
|
||||
.click();
|
||||
},
|
||||
|
||||
getCurrentQueryName: function getCurrentQueryName() {
|
||||
return this.remote.setFindTimeout(defaultTimeout)
|
||||
.findByCssSelector('span.discover-info-title')
|
||||
// .findByCssSelector('span[bo-bind="opts.savedSearch.title"]')
|
||||
.getVisibleText();
|
||||
},
|
||||
|
||||
getBarChartData: function getBarChartData() {
|
||||
// var barMap = {};
|
||||
var barArray = [];
|
||||
return this.remote.setFindTimeout(defaultTimeout * 2)
|
||||
.findAllByCssSelector('rect')
|
||||
.then(function (chartData) {
|
||||
|
||||
function getChartData(chart) {
|
||||
return chart.getAttribute('fill')
|
||||
.then(function (fillColor) {
|
||||
// we're only getting the Green Bars
|
||||
if (fillColor === '#57c17b') {
|
||||
return chart
|
||||
.getAttribute('height')
|
||||
.then(function (height) {
|
||||
// common.debug(': ' + height + ', ');
|
||||
barArray.push(height);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var getChartDataPromises = chartData.map(getChartData);
|
||||
return Promise.all(getChartDataPromises);
|
||||
})
|
||||
.then(function () {
|
||||
return barArray;
|
||||
});
|
||||
},
|
||||
|
||||
getSpinnerDone: function getSpinnerDone() {
|
||||
common.debug('--getSpinner done method');
|
||||
return this.remote.setFindTimeout(defaultTimeout * 3)
|
||||
.findByCssSelector('span.spinner.ng-hide');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
return DiscoverPage;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue