Skip to content

Commit

Permalink
[QA][refactor] Use ui settings - discover histogram (elastic#114997)
Browse files Browse the repository at this point in the history
* [QA][refactor] Use ui settings - discover histogram

Use ui settings instead of setting absolute range
for timepicker.

Stacked on top of: elastic#114530

* Use TimeStrings interface.
  • Loading branch information
wayneseymour authored and kibanamachine committed Nov 16, 2021
1 parent acea032 commit 6d2722e
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 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 @@ -40,10 +41,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'test/functional/fixtures/es_archiver/long_window_logstash_index_pattern'
);
await security.testUser.restoreDefaults();
await PageObjects.common.unsetTime();
});

async function prepareTest(fromTime: string, toTime: string, interval?: string) {
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
async function prepareTest(time: TimeStrings, interval?: string) {
await PageObjects.common.setTime(time);
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
if (interval) {
await PageObjects.discover.setChartInterval(interval);
Expand All @@ -52,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 @@ -95,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 6d2722e

Please sign in to comment.