From 178afd71fc825fc700e7bb5de39c1b34c72f2f7b Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Wed, 12 Aug 2020 13:42:43 +0200 Subject: [PATCH] [ML] Functional tests - stabilize DFA dependent variable input (#74829) This PR stabilizes the dependent variable input during tests by explicitly waiting for the options to load. --- .../configuration_step_form.tsx | 4 +++- .../ml/data_frame_analytics_creation.ts | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx index 571c7731822c0..2ae1996647463 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx @@ -397,7 +397,9 @@ export const ConfigurationStepForm: FC = ({ } isClearable={false} isInvalid={dependentVariable === ''} - data-test-subj="mlAnalyticsCreateJobWizardDependentVariableSelect" + data-test-subj={`mlAnalyticsCreateJobWizardDependentVariableSelect${ + loadingDepVarOptions ? ' loading' : ' loaded' + }`} /> diff --git a/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts b/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts index d8df2fb869ed7..474d6845ef3ec 100644 --- a/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts +++ b/x-pack/test/functional/services/ml/data_frame_analytics_creation.ts @@ -228,23 +228,33 @@ export function MachineLearningDataFrameAnalyticsCreationProvider( await this.assertDestIndexValue(destIndex); }, + async waitForDependentVariableInputLoaded() { + await testSubjects.existOrFail('~mlAnalyticsCreateJobWizardDependentVariableSelect', { + timeout: 5 * 1000, + }); + await testSubjects.existOrFail('mlAnalyticsCreateJobWizardDependentVariableSelect loaded', { + timeout: 30 * 1000, + }); + }, + async assertDependentVariableInputExists() { await retry.tryForTime(8000, async () => { await testSubjects.existOrFail( - 'mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' + '~mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' ); }); }, async assertDependentVariableInputMissing() { await testSubjects.missingOrFail( - 'mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' + '~mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' ); }, async assertDependentVariableSelection(expectedSelection: string[]) { + await this.waitForDependentVariableInputLoaded(); const actualSelection = await comboBox.getComboBoxSelectedOptions( - 'mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' + '~mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput' ); expect(actualSelection).to.eql( expectedSelection, @@ -253,8 +263,9 @@ export function MachineLearningDataFrameAnalyticsCreationProvider( }, async selectDependentVariable(dependentVariable: string) { + await this.waitForDependentVariableInputLoaded(); await comboBox.set( - 'mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput', + '~mlAnalyticsCreateJobWizardDependentVariableSelect > comboBoxInput', dependentVariable ); await this.assertDependentVariableSelection([dependentVariable]);