Skip to content

Commit

Permalink
Improve discover historgram tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jul 17, 2020
1 parent 7e533f2 commit 8e27d7e
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
const log = getService('log');
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const elasticChart = getService('elasticChart');
Expand All @@ -34,7 +34,6 @@ export default function ({ getService, getPageObjects }) {

describe('discover histogram', function describeIndexTests() {
before(async function () {
log.debug('load kibana index with default index pattern');
await PageObjects.common.navigateToApp('settings');
await security.testUser.setRoles([
'kibana_admin',
Expand All @@ -46,13 +45,11 @@ export default function ({ getService, getPageObjects }) {
await esArchiver.load('visualize');
await esArchiver.load('discover');

log.debug('create long_window_logstash index pattern');
// NOTE: long_window_logstash load does NOT create index pattern
await PageObjects.settings.createIndexPattern('long-window-logstash-*');
await kibanaServer.uiSettings.replace(defaultSettings);
await browser.refresh();

log.debug('discover');
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('long-window-logstash-*');
// NOTE: For some reason without setting this relative time, the abs times will not fetch data.
Expand All @@ -65,31 +62,31 @@ export default function ({ getService, getPageObjects }) {
await security.testUser.restoreDefaults();
});

async function prepareTest(fromTime, toTime, interval) {
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval(interval);
await PageObjects.header.waitUntilLoadingHasFinished();
}

it('should visualize monthly data with different day intervals', async () => {
const fromTime = 'Nov 01, 2017 @ 00:00:00.000';
const toTime = 'Mar 21, 2018 @ 00:00:00.000';
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.setChartInterval('Month');
await PageObjects.header.waitUntilLoadingHasFinished();
await prepareTest(fromTime, toTime, 'Month');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
});
it('should visualize weekly data with within DST changes', async () => {
const fromTime = 'Mar 01, 2018 @ 00:00:00.000';
const toTime = 'May 01, 2018 @ 00:00:00.000';
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.setChartInterval('Week');
await PageObjects.header.waitUntilLoadingHasFinished();
await prepareTest(fromTime, toTime, 'Week');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
});
it('should visualize monthly data with different years Scaled to 30 days', async () => {
it('should visualize monthly data with different years scaled to 30 days', async () => {
const fromTime = 'Jan 01, 2010 @ 00:00:00.000';
const toTime = 'Mar 21, 2019 @ 00:00:00.000';

await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
await PageObjects.discover.setChartInterval('Day');
await PageObjects.header.waitUntilLoadingHasFinished();
await prepareTest(fromTime, toTime, 'Day');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
const chartIntervalIconTip = await PageObjects.discover.getChartIntervalWarningIcon();
Expand Down

0 comments on commit 8e27d7e

Please sign in to comment.