Skip to content

Commit

Permalink
[Discover] Improve Discover histogram time range tests (elastic#71056)
Browse files Browse the repository at this point in the history
* Improve Discover histogram tests

* Use includes function to find a string

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
kertal and elasticmachine committed Jul 9, 2020
1 parent 7fa252b commit c3d8061
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,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 () {
Expand Down

0 comments on commit c3d8061

Please sign in to comment.