-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Single metric viewer in dashboards: adds functional test (#178768)
## Summary Related meta issue: #176651 This PR adds functional tests for SMV in dashboards. Flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5485 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
da8e891
commit a6174d4
Showing
6 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...onal/apps/ml/anomaly_detection_integrations/single_metric_viewer_dashboard_embeddables.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
import { JOB_CONFIG, DATAFEED_CONFIG, ML_EMBEDDABLE_TYPES } from './constants'; | ||
|
||
const testDataList = [ | ||
{ | ||
type: 'testData', | ||
suiteSuffix: 'with multi metric job', | ||
panelTitle: `ML single metric viewer for ${JOB_CONFIG.job_id}`, | ||
jobConfig: JOB_CONFIG, | ||
datafeedConfig: DATAFEED_CONFIG, | ||
dashboardTitle: `ML single metric viewer for fq_multi_1_ae ${Date.now()}`, | ||
expected: { detectorInputValue: '0', entityInputLabel: 'airline', entityInputValue: 'AAL' }, | ||
}, | ||
]; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const ml = getService('ml'); | ||
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']); | ||
const from = 'Feb 7, 2016 @ 00:00:00.000'; | ||
const to = 'Feb 11, 2016 @ 00:00:00.000'; | ||
|
||
describe('single metric viewer in dashboard', function () { | ||
this.tags(['ml']); | ||
|
||
before(async () => { | ||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); | ||
await ml.testResources.createDataViewIfNeeded('ft_farequote', '@timestamp'); | ||
await ml.testResources.setKibanaTimeZoneToUTC(); | ||
await ml.securityUI.loginAsMlPowerUser(); | ||
await PageObjects.common.setTime({ from, to }); | ||
}); | ||
|
||
after(async () => { | ||
await ml.api.cleanMlIndices(); | ||
await ml.testResources.deleteDataViewByTitle('ft_farequote'); | ||
await PageObjects.common.unsetTime(); | ||
}); | ||
|
||
for (const testData of testDataList) { | ||
describe(testData.suiteSuffix, function () { | ||
before(async () => { | ||
await ml.api.createAndRunAnomalyDetectionLookbackJob( | ||
testData.jobConfig, | ||
testData.datafeedConfig | ||
); | ||
await PageObjects.dashboard.navigateToApp(); | ||
}); | ||
|
||
after(async () => { | ||
await ml.testResources.deleteDashboardByTitle(testData.dashboardTitle); | ||
}); | ||
|
||
it('can open job selection flyout', async () => { | ||
await PageObjects.dashboard.clickNewDashboard(); | ||
await ml.dashboardEmbeddables.assertDashboardIsEmpty(); | ||
await ml.dashboardEmbeddables.openAnomalyJobSelectionFlyout( | ||
ML_EMBEDDABLE_TYPES.ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE | ||
); | ||
}); | ||
|
||
it('can select jobs', async () => { | ||
await ml.dashboardJobSelectionTable.setRowRadioButtonState( | ||
testData.jobConfig.job_id, | ||
true | ||
); | ||
await ml.dashboardJobSelectionTable.applyJobSelection(); | ||
}); | ||
|
||
it('can configure single metric viewer panel', async () => { | ||
await ml.dashboardEmbeddables.assertSingleMetricViewerEmbeddableInitializerExists(); | ||
await ml.singleMetricViewer.assertDetectorInputExist(); | ||
await ml.singleMetricViewer.assertDetectorInputValue( | ||
testData.expected.detectorInputValue | ||
); | ||
await ml.singleMetricViewer.assertEntityInputExist(testData.expected.entityInputLabel); | ||
await ml.singleMetricViewer.selectEntityValue( | ||
testData.expected.entityInputLabel, | ||
testData.expected.entityInputValue | ||
); | ||
}); | ||
|
||
it('create new single metric viewer panel', async () => { | ||
await ml.dashboardEmbeddables.clickSingleMetricViewerInitializerConfirmButtonEnabled(); | ||
await PageObjects.timePicker.pauseAutoRefresh(); | ||
await ml.dashboardEmbeddables.assertDashboardPanelExists(testData.panelTitle); | ||
await ml.singleMetricViewer.assertChartExist(); | ||
await ml.singleMetricViewer.assertAnomalyMarkerExist(); | ||
await PageObjects.dashboard.saveDashboard(testData.dashboardTitle); | ||
}); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters