diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts b/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts index 4461c5aec42f..c86a875be641 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts @@ -189,6 +189,8 @@ export default function ({ getService }: FtrProviderContext) { x: sampleCell.x + cellSize, y: sampleCell.y + cellSize, }); + await ml.swimLane.waitForSwimLanesToLoad(); + // TODO extend cell data with X and Y values, and cell width await ml.swimLane.assertSelection(overallSwimLaneTestSubj, { x: [1454846400000, 1454860800000], @@ -215,6 +217,8 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('clears the selection'); await ml.anomalyExplorer.clearSwimLaneSelection(); + await ml.swimLane.waitForSwimLanesToLoad(); + await ml.navigation.assertCurrentURLNotContain( 'selectedLanes%3A!(Overall)%2CselectedTimes%3A!(1454846400%2C1454860800)%2CselectedType%3Aoverall%2CshowTopFieldValues%3A!t%2CviewByFieldName%3Aairline%2CviewByFromPage%3A1%2CviewByPerPage%3A10' ); @@ -255,6 +259,7 @@ export default function ({ getService }: FtrProviderContext) { x: sampleCell.x + cellSize, y: sampleCell.y + cellSize, }); + await ml.swimLane.waitForSwimLanesToLoad(); await ml.testExecution.logTestStep('check page content'); await ml.swimLane.assertSelection(viewBySwimLaneTestSubj, { @@ -274,6 +279,8 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('clears the selection'); await ml.anomalyExplorer.clearSwimLaneSelection(); + await ml.swimLane.waitForSwimLanesToLoad(); + await ml.anomaliesTable.assertTableRowsCount(25); await ml.anomalyExplorer.assertInfluencerFieldListLength('airline', 10); await ml.anomalyExplorer.assertAnomalyExplorerChartsCount(0); @@ -299,6 +306,7 @@ export default function ({ getService }: FtrProviderContext) { x2: sampleCell2!.x + cellSize, y2: sampleCell2!.y + cellSize, }); + await ml.swimLane.waitForSwimLanesToLoad(); await ml.swimLane.assertSelection(viewBySwimLaneTestSubj, { x: [1454817600000, 1454846400000], @@ -311,6 +319,8 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('clears the selection'); await ml.anomalyExplorer.clearSwimLaneSelection(); + await ml.swimLane.waitForSwimLanesToLoad(); + await ml.anomaliesTable.assertTableRowsCount(25); await ml.anomalyExplorer.assertInfluencerFieldListLength('airline', 10); await ml.anomalyExplorer.assertAnomalyExplorerChartsCount(0); diff --git a/x-pack/test/functional/services/ml/anomaly_explorer.ts b/x-pack/test/functional/services/ml/anomaly_explorer.ts index 4b1992777b8a..6ec45204388d 100644 --- a/x-pack/test/functional/services/ml/anomaly_explorer.ts +++ b/x-pack/test/functional/services/ml/anomaly_explorer.ts @@ -89,7 +89,8 @@ export function MachineLearningAnomalyExplorerProvider({ getService }: FtrProvid true ); await testSubjects.clickWhenNotDisabled('mlAddAndEditDashboardButton'); - const embeddable = await testSubjects.find('mlAnomalySwimlaneEmbeddableWrapper'); + // changing to the dashboard app might take sime time + const embeddable = await testSubjects.find('mlAnomalySwimlaneEmbeddableWrapper', 30 * 1000); const swimlane = await embeddable.findByClassName('mlSwimLaneContainer'); expect(await swimlane.isDisplayed()).to.eql( true, diff --git a/x-pack/test/functional/services/ml/swim_lane.ts b/x-pack/test/functional/services/ml/swim_lane.ts index d659b24559a4..29918b83cd27 100644 --- a/x-pack/test/functional/services/ml/swim_lane.ts +++ b/x-pack/test/functional/services/ml/swim_lane.ts @@ -208,5 +208,16 @@ export function SwimLaneProvider({ getService }: FtrProviderContext) { await testSubjects.click(`mlSwimLanePageSizePanel > ${rowsCount} rows`); await this.assertPageSize(testSubj, rowsCount); }, + + async waitForSwimLanesToLoad() { + // when updating the swim lanes, the old lanes might still be displayed + // for some time, before the loading indicator is displayed + + // wait for loading indicator to be displayed, but don't fail in case it's already gone + if (await testSubjects.exists('mlSwimLaneLoadingIndicator', { timeout: 10 * 1000 })) { + // only wait for loading indicator to disappear if it was actually displayed + await testSubjects.missingOrFail('mlSwimLaneLoadingIndicator', { timeout: 10 * 1000 }); + } + }, }; }