From 216ef477ce80c5018d143c17144aa50a6ab260bf Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 9 Jul 2020 14:42:06 +0200 Subject: [PATCH] [Discover] Improve Discover histogram time range tests (#71056) * Improve Discover histogram tests * Use includes function to find a string Co-authored-by: Elastic Machine --- test/functional/apps/discover/_discover.js | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 949a01ff7873..47741c1ab8a0 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -96,25 +96,32 @@ export default function ({ getService, getPageObjects }) { it('should modify the time range when a bar is clicked', async function () { await PageObjects.timePicker.setDefaultAbsoluteRange(); await PageObjects.discover.clickHistogramBar(); + await PageObjects.discover.waitUntilSearchingHasFinished(); const time = await PageObjects.timePicker.getTimeConfig(); expect(time.start).to.be('Sep 21, 2015 @ 09:00:00.000'); expect(time.end).to.be('Sep 21, 2015 @ 12:00:00.000'); - const rowData = await PageObjects.discover.getDocTableField(1); - expect(rowData).to.have.string('Sep 21, 2015 @ 11:59:22.316'); + await retry.waitFor('doc table to contain the right search result', async () => { + const rowData = await PageObjects.discover.getDocTableField(1); + log.debug(`The first timestamp value in doc table: ${rowData}`); + return rowData.includes('Sep 21, 2015 @ 11:59:22.316'); + }); }); it('should modify the time range when the histogram is brushed', async function () { await PageObjects.timePicker.setDefaultAbsoluteRange(); await PageObjects.discover.brushHistogram(); + await PageObjects.discover.waitUntilSearchingHasFinished(); const newDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); expect(Math.round(newDurationHours)).to.be(24); - const rowData = await PageObjects.discover.getDocTableField(1); - log.debug(`The first timestamp value in doc table: ${rowData}`); - expect(Date.parse(rowData)).to.be.within( - Date.parse('Sep 20, 2015 @ 17:30:00.000'), - Date.parse('Sep 20, 2015 @ 23:30:00.000') - ); + + await retry.waitFor('doc table to contain the right search result', async () => { + const rowData = await PageObjects.discover.getDocTableField(1); + log.debug(`The first timestamp value in doc table: ${rowData}`); + const dateParsed = Date.parse(rowData); + //compare against the parsed date of Sep 20, 2015 @ 17:30:00.000 and Sep 20, 2015 @ 23:30:00.000 + return dateParsed >= 1442770200000 && dateParsed <= 1442791800000; + }); }); it('should show correct initial chart interval of Auto', async function () {