From c01ff06cd2b3dcddd5a896ae417c218da78ac516 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Mon, 13 Sep 2021 17:23:28 +0200 Subject: [PATCH] [ML] Functional tests - stabilize import job test (#111929) This PR stabilizes the import job tests by giving the `Import` button some time to be enabled before clicking it. --- .../services/ml/stack_management_jobs.ts | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/x-pack/test/functional/services/ml/stack_management_jobs.ts b/x-pack/test/functional/services/ml/stack_management_jobs.ts index 45b9fa2f29ccd..8be01f452219c 100644 --- a/x-pack/test/functional/services/ml/stack_management_jobs.ts +++ b/x-pack/test/functional/services/ml/stack_management_jobs.ts @@ -86,7 +86,7 @@ export function MachineLearningStackManagementJobsProvider( }, async executeSync() { - await testSubjects.click('mlJobMgmtSyncFlyoutSyncButton', 2000); + await testSubjects.clickWhenNotDisabled('mlJobMgmtSyncFlyoutSyncButton', { timeout: 5000 }); // check and close success toast const resultToast = await toasts.getToastElement(1); @@ -285,7 +285,18 @@ export function MachineLearningStackManagementJobsProvider( }, async importJobs() { - await testSubjects.click('mlJobMgmtImportImportButton', 1000); + await testSubjects.clickWhenNotDisabled('mlJobMgmtImportImportButton', { timeout: 5000 }); + + // check and close success toast + const resultToast = await toasts.getToastElement(1); + const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); + const title: string = await titleElement.getVisibleText(); + expect(title).to.match(/^\d+ job[s]? successfully imported$/); + + const dismissButton = await testSubjects.findDescendant('toastCloseButton', resultToast); + await dismissButton.click(); + + // check that the flyout is closed await testSubjects.missingOrFail('mlJobMgmtImportJobsFlyout', { timeout: 60 * 1000 }); }, @@ -340,7 +351,18 @@ export function MachineLearningStackManagementJobsProvider( }, async selectExportJobs() { - await testSubjects.click('mlJobMgmtExportExportButton'); + await testSubjects.clickWhenNotDisabled('mlJobMgmtExportExportButton', { timeout: 5000 }); + + // check and close success toast + const resultToast = await toasts.getToastElement(1); + const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); + const title: string = await titleElement.getVisibleText(); + expect(title).to.match(/^Your file is downloading in the background$/); + + const dismissButton = await testSubjects.findDescendant('toastCloseButton', resultToast); + await dismissButton.click(); + + // check that the flyout is closed await testSubjects.missingOrFail('mlJobMgmtExportJobsFlyout', { timeout: 60 * 1000 }); },