mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Backport PR #8654
--------- **Commit 1:** Improve readability of some functional tests Consistently use async/await and bring tests more in line with "Arrange, Act, Assert". * Original sha:db775687f2
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-11T16:48:37Z **Commit 2:** Simplify NoResultsTimefilter link test This reformulates the test case to a simple sequence of actions and assertions to improve maintainability. * Original sha:88c0b7b75e
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-11T17:34:24Z **Commit 3:** Replace and remove static sleep calls Any `sleep()` calls preceding a `verifyChartData()` call seem to be redundant, because `verifyChartData()` already uses `try()` to avoid flakyness due to timing. A few more assertions are now wrapped in `try()` calls to avoid occasional failures due to the timing of rendering. * Original sha:d4f717016f
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-12T10:12:25Z **Commit 4:** Extract expected values into separate variables to match convention * Original sha:a5fe202432
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-14T08:48:50Z **Commit 5:** Take screenshots after assertions The screenshots are now taken after the corresponding assertions are made to make sure they actually depict the expected ui state. * Original sha:956834430a
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-17T11:14:32Z **Commit 6:** Use let/const where appropriate * Original sha:731fe7924a
* Authored by Felix Stürmer <stuermer@weltenwort.de> on 2016-10-17T16:14:05Z
This commit is contained in:
parent
0259b89592
commit
02a5d8a16f
1 changed files with 143 additions and 224 deletions
|
@ -11,121 +11,93 @@ import {
|
|||
import PageObjects from '../../../support/page_objects';
|
||||
|
||||
bdd.describe('discover app', function describeIndexTests() {
|
||||
bdd.before(function () {
|
||||
var fromTime = '2015-09-19 06:31:44.000';
|
||||
var toTime = '2015-09-23 18:31:44.000';
|
||||
const fromTime = '2015-09-19 06:31:44.000';
|
||||
const fromTimeString = 'September 19th 2015, 06:31:44.000';
|
||||
const toTime = '2015-09-23 18:31:44.000';
|
||||
const toTimeString = 'September 23rd 2015, 18:31:44.000';
|
||||
|
||||
bdd.before(async function () {
|
||||
// delete .kibana index and update configDoc
|
||||
return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'})
|
||||
.then(function loadkibanaIndexPattern() {
|
||||
PageObjects.common.debug('load kibana index with default index pattern');
|
||||
return elasticDump.elasticLoad('visualize','.kibana');
|
||||
})
|
||||
await esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'});
|
||||
PageObjects.common.debug('load kibana index with default index pattern');
|
||||
await elasticDump.elasticLoad('visualize','.kibana');
|
||||
|
||||
// and load a set of makelogs data
|
||||
.then(function loadIfEmptyMakelogs() {
|
||||
return scenarioManager.loadIfEmpty('logstashFunctional');
|
||||
})
|
||||
.then(function () {
|
||||
PageObjects.common.debug('discover');
|
||||
return PageObjects.common.navigateToApp('discover');
|
||||
})
|
||||
.then(function () {
|
||||
PageObjects.common.debug('setAbsoluteRange');
|
||||
return PageObjects.header.setAbsoluteRange(fromTime, toTime);
|
||||
});
|
||||
await scenarioManager.loadIfEmpty('logstashFunctional');
|
||||
PageObjects.common.debug('discover');
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
PageObjects.common.debug('setAbsoluteRange');
|
||||
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
|
||||
});
|
||||
|
||||
|
||||
bdd.describe('query', function () {
|
||||
var queryName1 = 'Query # 1';
|
||||
var fromTimeString = 'September 19th 2015, 06:31:44.000';
|
||||
var toTimeString = 'September 23rd 2015, 18:31:44.000';
|
||||
const queryName1 = 'Query # 1';
|
||||
|
||||
bdd.it('should show correct time range string by timepicker', function () {
|
||||
var expectedTimeRangeString = fromTimeString + ' to ' + toTimeString;
|
||||
return PageObjects.discover.getTimespanText()
|
||||
.then(function (actualTimeString) {
|
||||
expect(actualTimeString).to.be(expectedTimeRangeString);
|
||||
bdd.it('should show correct time range string by timepicker', async function () {
|
||||
const actualTimeString = await PageObjects.discover.getTimespanText();
|
||||
|
||||
const expectedTimeString = `${fromTimeString} to ${toTimeString}`;
|
||||
expect(actualTimeString).to.be(expectedTimeString);
|
||||
});
|
||||
|
||||
bdd.it('save query should show toast message and display query name', async function () {
|
||||
await PageObjects.discover.saveSearch(queryName1);
|
||||
const toastMessage = await PageObjects.header.getToastMessage();
|
||||
|
||||
const expectedToastMessage = `Discover: Saved Data Source "${queryName1}"`;
|
||||
expect(toastMessage).to.be(expectedToastMessage);
|
||||
await PageObjects.common.saveScreenshot('Discover-save-query-toast');
|
||||
|
||||
await PageObjects.header.waitForToastMessageGone();
|
||||
const actualQueryNameString = await PageObjects.discover.getCurrentQueryName();
|
||||
|
||||
expect(actualQueryNameString).to.be(queryName1);
|
||||
});
|
||||
|
||||
bdd.it('load query should show query name', async function () {
|
||||
await PageObjects.discover.loadSavedSearch(queryName1);
|
||||
|
||||
await PageObjects.common.try(async function() {
|
||||
expect(await PageObjects.discover.getCurrentQueryName()).to.be(queryName1);
|
||||
});
|
||||
await PageObjects.common.saveScreenshot('Discover-load-query');
|
||||
});
|
||||
|
||||
bdd.it('should show the correct hit count', async function () {
|
||||
const expectedHitCount = '14,004';
|
||||
await PageObjects.common.try(async function() {
|
||||
expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('save query should show toast message and display query name', function () {
|
||||
var expectedSavedQueryMessage = 'Discover: Saved Data Source "' + queryName1 + '"';
|
||||
return PageObjects.discover.saveSearch(queryName1)
|
||||
.then(function () {
|
||||
return PageObjects.header.getToastMessage();
|
||||
})
|
||||
.then(function (toastMessage) {
|
||||
PageObjects.common.saveScreenshot('Discover-save-query-toast');
|
||||
expect(toastMessage).to.be(expectedSavedQueryMessage);
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.header.waitForToastMessageGone();
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.discover.getCurrentQueryName();
|
||||
})
|
||||
.then(function (actualQueryNameString) {
|
||||
expect(actualQueryNameString).to.be(queryName1);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('load query should show query name', function () {
|
||||
return PageObjects.discover.loadSavedSearch(queryName1)
|
||||
.then(function () {
|
||||
return PageObjects.common.sleep(3000);
|
||||
})
|
||||
.then(function () {
|
||||
return PageObjects.discover.getCurrentQueryName();
|
||||
})
|
||||
.then(function (actualQueryNameString) {
|
||||
PageObjects.common.saveScreenshot('Discover-load-query');
|
||||
expect(actualQueryNameString).to.be(queryName1);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should show the correct hit count', function () {
|
||||
var expectedHitCount = '14,004';
|
||||
return PageObjects.common.try(function tryingForTime() {
|
||||
return PageObjects.discover.getHitCount()
|
||||
.then(function compareData(hitCount) {
|
||||
expect(hitCount).to.be(expectedHitCount);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should show the correct bar chart', function () {
|
||||
var expectedBarChartData = [ '3.237',
|
||||
bdd.it('should show the correct bar chart', async function () {
|
||||
const expectedBarChartData = [ '3.237',
|
||||
'17.674', '64.75', '125.737', '119.962', '65.712', '16.449',
|
||||
'2.712', '3.675', '17.674', '59.762', '119.087', '123.812',
|
||||
'61.862', '15.487', '2.362', '2.800', '15.312', '61.862', '123.2',
|
||||
'118.562', '63.524', '17.587', '2.537'
|
||||
];
|
||||
return PageObjects.common.sleep(4000)
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
});
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show correct time range string in chart', function () {
|
||||
var expectedTimeRangeString = fromTimeString + ' - ' + toTimeString;
|
||||
return PageObjects.discover.getChartTimespan()
|
||||
.then(function (actualTimeString) {
|
||||
expect(actualTimeString).to.be(expectedTimeRangeString);
|
||||
});
|
||||
bdd.it('should show correct time range string in chart', async function () {
|
||||
const actualTimeString = await PageObjects.discover.getChartTimespan();
|
||||
|
||||
const expectedTimeString = `${fromTimeString} - ${toTimeString}`;
|
||||
expect(actualTimeString).to.be(expectedTimeString);
|
||||
});
|
||||
|
||||
bdd.it('should show correct initial chart interval of 3 hours', function () {
|
||||
var expectedChartInterval = 'by 3 hours';
|
||||
return PageObjects.discover.getChartInterval()
|
||||
.then(function (actualInterval) {
|
||||
expect(actualInterval).to.be(expectedChartInterval);
|
||||
});
|
||||
bdd.it('should show correct initial chart interval of 3 hours', async function () {
|
||||
const actualInterval = await PageObjects.discover.getChartInterval();
|
||||
|
||||
const expectedInterval = 'by 3 hours';
|
||||
expect(actualInterval).to.be(expectedInterval);
|
||||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Hourly', function () {
|
||||
var chartInterval = 'Hourly';
|
||||
var expectedBarChartData = [ '1.527', '2.290',
|
||||
bdd.it('should show correct data for chart interval Hourly', async function () {
|
||||
await PageObjects.discover.setChartInterval('Hourly');
|
||||
|
||||
const expectedBarChartData = [ '1.527', '2.290',
|
||||
'5.599', '7.890', '13.236', '30.290', '46.072', '55.490', '86.8',
|
||||
'112', '122.181', '131.6', '132.872', '113.527', '102.581',
|
||||
'81.709', '65.672', '43.781', '24.181', '14', '9.672', '6.109',
|
||||
|
@ -138,18 +110,12 @@ bdd.describe('discover app', function describeIndexTests() {
|
|||
'120.4', '96.472', '74.581', '70.509', '39.709', '25.199', '13.490',
|
||||
'12.472', '4.072', '2.290', '1.018'
|
||||
];
|
||||
return PageObjects.discover.setChartInterval(chartInterval)
|
||||
.then(function () {
|
||||
return PageObjects.common.sleep(4000);
|
||||
})
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
});
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Daily', async function () {
|
||||
var chartInterval = 'Daily';
|
||||
var expectedBarChartData = [
|
||||
const chartInterval = 'Daily';
|
||||
const expectedBarChartData = [
|
||||
'133.196', '129.192', '129.724'
|
||||
];
|
||||
await PageObjects.discover.setChartInterval(chartInterval);
|
||||
|
@ -159,120 +125,99 @@ bdd.describe('discover app', function describeIndexTests() {
|
|||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Weekly', async function () {
|
||||
var chartInterval = 'Weekly';
|
||||
var expectedBarChartData = [ '66.598', '129.458'];
|
||||
const chartInterval = 'Weekly';
|
||||
const expectedBarChartData = [ '66.598', '129.458'];
|
||||
|
||||
await PageObjects.discover.setChartInterval(chartInterval);
|
||||
await PageObjects.common.try(async () => {
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('browser back button should show previous interval Daily', function () {
|
||||
var expectedChartInterval = 'Daily';
|
||||
var expectedBarChartData = [
|
||||
bdd.it('browser back button should show previous interval Daily', async function () {
|
||||
const expectedChartInterval = 'Daily';
|
||||
const expectedBarChartData = [
|
||||
'133.196', '129.192', '129.724'
|
||||
];
|
||||
return this.remote.goBack()
|
||||
.then(function () {
|
||||
return PageObjects.common.try(function tryingForTime() {
|
||||
return PageObjects.discover.getChartInterval()
|
||||
.then(function (actualInterval) {
|
||||
expect(actualInterval).to.be(expectedChartInterval);
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
|
||||
await this.remote.goBack();
|
||||
await PageObjects.common.try(async function tryingForTime() {
|
||||
const actualInterval = await PageObjects.discover.getChartInterval();
|
||||
expect(actualInterval).to.be(expectedChartInterval);
|
||||
});
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Monthly', function () {
|
||||
var chartInterval = 'Monthly';
|
||||
var expectedBarChartData = [ '122.535'];
|
||||
return PageObjects.discover.setChartInterval(chartInterval)
|
||||
.then(function () {
|
||||
return PageObjects.common.sleep(2000);
|
||||
})
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
});
|
||||
bdd.it('should show correct data for chart interval Monthly', async function () {
|
||||
const chartInterval = 'Monthly';
|
||||
const expectedBarChartData = [ '122.535'];
|
||||
|
||||
await PageObjects.discover.setChartInterval(chartInterval);
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Yearly', function () {
|
||||
var chartInterval = 'Yearly';
|
||||
var expectedBarChartData = [ '122.535'];
|
||||
return PageObjects.discover.setChartInterval(chartInterval)
|
||||
.then(function () {
|
||||
return PageObjects.common.sleep(2000);
|
||||
})
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
});
|
||||
bdd.it('should show correct data for chart interval Yearly', async function () {
|
||||
const chartInterval = 'Yearly';
|
||||
const expectedBarChartData = [ '122.535'];
|
||||
|
||||
await PageObjects.discover.setChartInterval(chartInterval);
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show correct data for chart interval Auto', function () {
|
||||
var chartInterval = 'Auto';
|
||||
var expectedBarChartData = [ '3.237',
|
||||
bdd.it('should show correct data for chart interval Auto', async function () {
|
||||
const chartInterval = 'Auto';
|
||||
const expectedBarChartData = [ '3.237',
|
||||
'17.674', '64.75', '125.737', '119.962', '65.712', '16.449',
|
||||
'2.712', '3.675', '17.674', '59.762', '119.087', '123.812',
|
||||
'61.862', '15.487', '2.362', '2.800', '15.312', '61.862', '123.2',
|
||||
'118.562', '63.524', '17.587', '2.537'
|
||||
];
|
||||
return PageObjects.discover.setChartInterval(chartInterval)
|
||||
.then(function () {
|
||||
return PageObjects.common.sleep(4000);
|
||||
})
|
||||
.then(function () {
|
||||
return verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
await PageObjects.discover.setChartInterval(chartInterval);
|
||||
await verifyChartData(expectedBarChartData);
|
||||
});
|
||||
|
||||
bdd.it('should show Auto chart interval of 3 hours', function () {
|
||||
var expectedChartInterval = 'by 3 hours';
|
||||
return PageObjects.discover.getChartInterval()
|
||||
.then(function (actualInterval) {
|
||||
expect(actualInterval).to.be(expectedChartInterval);
|
||||
});
|
||||
bdd.it('should show Auto chart interval of 3 hours', async function () {
|
||||
const expectedChartInterval = 'by 3 hours';
|
||||
|
||||
const actualInterval = await PageObjects.discover.getChartInterval();
|
||||
expect(actualInterval).to.be(expectedChartInterval);
|
||||
});
|
||||
|
||||
bdd.it('should not show "no results"', () => {
|
||||
return PageObjects.discover.hasNoResults().then(visible => {
|
||||
expect(visible).to.be(false);
|
||||
});
|
||||
bdd.it('should not show "no results"', async () => {
|
||||
const isVisible = await PageObjects.discover.hasNoResults();
|
||||
expect(isVisible).to.be(false);
|
||||
});
|
||||
|
||||
function verifyChartData(expectedBarChartData) {
|
||||
return PageObjects.common.try(function tryingForTime() {
|
||||
return PageObjects.discover.getBarChartData()
|
||||
.then(function compareData(paths) {
|
||||
// the largest bars are over 100 pixels high so this is less than 1% tolerance
|
||||
var barHeightTolerance = 1;
|
||||
var stringResults = '';
|
||||
var hasFailure = false;
|
||||
for (var y = 0; y < expectedBarChartData.length; y++) {
|
||||
stringResults += y + ': expected = ' + expectedBarChartData[y] + ', actual = ' + paths[y] +
|
||||
', Pass = ' + (Math.abs(expectedBarChartData[y] - paths[y]) < barHeightTolerance) + '\n';
|
||||
if ((Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance)) {
|
||||
hasFailure = true;
|
||||
};
|
||||
async function verifyChartData(expectedBarChartData) {
|
||||
await PageObjects.common.try(async function tryingForTime() {
|
||||
const paths = await PageObjects.discover.getBarChartData();
|
||||
// the largest bars are over 100 pixels high so this is less than 1% tolerance
|
||||
const barHeightTolerance = 1;
|
||||
let stringResults = '';
|
||||
let hasFailure = false;
|
||||
for (let y = 0; y < expectedBarChartData.length; y++) {
|
||||
stringResults += y + ': expected = ' + expectedBarChartData[y] + ', actual = ' + paths[y] +
|
||||
', Pass = ' + (Math.abs(expectedBarChartData[y] - paths[y]) < barHeightTolerance) + '\n';
|
||||
if ((Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance)) {
|
||||
hasFailure = true;
|
||||
};
|
||||
if (hasFailure) {
|
||||
PageObjects.common.log(stringResults);
|
||||
PageObjects.common.log(paths);
|
||||
}
|
||||
for (var x = 0; x < expectedBarChartData.length; x++) {
|
||||
expect(Math.abs(expectedBarChartData[x] - paths[x]) < barHeightTolerance).to.be.ok();
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasFailure) {
|
||||
PageObjects.common.log(stringResults);
|
||||
PageObjects.common.log(paths);
|
||||
}
|
||||
for (let x = 0; x < expectedBarChartData.length; x++) {
|
||||
expect(Math.abs(expectedBarChartData[x] - paths[x]) < barHeightTolerance).to.be.ok();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bdd.describe('query #2, which has an empty time range', function () {
|
||||
var fromTime = '1999-06-11 09:22:11.000';
|
||||
var toTime = '1999-06-12 11:21:04.000';
|
||||
const fromTime = '1999-06-11 09:22:11.000';
|
||||
const toTime = '1999-06-12 11:21:04.000';
|
||||
|
||||
bdd.before(() => {
|
||||
PageObjects.common.debug('setAbsoluteRangeForAnotherQuery');
|
||||
|
@ -280,52 +225,26 @@ bdd.describe('discover app', function describeIndexTests() {
|
|||
.setAbsoluteRange(fromTime, toTime);
|
||||
});
|
||||
|
||||
bdd.it('should show "no results"', () => {
|
||||
return PageObjects.discover.hasNoResults().then(visible => {
|
||||
PageObjects.common.saveScreenshot('Discover-no-results');
|
||||
expect(visible).to.be(true);
|
||||
});
|
||||
bdd.it('should show "no results"', async () => {
|
||||
const isVisible = await PageObjects.discover.hasNoResults();
|
||||
expect(isVisible).to.be(true);
|
||||
await PageObjects.common.saveScreenshot('Discover-no-results');
|
||||
});
|
||||
|
||||
bdd.it('should suggest a new time range is picked', () => {
|
||||
return PageObjects.discover.hasNoResultsTimepicker().then(visible => {
|
||||
expect(visible).to.be(true);
|
||||
});
|
||||
bdd.it('should suggest a new time range is picked', async () => {
|
||||
const isVisible = await PageObjects.discover.hasNoResultsTimepicker();
|
||||
expect(isVisible).to.be(true);
|
||||
});
|
||||
|
||||
bdd.it('should open and close the time picker', () => {
|
||||
let i = 0;
|
||||
bdd.it('should have a link that opens and closes the time picker', async function() {
|
||||
const noResultsTimepickerLink = await PageObjects.discover.getNoResultsTimepicker();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(false);
|
||||
|
||||
return closeTimepicker() // close
|
||||
.then(() => isTimepickerOpen(false)
|
||||
.then(el => el.click()) // open
|
||||
.then(() => isTimepickerOpen(true))
|
||||
.then(el => el.click()) // close
|
||||
.then(() => isTimepickerOpen(false))
|
||||
.catch(PageObjects.common.createErrorHandler(this))
|
||||
);
|
||||
await noResultsTimepickerLink.click();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(true);
|
||||
|
||||
function closeTimepicker() {
|
||||
return PageObjects.header.isTimepickerOpen().then(shown => {
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
return PageObjects.discover
|
||||
.getNoResultsTimepicker()
|
||||
.click(); // close
|
||||
});
|
||||
}
|
||||
|
||||
function isTimepickerOpen(expected) {
|
||||
return PageObjects.header.isTimepickerOpen().then(shown => {
|
||||
PageObjects.common.debug(`expect (#${++i}) timepicker to be ${peek(expected)} (is ${peek(shown)}).`);
|
||||
expect(shown).to.be(expected);
|
||||
return PageObjects.discover.getNoResultsTimepicker();
|
||||
function peek(state) {
|
||||
return state ? 'open' : 'closed';
|
||||
}
|
||||
});
|
||||
}
|
||||
await noResultsTimepickerLink.click();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue