Skip to content

Commit

Permalink
Use TimeStrings interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Nov 15, 2021
1 parent 56fb343 commit 76745be
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions test/functional/apps/discover/_discover_histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
Expand Down Expand Up @@ -43,8 +44,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.common.unsetTime();
});

async function prepareTest(from: string, to: string, interval?: string) {
await PageObjects.common.setTime({ from, to });
async function prepareTest(time: TimeStrings, interval?: string) {
await PageObjects.common.setTime(time);
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
if (interval) {
Expand All @@ -54,32 +55,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
}

it('should visualize monthly data with different day intervals', async () => {
const fromTime = 'Nov 1, 2017 @ 00:00:00.000';
const toTime = 'Mar 21, 2018 @ 00:00:00.000';
await prepareTest(fromTime, toTime, 'Month');
const from = 'Nov 1, 2017 @ 00:00:00.000';
const to = 'Mar 21, 2018 @ 00:00:00.000';
await prepareTest({ from, to }, 'Month');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
});
it('should visualize weekly data with within DST changes', async () => {
const fromTime = 'Mar 1, 2018 @ 00:00:00.000';
const toTime = 'May 1, 2018 @ 00:00:00.000';
await prepareTest(fromTime, toTime, 'Week');
const from = 'Mar 1, 2018 @ 00:00:00.000';
const to = 'May 1, 2018 @ 00:00:00.000';
await prepareTest({ from, to }, 'Week');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
});
it('should visualize monthly data with different years scaled to 30 days', async () => {
const fromTime = 'Jan 1, 2010 @ 00:00:00.000';
const toTime = 'Mar 21, 2019 @ 00:00:00.000';
await prepareTest(fromTime, toTime, 'Day');
const from = 'Jan 1, 2010 @ 00:00:00.000';
const to = 'Mar 21, 2019 @ 00:00:00.000';
await prepareTest({ from, to }, 'Day');
const chartCanvasExist = await elasticChart.canvasExists();
expect(chartCanvasExist).to.be(true);
const chartIntervalIconTip = await PageObjects.discover.getChartIntervalWarningIcon();
expect(chartIntervalIconTip).to.be(true);
});
it('should allow hide/show histogram, persisted in url state', async () => {
const fromTime = 'Jan 1, 2010 @ 00:00:00.000';
const toTime = 'Mar 21, 2019 @ 00:00:00.000';
await prepareTest(fromTime, toTime);
const from = 'Jan 1, 2010 @ 00:00:00.000';
const to = 'Mar 21, 2019 @ 00:00:00.000';
await prepareTest({ from, to });
let canvasExists = await elasticChart.canvasExists();
expect(canvasExists).to.be(true);
await testSubjects.click('discoverChartOptionsToggle');
Expand All @@ -97,10 +98,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(canvasExists).to.be(true);
});
it('should allow hiding the histogram, persisted in saved search', async () => {
const fromTime = 'Jan 1, 2010 @ 00:00:00.000';
const toTime = 'Mar 21, 2019 @ 00:00:00.000';
const from = 'Jan 1, 2010 @ 00:00:00.000';
const to = 'Mar 21, 2019 @ 00:00:00.000';
const savedSearch = 'persisted hidden histogram';
await prepareTest(fromTime, toTime);
await prepareTest({ from, to });
await testSubjects.click('discoverChartOptionsToggle');
await testSubjects.click('discoverChartToggle');
let canvasExists = await elasticChart.canvasExists();
Expand Down

0 comments on commit 76745be

Please sign in to comment.