diff --git a/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts b/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts index 51875c683346e..de44984a50c5b 100644 --- a/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts +++ b/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts @@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const ml = getService('ml'); const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']); - const dashboardAddPanel = getService('dashboardAddPanel'); const a11y = getService('a11y'); /* this is the wrapping service around axe */ describe('machine learning embeddables anomaly charts', function () { @@ -96,10 +95,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('can open job selection flyout', async () => { await PageObjects.dashboard.clickCreateDashboardPrompt(); await ml.dashboardEmbeddables.assertDashboardIsEmpty(); - await dashboardAddPanel.clickEditorMenuButton(); - await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml'); - await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts'); - await ml.dashboardJobSelectionTable.assertJobSelectionTableExists(); + await ml.dashboardEmbeddables.openJobSelectionFlyout(); await a11y.testAppSnapshot(); }); diff --git a/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts b/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts index 0aee183c1a4a5..d4eb45619b7f7 100644 --- a/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts +++ b/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts @@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const ml = getService('ml'); const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']); - const dashboardAddPanel = getService('dashboardAddPanel'); describe('anomaly charts', function () { this.tags(['mlqa']); @@ -87,10 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('can open job selection flyout', async () => { await PageObjects.dashboard.clickCreateDashboardPrompt(); await ml.dashboardEmbeddables.assertDashboardIsEmpty(); - await dashboardAddPanel.clickEditorMenuButton(); - await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml'); - await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts'); - await ml.dashboardJobSelectionTable.assertJobSelectionTableExists(); + await ml.dashboardEmbeddables.openJobSelectionFlyout(); }); it('can select jobs', async () => { diff --git a/x-pack/test/functional/services/ml/dashboard_embeddables.ts b/x-pack/test/functional/services/ml/dashboard_embeddables.ts index d0e100a57075a..db5c3f35a2e14 100644 --- a/x-pack/test/functional/services/ml/dashboard_embeddables.ts +++ b/x-pack/test/functional/services/ml/dashboard_embeddables.ts @@ -8,14 +8,17 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; import { MlCommonUI } from './common_ui'; +import { MlDashboardJobSelectionTable } from './dashboard_job_selection_table'; export function MachineLearningDashboardEmbeddablesProvider( { getService }: FtrProviderContext, - mlCommonUI: MlCommonUI + mlCommonUI: MlCommonUI, + mlDashboardJobSelectionTable: MlDashboardJobSelectionTable ) { const retry = getService('retry'); const testSubjects = getService('testSubjects'); const find = getService('find'); + const dashboardAddPanel = getService('dashboardAddPanel'); return { async assertAnomalyChartsEmbeddableInitializerExists() { @@ -91,5 +94,17 @@ export function MachineLearningDashboardEmbeddablesProvider( async assertAnomalyChartsExists() { await testSubjects.existOrFail(`mlExplorerChartsContainer`); }, + + async openJobSelectionFlyout() { + await retry.tryForTime(60 * 1000, async () => { + await dashboardAddPanel.clickEditorMenuButton(); + await testSubjects.existOrFail('dashboardEditorContextMenu', { timeout: 2000 }); + + await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml'); + await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts'); + + await mlDashboardJobSelectionTable.assertJobSelectionTableExists(); + }); + }, }; } diff --git a/x-pack/test/functional/services/ml/dashboard_job_selection_table.ts b/x-pack/test/functional/services/ml/dashboard_job_selection_table.ts index b9fe43b000baf..f372928d92a50 100644 --- a/x-pack/test/functional/services/ml/dashboard_job_selection_table.ts +++ b/x-pack/test/functional/services/ml/dashboard_job_selection_table.ts @@ -6,8 +6,13 @@ */ import expect from '@kbn/expect'; +import { ProvidedType } from '@kbn/test/types/ftr'; import { FtrProviderContext } from '../../ftr_provider_context'; +export type MlDashboardJobSelectionTable = ProvidedType< + typeof MachineLearningDashboardJobSelectionTableProvider +>; + export function MachineLearningDashboardJobSelectionTableProvider({ getService, }: FtrProviderContext) { @@ -16,8 +21,8 @@ export function MachineLearningDashboardJobSelectionTableProvider({ return { async assertJobSelectionTableExists(): Promise { - await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail('mlCustomSelectionTable'); + await retry.tryForTime(20 * 1000, async () => { + await testSubjects.existOrFail('mlCustomSelectionTable', { timeout: 2000 }); }); }, diff --git a/x-pack/test/functional/services/ml/index.ts b/x-pack/test/functional/services/ml/index.ts index fe46263f50266..05d369d890289 100644 --- a/x-pack/test/functional/services/ml/index.ts +++ b/x-pack/test/functional/services/ml/index.ts @@ -60,7 +60,11 @@ export function MachineLearningProvider(context: FtrProviderContext) { const customUrls = MachineLearningCustomUrlsProvider(context); const dashboardJobSelectionTable = MachineLearningDashboardJobSelectionTableProvider(context); - const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(context, commonUI); + const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider( + context, + commonUI, + dashboardJobSelectionTable + ); const dataFrameAnalytics = MachineLearningDataFrameAnalyticsProvider(context, api); const dataFrameAnalyticsCreation = MachineLearningDataFrameAnalyticsCreationProvider(