Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Single Metric Viewer embeddable in dashboards: add tests for anomaly action menu #187801

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.testResources.deleteDashboardByTitle(testData.dashboardTitle);
});

it('can open job selection flyout', async () => {
it('should 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 () => {
it('should select jobs', async () => {
await ml.alerting.selectJobs([testData.jobConfig.job_id]);
await ml.alerting.assertJobSelection([testData.jobConfig.job_id]);
});

it('can configure single metric viewer panel', async () => {
it('should configure single metric viewer panel', async () => {
await ml.singleMetricViewer.assertDetectorInputExist();
await ml.singleMetricViewer.assertDetectorInputValue(
testData.expected.detectorInputValue
Expand All @@ -83,14 +83,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
});

it('create new single metric viewer panel', async () => {
it('should 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);
});

it('should have anomaly click action menu', async () => {
await ml.dashboardEmbeddables.assertDashboardPanelExists(testData.panelTitle);
await ml.singleMetricViewer.assertAnomalyMarkerExist();
await ml.singleMetricViewer.openAnomalyMarkerActionsPopover();
await ml.singleMetricViewer.assertAnomalyActionDiscoverButtonExists();
peteharverson marked this conversation as resolved.
Show resolved Hide resolved
await ml.singleMetricViewer.assertAnomalyActionJobRulesButtonExists();
peteharverson marked this conversation as resolved.
Show resolved Hide resolved
});
});
}
});
Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/functional/services/ml/single_metric_viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function MachineLearningSingleMetricViewerProvider(
) {
const comboBox = getService('comboBox');
const testSubjects = getService('testSubjects');
const retry = getService('retry');

return {
async assertSingleMetricViewerEmptyListMessageExsist() {
Expand Down Expand Up @@ -82,6 +83,21 @@ export function MachineLearningSingleMetricViewerProvider(
await testSubjects.existOrFail('mlAnomaliesListRowActionsMenu');
},

async assertAnomalyActionDiscoverButtonExists() {
await testSubjects.existOrFail('mlAnomaliesListRowAction_viewInDiscoverButton');
},

async assertAnomalyActionJobRulesButtonExists() {
await testSubjects.existOrFail('mlAnomaliesListRowActionConfigureRulesButton');
},

async ensureAnomalyActionDiscoverButtonClicked() {
await retry.tryForTime(3 * 1000, async () => {
await testSubjects.click('mlAnomaliesListRowAction_viewInDiscoverButton');
await testSubjects.existOrFail('discoverLayoutResizableContainer');
});
},

async assertAnnotationsExists(state: string) {
await testSubjects.existOrFail(`mlAnomalyExplorerAnnotations ${state}`, {
timeout: 30 * 1000,
Expand Down