From 4f9a58869f33e1bda6abc3747e5adfc5eb657fb1 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 25 Mar 2024 10:01:12 +0000 Subject: [PATCH 01/44] [ML] Add AD job validation UI tests - Add job wizard validation suite - Add job wizard model change annotation recommendation callout test subject - Add job wizard model time picker test subject within a div, as the EUI documents are incorrect about data-test-subjs for this component - Add test subjects for two steps: Time Range and Job Details - Add more methods to job wizard common service --- .../common/components/time_range_picker.tsx | 32 ++-- .../annotations/annotations_switch.tsx | 1 + .../pages/new_job/wizard_horizontal_steps.tsx | 5 + .../apps/ml/anomaly_detection_jobs/index.ts | 1 + .../job_wizard_validation.ts | 173 ++++++++++++++++++ .../services/ml/job_wizard_common.ts | 72 ++++++++ 6 files changed, 269 insertions(+), 15 deletions(-) create mode 100644 x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx index b9332e04144c0..d82cb606fbc71 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx @@ -85,21 +85,23 @@ export const TimeRangePicker: FC = ({ setTimeRange, timeRange }) => { /> } endDateControl={ - +
+ +
} /> diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/advanced_section/components/annotations/annotations_switch.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/advanced_section/components/annotations/annotations_switch.tsx index 132f005349604..b761bf3be6451 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/advanced_section/components/annotations/annotations_switch.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/advanced_section/components/annotations/annotations_switch.tsx @@ -53,6 +53,7 @@ export const AnnotationsSwitch: FC = () => { {showCallOut && ( = ({ } function createStepProps(step: WIZARD_STEPS) { + let testSubj: string = ''; + if (step === WIZARD_STEPS.TIME_RANGE) testSubj = 'mlJobWizardTimeRangeStep'; + if (step === WIZARD_STEPS.JOB_DETAILS) testSubj = 'mlJobWizardJobDetailsStep'; + return { onClick: () => jumpToStep(step), status: (currentStep === step @@ -87,6 +91,7 @@ export const WizardHorizontalSteps: FC = ({ ? 'complete' : 'incomplete') as EuiStepStatus, disabled: disableSteps || highestStep < step, + 'data-test-subj': testSubj, }; } diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts index 254bd76f5616b..68c15ecd08f57 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts @@ -40,6 +40,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./single_metric_job')); if (!isCcs) { + loadTestFile(require.resolve('./job_wizard_validation')); loadTestFile(require.resolve('./single_metric_job_without_datafeed_start')); loadTestFile(require.resolve('./multi_metric_job')); loadTestFile(require.resolve('./population_job')); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts new file mode 100644 index 0000000000000..470afb93cea00 --- /dev/null +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts @@ -0,0 +1,173 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { FtrProviderContext } from '../../../ftr_provider_context'; +import type { FieldStatsType } from '../common/types'; + +export default function ({ getService }: FtrProviderContext) { + const config = getService('config'); + const esNode = config.get('esTestCluster.ccs') + ? getService('remoteEsArchiver' as 'esArchiver') + : getService('esArchiver'); + const ml = getService('ml'); + + const jobId = `fq_single_1_${Date.now()}`; + const jobDescription = + 'Create single metric job based on the farequote dataset with 30m bucketspan and mean(responsetime)'; + const jobGroups = ['automated', 'farequote', 'single-metric']; + const aggAndFieldIdentifier = 'Mean(responsetime)'; + const bucketSpan = '30m'; + + const remoteName = 'ftr-remote:'; + const esIndexPatternName = 'ft_farequote'; + const esIndexPatternString = config.get('esTestCluster.ccs') + ? remoteName + esIndexPatternName + : esIndexPatternName; + + const fieldStatsEntries = [ + { + fieldName: '@version.keyword', + type: 'keyword' as FieldStatsType, + expectedValues: ['1'], + }, + ]; + + describe('job wizard validation', function () { + this.tags(['ml']); + before(async () => { + await esNode.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await ml.testResources.createDataViewIfNeeded(esIndexPatternString, '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.securityUI.loginAsMlPowerUser(); + + await ml.testExecution.logTestStep('job creation loads the job management page'); + await ml.navigation.navigateToMl(); + await ml.navigation.navigateToJobManagement(); + + await ml.testExecution.logTestStep('job creation loads the new job source selection page'); + await ml.jobManagement.navigateToNewJobSourceSelection(); + + await ml.testExecution.logTestStep('job creation loads the job type selection page'); + await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(esIndexPatternString); + + await ml.testExecution.logTestStep('job creation loads the single metric job wizard page'); + await ml.jobTypeSelection.selectSingleMetricJob(); + await ml.testExecution.logTestStep('job creation displays the time range step'); + await ml.jobWizardCommon.assertTimeRangeSectionExists(); + + await ml.testExecution.logTestStep('job creation sets the time range'); + await ml.jobWizardCommon.clickUseFullDataButton( + 'Feb 7, 2016 @ 00:00:00.000', + 'Feb 11, 2016 @ 23:59:54.000' + ); + + await ml.testExecution.logTestStep('job creation displays the event rate chart'); + await ml.jobWizardCommon.assertEventRateChartExists(); + await ml.jobWizardCommon.assertEventRateChartHasData(); + + await ml.testExecution.logTestStep('job creation displays the pick fields step'); + await ml.jobWizardCommon.advanceToPickFieldsSection(); + + await ml.testExecution.logTestStep('job creation opens field stats flyout from agg input'); + await ml.jobWizardCommon.assertAggAndFieldInputExists(); + for (const { fieldName, type: fieldType, expectedValues } of fieldStatsEntries) { + await ml.jobWizardCommon.assertFieldStatFlyoutContentFromAggSelectionInputTrigger( + fieldName, + fieldType, + expectedValues + ); + } + + await ml.testExecution.logTestStep('job creation selects field and aggregation'); + await ml.jobWizardCommon.selectAggAndField(aggAndFieldIdentifier, true); + await ml.jobWizardCommon.assertAnomalyChartExists('LINE'); + + await ml.testExecution.logTestStep('job creation inputs the bucket span'); + await ml.jobWizardCommon.assertBucketSpanInputExists(); + await ml.jobWizardCommon.setBucketSpan(bucketSpan); + + await ml.testExecution.logTestStep('job creation displays the job details step'); + await ml.jobWizardCommon.advanceToJobDetailsSection(); + + await ml.testExecution.logTestStep('job creation inputs the job id'); + await ml.jobWizardCommon.assertJobIdInputExists(); + await ml.jobWizardCommon.setJobId(jobId); + + await ml.testExecution.logTestStep('job creation inputs job groups'); + await ml.jobWizardCommon.assertJobGroupInputExists(); + for (const jobGroup of jobGroups) { + await ml.jobWizardCommon.addJobGroup(jobGroup); + } + await ml.jobWizardCommon.assertJobGroupSelection(jobGroups); + + await ml.testExecution.logTestStep('job creation opens the additional settings section'); + await ml.jobWizardCommon.ensureAdditionalSettingsSectionOpen(); + + await ml.testExecution.logTestStep('job creation opens the advanced section'); + await ml.jobWizardCommon.ensureAdvancedSectionOpen(); + + await ml.testExecution.logTestStep('job creation displays the model plot switch'); + await ml.jobWizardCommon.assertModelPlotSwitchExists(); + + await ml.testExecution.logTestStep('job creation enables the dedicated index switch'); + await ml.jobWizardCommon.assertDedicatedIndexSwitchExists(); + await ml.jobWizardCommon.activateDedicatedIndexSwitch(); + + await ml.testExecution.logTestStep('job creation inputs the model memory limit'); + await ml.jobWizardCommon.assertModelMemoryLimitInputExists(); + }); + + after(async () => { + await ml.api.cleanMlIndices(); + await ml.testResources.deleteDataViewByTitle(esIndexPatternString); + }); + + it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { + await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); + }); + + it('too short of a job creation time range results in validation callouts', async () => { + await ml.jobWizardCommon.goBackToTimeRange(); + + const tooShort = 'Feb 7, 2016 @ 00:01:00.000'; + await ml.jobWizardCommon.setEndDate(tooShort); + + await ml.testExecution.logTestStep('job creation displays the validation step'); + await ml.jobWizardCommon.goBackToJobDetailsSection(); + await ml.jobWizardCommon.advanceToValidationSection(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'Time range\nThe selected or available time range might be too short. The recommended minimum time range should be at least 2 hours and 25 times the bucket span.', + 'The datafeed preview failed. This may be due to an error in the job or datafeed configurations.', + 'Job validation has failed, but you can still continue and create the job. Please be aware the job may encounter problems when running.', + ]); + + await ml.jobWizardCommon.goBackToTimeRange(); + await ml.jobWizardCommon.clickUseFullDataButton( + 'Feb 7, 2016 @ 00:00:00.000', + 'Feb 11, 2016 @ 23:59:54.000' + ); + await ml.jobWizardCommon.advanceToValidationSection(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'Time range\nValid and long enough to model patterns in the data.', + 'Model memory limit\nValid and within the estimated model memory limit. Learn more', + ]); + }); + + it('job creation memory limit too large results in validation callout', async () => { + await ml.jobWizardCommon.goBackToJobDetailsSection(); + + const tooLarge = '100000000MB'; + await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); + + await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'Job will not be able to run in the current cluster because model memory limit is higher than 9790MB.', + ]); + }); + }); +} diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 9d9c91f500456..8f312098ef2a4 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -619,5 +619,77 @@ export function MachineLearningJobWizardCommonProvider( await testSubjects.existOrFail(expectedSelector); }); }, + + async getAnnotationSwitchCheckedState(): Promise { + const subj = 'mlJobWizardSwitchAnnotations'; + const isSelected = await testSubjects.getAttribute(subj, 'aria-checked'); + return isSelected === 'true'; + }, + + async getAnnotationsSwitchCheckedState(expectedValue: boolean) { + const actualCheckedState = await this.getAnnotationSwitchCheckedState(); + expect(actualCheckedState).to.eql( + expectedValue, + `Expected annotations switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${ + actualCheckedState ? 'enabled' : 'disabled' + }')` + ); + }, + + async toggleAnnotationSwitch(toggle: boolean) { + const subj = 'mlJobWizardSwitchAnnotations'; + if ((await this.getAnnotationSwitchCheckedState()) !== toggle) { + await retry.tryForTime(5 * 1000, async () => { + await testSubjects.clickWhenNotDisabledWithoutRetry(subj); + await this.getAnnotationSwitchCheckedState(); + }); + } + }, + + async togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout() { + await this.toggleAnnotationSwitch(false); + await testSubjects.existOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { + timeout: 3_000, + }); + await this.toggleAnnotationSwitch(true); + await testSubjects.missingOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { + timeout: 3_000, + }); + }, + + async goBackToTimeRange() { + await testSubjects.existOrFail('mlJobWizardTimeRangeStep', { + timeout: 3_000, + }); + await testSubjects.click('mlJobWizardTimeRangeStep'); + }, + + async setEndDate(input: string) { + await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', input); + }, + + async goBackToJobDetailsSection() { + await testSubjects.existOrFail('mlJobWizardJobDetailsStep', { + timeout: 3_000, + }); + await testSubjects.click('mlJobWizardJobDetailsStep'); + }, + + async assertValidationCallouts(expectedCallouts: string[]) { + if (expectedCallouts.length === 1) { + const [, memLimitTooHighCalloutVisibleText] = await testSubjects.getVisibleTextAll( + 'mlValidationCallout' + ); + + expect(memLimitTooHighCalloutVisibleText).to.be(expectedCallouts[0]); + return; + } + + const allCallOutVisibleTexts = await testSubjects.getVisibleTextAll('mlValidationCallout'); + const expectedWithinActual = expectedCallouts.every((expected) => + allCallOutVisibleTexts.some((actual) => actual === expected) + ); + expect(expectedWithinActual).to.be(true); + }, }; } From 057da93265eaf1128de5a1dab6793cccf6ba0554 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 27 Mar 2024 15:49:07 +0000 Subject: [PATCH 02/44] Truncate test subj for validation callout, from msg contents. Use selectors over visible text. Change assertions based on lessons learned from previous code reviews. --- .../components/callout/callout.tsx | 2 +- .../job_wizard_validation.ts | 14 ++++++------- .../services/ml/job_wizard_common.ts | 20 +++++-------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/callout/callout.tsx b/x-pack/plugins/ml/public/application/components/callout/callout.tsx index b2c588377d232..74c6b0c11df71 100644 --- a/x-pack/plugins/ml/public/application/components/callout/callout.tsx +++ b/x-pack/plugins/ml/public/application/components/callout/callout.tsx @@ -55,7 +55,7 @@ const Message: FC> = ({ text, url }) => ( export const Callout: FC = ({ heading, status, text, url }) => ( <> - allCallOutVisibleTexts.some((actual) => actual === expected) - ); - expect(expectedWithinActual).to.be(true); + async assertValidationCallouts(expectedCallOutSelectors: string[]) { + for await (const sel of expectedCallOutSelectors) + await testSubjects.existOrFail(sel, { + timeout: 3_000, + }); }, }; } From 433aad826a3e88696c9c35239d40cb49d2fe9212 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 14:23:36 +0100 Subject: [PATCH 03/44] Graft it block to existing suite, per cr. --- .../job_wizard_validation.ts | 27 ------------ .../single_metric_job.ts | 41 +++++++++++++++++++ .../services/ml/job_wizard_common.ts | 29 ++++++++++++- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts index 10c497fdd0924..1a776b6a7d01a 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts @@ -129,33 +129,6 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); }); - it('too short of a job creation time range results in validation callouts', async () => { - await ml.jobWizardCommon.goBackToTimeRange(); - - const tooShort = 'Feb 7, 2016 @ 00:01:00.000'; - await ml.jobWizardCommon.setEndDate(tooShort); - - await ml.testExecution.logTestStep('job creation displays the validation step'); - await ml.jobWizardCommon.goBackToJobDetailsSection(); - await ml.jobWizardCommon.advanceToValidationSection(); - await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-warning-The selected or available time', - 'mlValidationCallout-danger-The datafeed preview failed. T', - 'mlValidationCallout-warning-Job validation has failed, but', - ]); - - await ml.jobWizardCommon.goBackToTimeRange(); - await ml.jobWizardCommon.clickUseFullDataButton( - 'Feb 7, 2016 @ 00:00:00.000', - 'Feb 11, 2016 @ 23:59:54.000' - ); - await ml.jobWizardCommon.advanceToValidationSection(); - await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-success-Valid and long enough to model', - 'mlValidationCallout-success-Valid and within the estimated', - ]); - }); - it('job creation memory limit too large results in validation callout', async () => { await ml.jobWizardCommon.goBackToJobDetailsSection(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 7ce5d1838a1a5..3c5a67a853a81 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -387,5 +387,46 @@ export default function ({ getService }: FtrProviderContext) { ); await ml.api.assertNoJobResultsExist(jobIdClone); }); + + it('job cloning with too short of a job creation time range results in validation callouts', async () => { + await ml.testExecution.logTestStep('job creation loads the job management page'); + await ml.navigation.navigateToMl(); + await ml.navigation.navigateToJobManagement(); + + await ml.testExecution.logTestStep(`cloning job: [${jobId}]`); + await ml.jobWizardCommon.cloneJob(); + + await ml.testExecution.logTestStep('job creation displays the time range step'); + await ml.jobWizardCommon.assertTimeRangeSectionExists(); + + await ml.testExecution.logTestStep('job creation sets the time range'); + await ml.jobWizardCommon.clickUseFullDataButton( + 'Feb 7, 2016 @ 00:00:00.000', + 'Feb 11, 2016 @ 23:59:54.000' + ); + + await ml.jobWizardCommon.goBackToTimeRange(); + + await ml.jobWizardCommon.assertShortDurationTimeRange(); + + await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.assertJobIdInputExists(); + await ml.jobWizardCommon.setJobId(`${jobIdClone}-again`); + await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'mlValidationCallout-warning-The selected or available time', + ]); + + await ml.jobWizardCommon.goBackToTimeRange(); + await ml.jobWizardCommon.clickUseFullDataButton( + 'Feb 7, 2016 @ 00:00:00.000', + 'Feb 11, 2016 @ 23:59:54.000' + ); + await ml.jobWizardCommon.advanceToValidationSection(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'mlValidationCallout-success-Valid and long enough to model', + ]); + }); }); } diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index c5aa45f12072f..e83391616811e 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -664,8 +664,27 @@ export function MachineLearningJobWizardCommonProvider( await testSubjects.click('mlJobWizardTimeRangeStep'); }, - async setEndDate(input: string) { - await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', input); + async assertShortDurationTimeRange() { + const { startDate: origStartDate } = await this.getSelectedDateRange(); + + // calculate the new end datedate + const shortDurationEndDate = `${origStartDate.split(':', 1)[0]}:01:00.000`; + + // set the new end date + await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', shortDurationEndDate, { + clearWithKeyboard: true, + typeCharByChar: true, + }); + + // click away from time popover + await testSubjects.click('mlJobWizardTimeRangeStep'); + const { endDate: newEndDate } = await this.getSelectedDateRange(); + + // assert time is set as expected + expect(newEndDate).to.eql( + shortDurationEndDate, + `Expect [${newEndDate}] to eql [${shortDurationEndDate}]` + ); }, async goBackToJobDetailsSection() { @@ -681,5 +700,11 @@ export function MachineLearningJobWizardCommonProvider( timeout: 3_000, }); }, + + async cloneJob() { + await testSubjects.click('euiCollapsedItemActionsButton'); + await testSubjects.click('mlActionButtonCloneJob'); + await testSubjects.existOrFail('mlPageJobWizardHeader-single_metric'); + }, }; } From 21c1f5078539f4a932ad84576e9fc2bae987786d Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 14:47:51 +0100 Subject: [PATCH 04/44] Graft next it block to exisiting suite, per cr. --- .../apps/ml/anomaly_detection_jobs/job_wizard_validation.ts | 4 ---- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts index 1a776b6a7d01a..e6238ad0970cd 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts @@ -125,10 +125,6 @@ export default function ({ getService }: FtrProviderContext) { await ml.testResources.deleteDataViewByTitle(esIndexPatternString); }); - it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { - await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); - }); - it('job creation memory limit too large results in validation callout', async () => { await ml.jobWizardCommon.goBackToJobDetailsSection(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 3c5a67a853a81..3c8f65d00d1f7 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -428,5 +428,11 @@ export default function ({ getService }: FtrProviderContext) { 'mlValidationCallout-success-Valid and long enough to model', ]); }); + + it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { + await ml.jobWizardCommon.goBackToJobDetailsSection(); + await ml.jobWizardCommon.ensureAdvancedSectionOpen(); + await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); + }); }); } From f1bb2271d2a975c7fcfef3a98bcc9b4bcc0aa938 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 15:26:08 +0100 Subject: [PATCH 05/44] Graft next it block to existing suite. --- .../anomaly_detection_jobs/job_wizard_validation.ts | 12 ------------ .../ml/anomaly_detection_jobs/single_metric_job.ts | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts index e6238ad0970cd..a8b711b03acb8 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts @@ -124,17 +124,5 @@ export default function ({ getService }: FtrProviderContext) { await ml.api.cleanMlIndices(); await ml.testResources.deleteDataViewByTitle(esIndexPatternString); }); - - it('job creation memory limit too large results in validation callout', async () => { - await ml.jobWizardCommon.goBackToJobDetailsSection(); - - const tooLarge = '100000000MB'; - await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); - - await ml.jobWizardCommon.clickNextButton(); - await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-warning-Job will not be able to run in', - ]); - }); }); } diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 3c8f65d00d1f7..8bd01306bc025 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -434,5 +434,17 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.ensureAdvancedSectionOpen(); await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); }); + + it('job creation memory limit too large results in validation callout', async () => { + await ml.jobWizardCommon.goBackToJobDetailsSection(); + + const tooLarge = '100000000MB'; + await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); + + await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.assertValidationCallouts([ + 'mlValidationCallout-warning-Job will not be able to run in', + ]); + }); }); } From 30a59c6a9d33c13ed56a2244ec327c89e9aa7e82 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 15:28:40 +0100 Subject: [PATCH 06/44] Drop new suite. --- .../job_wizard_validation.ts | 128 ------------------ 1 file changed, 128 deletions(-) delete mode 100644 x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts deleted file mode 100644 index a8b711b03acb8..0000000000000 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/job_wizard_validation.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { FtrProviderContext } from '../../../ftr_provider_context'; -import type { FieldStatsType } from '../common/types'; - -export default function ({ getService }: FtrProviderContext) { - const config = getService('config'); - const esNode = config.get('esTestCluster.ccs') - ? getService('remoteEsArchiver' as 'esArchiver') - : getService('esArchiver'); - const ml = getService('ml'); - - const jobId = `fq_single_1_${Date.now()}`; - const jobGroups = ['automated', 'farequote', 'single-metric']; - const aggAndFieldIdentifier = 'Mean(responsetime)'; - const bucketSpan = '30m'; - - const remoteName = 'ftr-remote:'; - const esIndexPatternName = 'ft_farequote'; - const esIndexPatternString = config.get('esTestCluster.ccs') - ? remoteName + esIndexPatternName - : esIndexPatternName; - - const fieldStatsEntries = [ - { - fieldName: '@version.keyword', - type: 'keyword' as FieldStatsType, - expectedValues: ['1'], - }, - ]; - - describe('job wizard validation', function () { - this.tags(['ml']); - before(async () => { - await esNode.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); - await ml.testResources.createDataViewIfNeeded(esIndexPatternString, '@timestamp'); - await ml.testResources.setKibanaTimeZoneToUTC(); - - await ml.securityUI.loginAsMlPowerUser(); - - await ml.testExecution.logTestStep('job creation loads the job management page'); - await ml.navigation.navigateToMl(); - await ml.navigation.navigateToJobManagement(); - - await ml.testExecution.logTestStep('job creation loads the new job source selection page'); - await ml.jobManagement.navigateToNewJobSourceSelection(); - - await ml.testExecution.logTestStep('job creation loads the job type selection page'); - await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(esIndexPatternString); - - await ml.testExecution.logTestStep('job creation loads the single metric job wizard page'); - await ml.jobTypeSelection.selectSingleMetricJob(); - await ml.testExecution.logTestStep('job creation displays the time range step'); - await ml.jobWizardCommon.assertTimeRangeSectionExists(); - - await ml.testExecution.logTestStep('job creation sets the time range'); - await ml.jobWizardCommon.clickUseFullDataButton( - 'Feb 7, 2016 @ 00:00:00.000', - 'Feb 11, 2016 @ 23:59:54.000' - ); - - await ml.testExecution.logTestStep('job creation displays the event rate chart'); - await ml.jobWizardCommon.assertEventRateChartExists(); - await ml.jobWizardCommon.assertEventRateChartHasData(); - - await ml.testExecution.logTestStep('job creation displays the pick fields step'); - await ml.jobWizardCommon.advanceToPickFieldsSection(); - - await ml.testExecution.logTestStep('job creation opens field stats flyout from agg input'); - await ml.jobWizardCommon.assertAggAndFieldInputExists(); - for (const { fieldName, type: fieldType, expectedValues } of fieldStatsEntries) { - await ml.jobWizardCommon.assertFieldStatFlyoutContentFromAggSelectionInputTrigger( - fieldName, - fieldType, - expectedValues - ); - } - - await ml.testExecution.logTestStep('job creation selects field and aggregation'); - await ml.jobWizardCommon.selectAggAndField(aggAndFieldIdentifier, true); - await ml.jobWizardCommon.assertAnomalyChartExists('LINE'); - - await ml.testExecution.logTestStep('job creation inputs the bucket span'); - await ml.jobWizardCommon.assertBucketSpanInputExists(); - await ml.jobWizardCommon.setBucketSpan(bucketSpan); - - await ml.testExecution.logTestStep('job creation displays the job details step'); - await ml.jobWizardCommon.advanceToJobDetailsSection(); - - await ml.testExecution.logTestStep('job creation inputs the job id'); - await ml.jobWizardCommon.assertJobIdInputExists(); - await ml.jobWizardCommon.setJobId(jobId); - - await ml.testExecution.logTestStep('job creation inputs job groups'); - await ml.jobWizardCommon.assertJobGroupInputExists(); - for (const jobGroup of jobGroups) { - await ml.jobWizardCommon.addJobGroup(jobGroup); - } - await ml.jobWizardCommon.assertJobGroupSelection(jobGroups); - - await ml.testExecution.logTestStep('job creation opens the additional settings section'); - await ml.jobWizardCommon.ensureAdditionalSettingsSectionOpen(); - - await ml.testExecution.logTestStep('job creation opens the advanced section'); - await ml.jobWizardCommon.ensureAdvancedSectionOpen(); - - await ml.testExecution.logTestStep('job creation displays the model plot switch'); - await ml.jobWizardCommon.assertModelPlotSwitchExists(); - - await ml.testExecution.logTestStep('job creation enables the dedicated index switch'); - await ml.jobWizardCommon.assertDedicatedIndexSwitchExists(); - await ml.jobWizardCommon.activateDedicatedIndexSwitch(); - - await ml.testExecution.logTestStep('job creation inputs the model memory limit'); - await ml.jobWizardCommon.assertModelMemoryLimitInputExists(); - }); - - after(async () => { - await ml.api.cleanMlIndices(); - await ml.testResources.deleteDataViewByTitle(esIndexPatternString); - }); - }); -} From affd426f8b1de9a532c051a2e51193d9d053d6f6 Mon Sep 17 00:00:00 2001 From: Tre Date: Tue, 2 Apr 2024 15:29:10 +0100 Subject: [PATCH 07/44] Update x-pack/test/functional/services/ml/job_wizard_common.ts Co-authored-by: Dima Arnautov --- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index c5aa45f12072f..b669959013425 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -657,7 +657,7 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async goBackToTimeRange() { + async goToTimeRangeStep() { await testSubjects.existOrFail('mlJobWizardTimeRangeStep', { timeout: 3_000, }); From f5cd43bdf54ee01f0b4bc05d0c5cc8ac1e1aa1b1 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 15:48:04 +0100 Subject: [PATCH 08/44] Change symbol name, per cr. --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 8bd01306bc025..671df0c33c725 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -405,7 +405,7 @@ export default function ({ getService }: FtrProviderContext) { 'Feb 11, 2016 @ 23:59:54.000' ); - await ml.jobWizardCommon.goBackToTimeRange(); + await ml.jobWizardCommon.goToTimeRangeStep(); await ml.jobWizardCommon.assertShortDurationTimeRange(); @@ -418,7 +418,7 @@ export default function ({ getService }: FtrProviderContext) { 'mlValidationCallout-warning-The selected or available time', ]); - await ml.jobWizardCommon.goBackToTimeRange(); + await ml.jobWizardCommon.goToTimeRangeStep(); await ml.jobWizardCommon.clickUseFullDataButton( 'Feb 7, 2016 @ 00:00:00.000', 'Feb 11, 2016 @ 23:59:54.000' From 6602b290f5763c857fa68cde24d1710191022648 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 2 Apr 2024 16:45:22 +0100 Subject: [PATCH 09/44] More cr fixups --- .../apps/ml/anomaly_detection_jobs/index.ts | 1 - .../single_metric_job.ts | 4 +- .../test/functional/services/ml/common_ui.ts | 24 +++++++++++ .../services/ml/job_wizard_common.ts | 42 ++++++------------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts index 68c15ecd08f57..254bd76f5616b 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/index.ts @@ -40,7 +40,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./single_metric_job')); if (!isCcs) { - loadTestFile(require.resolve('./job_wizard_validation')); loadTestFile(require.resolve('./single_metric_job_without_datafeed_start')); loadTestFile(require.resolve('./multi_metric_job')); loadTestFile(require.resolve('./population_job')); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 671df0c33c725..ad69003f03ca7 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -430,13 +430,13 @@ export default function ({ getService }: FtrProviderContext) { }); it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { - await ml.jobWizardCommon.goBackToJobDetailsSection(); + await ml.jobWizardCommon.goBackToJobDetailsStep(); await ml.jobWizardCommon.ensureAdvancedSectionOpen(); await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); }); it('job creation memory limit too large results in validation callout', async () => { - await ml.jobWizardCommon.goBackToJobDetailsSection(); + await ml.jobWizardCommon.goBackToJobDetailsStep(); const tooLarge = '100000000MB'; await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index 98404c88b412e..66e4ca1134318 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -438,5 +438,29 @@ export function MachineLearningCommonUIProvider({ } }); }, + + async getSwitchCheckedState(testSubj: string): Promise { + const isSelected = await testSubjects.getAttribute(testSubj, 'aria-checked'); + return isSelected === 'true'; + }, + + async getAnnotationsSwitchCheckedState(expectedValue: boolean) { + const actualCheckedState = await this.getSwitchCheckedState('mlJobWizardSwitchAnnotations'); + expect(actualCheckedState).to.eql( + expectedValue, + `Expected annotations switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${ + actualCheckedState ? 'enabled' : 'disabled' + }')` + ); + }, + + async toggleSwitchIfNeeded(testSubj: string, targetState: boolean) { + if ((await this.getSwitchCheckedState(testSubj)) !== targetState) { + await retry.tryForTime(5 * 1000, async () => { + await testSubjects.clickWhenNotDisabledWithoutRetry(testSubj); + await this.getSwitchCheckedState(testSubj); + }); + } + }, }; } diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 8516b37ed3529..23dbef178e021 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -620,38 +620,12 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async getAnnotationSwitchCheckedState(): Promise { - const subj = 'mlJobWizardSwitchAnnotations'; - const isSelected = await testSubjects.getAttribute(subj, 'aria-checked'); - return isSelected === 'true'; - }, - - async getAnnotationsSwitchCheckedState(expectedValue: boolean) { - const actualCheckedState = await this.getAnnotationSwitchCheckedState(); - expect(actualCheckedState).to.eql( - expectedValue, - `Expected annotations switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${ - actualCheckedState ? 'enabled' : 'disabled' - }')` - ); - }, - - async toggleAnnotationSwitch(toggle: boolean) { - const subj = 'mlJobWizardSwitchAnnotations'; - if ((await this.getAnnotationSwitchCheckedState()) !== toggle) { - await retry.tryForTime(5 * 1000, async () => { - await testSubjects.clickWhenNotDisabledWithoutRetry(subj); - await this.getAnnotationSwitchCheckedState(); - }); - } - }, - async togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout() { - await this.toggleAnnotationSwitch(false); + await mlCommonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', false); await testSubjects.existOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { timeout: 3_000, }); - await this.toggleAnnotationSwitch(true); + await mlCommonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', true); await testSubjects.missingOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { timeout: 3_000, }); @@ -662,6 +636,9 @@ export function MachineLearningJobWizardCommonProvider( timeout: 3_000, }); await testSubjects.click('mlJobWizardTimeRangeStep'); + await testSubjects.existOrFail('mlJobWizardStepTitleTimeRange', { + timeout: 3_000, + }); }, async assertShortDurationTimeRange() { @@ -687,11 +664,14 @@ export function MachineLearningJobWizardCommonProvider( ); }, - async goBackToJobDetailsSection() { + async goBackToJobDetailsStep() { await testSubjects.existOrFail('mlJobWizardJobDetailsStep', { timeout: 3_000, }); await testSubjects.click('mlJobWizardJobDetailsStep'); + await testSubjects.existOrFail('mlJobWizardStepTitleJobDetails', { + timeout: 3_000, + }); }, async assertValidationCallouts(expectedCallOutSelectors: string[]) { @@ -704,7 +684,9 @@ export function MachineLearningJobWizardCommonProvider( async cloneJob() { await testSubjects.click('euiCollapsedItemActionsButton'); await testSubjects.click('mlActionButtonCloneJob'); - await testSubjects.existOrFail('mlPageJobWizardHeader-single_metric'); + await testSubjects.existOrFail('mlPageJobWizardHeader-single_metric', { + timeout: 3_000, + }); }, }; } From ef73e438b1994225d3127d64906a05d1232ef552 Mon Sep 17 00:00:00 2001 From: Tre Date: Tue, 2 Apr 2024 16:48:05 +0100 Subject: [PATCH 10/44] Update x-pack/plugins/ml/public/application/components/callout/callout.tsx Co-authored-by: Dima Arnautov --- .../ml/public/application/components/callout/callout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/components/callout/callout.tsx b/x-pack/plugins/ml/public/application/components/callout/callout.tsx index 74c6b0c11df71..8c60f87ef2427 100644 --- a/x-pack/plugins/ml/public/application/components/callout/callout.tsx +++ b/x-pack/plugins/ml/public/application/components/callout/callout.tsx @@ -55,7 +55,7 @@ const Message: FC> = ({ text, url }) => ( export const Callout: FC = ({ heading, status, text, url }) => ( <> Date: Wed, 3 Apr 2024 08:26:33 +0100 Subject: [PATCH 11/44] Change for test subjs, per cr. --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index ad69003f03ca7..ad91a725fb92f 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -415,7 +415,8 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.setJobId(`${jobIdClone}-again`); await ml.jobWizardCommon.clickNextButton(); await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-warning-The selected or available time', + 'mlValidationCallout warning', + 'mlValidationCallout error', ]); await ml.jobWizardCommon.goToTimeRangeStep(); @@ -425,7 +426,7 @@ export default function ({ getService }: FtrProviderContext) { ); await ml.jobWizardCommon.advanceToValidationSection(); await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-success-Valid and long enough to model', + 'mlValidationCallout success', ]); }); From 57ed9dfede7e04596e3b6aa0f403d28bde2021e8 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 3 Apr 2024 09:13:33 +0100 Subject: [PATCH 12/44] Fixup assertions, per cr. --- .../anomaly_detection_jobs/single_metric_job.ts | 10 ++++++++-- .../functional/services/ml/job_wizard_common.ts | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index ad91a725fb92f..1532b865d1d82 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -418,6 +418,10 @@ export default function ({ getService }: FtrProviderContext) { 'mlValidationCallout warning', 'mlValidationCallout error', ]); + await ml.jobWizardCommon.assertCalloutText( + 'mlValidationCallout warning', + 'Time range\nThe selected or available time range might be too short. The recommended minimum time range should be at least 2 hours and 25 times the bucket span.' + ); await ml.jobWizardCommon.goToTimeRangeStep(); await ml.jobWizardCommon.clickUseFullDataButton( @@ -425,9 +429,11 @@ export default function ({ getService }: FtrProviderContext) { 'Feb 11, 2016 @ 23:59:54.000' ); await ml.jobWizardCommon.advanceToValidationSection(); - await ml.jobWizardCommon.assertValidationCallouts([ + await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout success']); + await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout success', - ]); + 'Time range\nValid and long enough to model patterns in the data.' + ); }); it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 23dbef178e021..43fc66a69de9b 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -681,6 +681,21 @@ export function MachineLearningJobWizardCommonProvider( }); }, + async assertCalloutText(testSubj: string, text: string) { + const allOfTestSubj = await testSubjects.getVisibleTextAll(testSubj); + console.log(`\nλjs allOfTestSubj: \n${JSON.stringify(allOfTestSubj, null, 2)}`); + + const oneOfVisibleTextMatches = allOfTestSubj.some((visibleText) => visibleText === text); + expect(oneOfVisibleTextMatches).to.eql( + true, + `Expect one of the visible text entries to match [${text}], instead found ${JSON.stringify( + allOfTestSubj, + null, + 2 + )}` + ); + }, + async cloneJob() { await testSubjects.click('euiCollapsedItemActionsButton'); await testSubjects.click('mlActionButtonCloneJob'); From b33540c74ddc3706f1ef33052b039e8d83f314a8 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 3 Apr 2024 09:30:06 +0100 Subject: [PATCH 13/44] assert test subj and text --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 8 +++++--- x-pack/test/functional/services/ml/job_wizard_common.ts | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 1532b865d1d82..2b621c2cc52dc 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -449,9 +449,11 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); await ml.jobWizardCommon.clickNextButton(); - await ml.jobWizardCommon.assertValidationCallouts([ - 'mlValidationCallout-warning-Job will not be able to run in', - ]); + await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout warning']); + await ml.jobWizardCommon.assertCalloutText( + 'mlValidationCallout warning', + 'Job will not be able to run in the current cluster because model memory limit is higher than 9790MB.' + ); }); }); } diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 43fc66a69de9b..e698405d667ed 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -683,7 +683,6 @@ export function MachineLearningJobWizardCommonProvider( async assertCalloutText(testSubj: string, text: string) { const allOfTestSubj = await testSubjects.getVisibleTextAll(testSubj); - console.log(`\nλjs allOfTestSubj: \n${JSON.stringify(allOfTestSubj, null, 2)}`); const oneOfVisibleTextMatches = allOfTestSubj.some((visibleText) => visibleText === text); expect(oneOfVisibleTextMatches).to.eql( From 4e739658c028b74a432ea1530d2254de41c3ff94 Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 5 Apr 2024 12:19:25 +0100 Subject: [PATCH 14/44] Update x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx Co-authored-by: Dima Arnautov --- .../jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx index b9beae433ea4c..a8fe7ffc31711 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx @@ -79,10 +79,6 @@ export const WizardHorizontalSteps: FC = ({ } function createStepProps(step: WIZARD_STEPS) { - let testSubj: string = ''; - if (step === WIZARD_STEPS.TIME_RANGE) testSubj = 'mlJobWizardTimeRangeStep'; - if (step === WIZARD_STEPS.JOB_DETAILS) testSubj = 'mlJobWizardJobDetailsStep'; - return { onClick: () => jumpToStep(step), status: (currentStep === step From 0fca96c7145009f8233cbff73db40505f26b2f69 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Thu, 11 Apr 2024 17:03:10 +0100 Subject: [PATCH 15/44] fixup test subjects && make tsc happy with adding a test subj to the advanced step --- .../jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx index a8fe7ffc31711..1a4f970029e48 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/new_job/wizard_horizontal_steps.tsx @@ -42,30 +42,35 @@ export const WizardHorizontalSteps: FC = ({ defaultMessage: 'Time range', }), ...createStepProps(WIZARD_STEPS.TIME_RANGE), + 'data-test-subj': 'mlJobWizardTimeRangeStep', }, { title: i18n.translate('xpack.ml.newJob.wizard.step.pickFieldsTitle', { defaultMessage: 'Choose fields', }), ...createStepProps(WIZARD_STEPS.PICK_FIELDS), + 'data-test-subj': 'mlJobWizardPickFieldsStep', }, { title: i18n.translate('xpack.ml.newJob.wizard.step.jobDetailsTitle', { defaultMessage: 'Job details', }), ...createStepProps(WIZARD_STEPS.JOB_DETAILS), + 'data-test-subj': 'mlJobWizardJobDetailsStep', }, { title: i18n.translate('xpack.ml.newJob.wizard.step.validationTitle', { defaultMessage: 'Validation', }), ...createStepProps(WIZARD_STEPS.VALIDATION), + 'data-test-subj': 'mlJobWizardValidationStep', }, { title: i18n.translate('xpack.ml.newJob.wizard.step.summaryTitle', { defaultMessage: 'Summary', }), ...createStepProps(WIZARD_STEPS.SUMMARY), + 'data-test-subj': 'mlJobWizardSummaryStep', }, ]; @@ -75,6 +80,7 @@ export const WizardHorizontalSteps: FC = ({ defaultMessage: 'Configure datafeed', }), ...createStepProps(WIZARD_STEPS.ADVANCED_CONFIGURE_DATAFEED), + 'data-test-subj': 'mlJobWizardAdvancedStep', }); } @@ -87,7 +93,6 @@ export const WizardHorizontalSteps: FC = ({ ? 'complete' : 'incomplete') as EuiStepStatus, disabled: disableSteps || highestStep < step, - 'data-test-subj': testSubj, }; } From 3664a943d0c8a22486686b8bef00cfbfa93c5b57 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Thu, 11 Apr 2024 17:05:19 +0100 Subject: [PATCH 16/44] Use optional chaining to make tsc happy. --- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index e698405d667ed..b338f73850e4e 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -645,7 +645,7 @@ export function MachineLearningJobWizardCommonProvider( const { startDate: origStartDate } = await this.getSelectedDateRange(); // calculate the new end datedate - const shortDurationEndDate = `${origStartDate.split(':', 1)[0]}:01:00.000`; + const shortDurationEndDate = `${origStartDate?.split(':', 1)[0]}:01:00.000`; // set the new end date await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', shortDurationEndDate, { From 01be0f46df8753f55149772a5e5e00344797e66e Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 12 Apr 2024 10:48:39 +0100 Subject: [PATCH 17/44] switch to regex as some of the numbers vary --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 6 +++--- x-pack/test/functional/services/ml/job_wizard_common.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 2b621c2cc52dc..d741c9bcbb897 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -420,7 +420,7 @@ export default function ({ getService }: FtrProviderContext) { ]); await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout warning', - 'Time range\nThe selected or available time range might be too short. The recommended minimum time range should be at least 2 hours and 25 times the bucket span.' + /Time range\s*The selected or available time range might be too short/ ); await ml.jobWizardCommon.goToTimeRangeStep(); @@ -432,7 +432,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout success']); await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout success', - 'Time range\nValid and long enough to model patterns in the data.' + /Time range\s*Valid and long enough to model patterns in the data/ ); }); @@ -452,7 +452,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout warning']); await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout warning', - 'Job will not be able to run in the current cluster because model memory limit is higher than 9790MB.' + /Job will not be able to run in the current cluster because model memory limit is higher than/ ); }); }); diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index b338f73850e4e..6d284822ea82b 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -681,10 +681,12 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async assertCalloutText(testSubj: string, text: string) { + async assertCalloutText(testSubj: string, text: RegExp) { const allOfTestSubj = await testSubjects.getVisibleTextAll(testSubj); - const oneOfVisibleTextMatches = allOfTestSubj.some((visibleText) => visibleText === text); + const oneOfVisibleTextMatches = allOfTestSubj.some( + (visibleText) => !!visibleText.match(text) + ); expect(oneOfVisibleTextMatches).to.eql( true, `Expect one of the visible text entries to match [${text}], instead found ${JSON.stringify( From d57bc5957ad3e4ce195e493c9ed6857362e63ead Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 12 Apr 2024 15:47:10 +0100 Subject: [PATCH 18/44] Use an inline level element instead and use preexisting time assertion method. --- .../jobs/new_job/common/components/time_range_picker.tsx | 4 ++-- x-pack/test/functional/services/ml/job_wizard_common.ts | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx index d82cb606fbc71..7bfa461e881cd 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx @@ -85,7 +85,7 @@ export const TimeRangePicker: FC = ({ setTimeRange, timeRange }) => { /> } endDateControl={ -
+ = ({ setTimeRange, timeRange }) => { dateFormat={dateFormat} minDate={startMoment} /> -
+ } /> diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 6d284822ea82b..d57cbac45fa66 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -655,13 +655,9 @@ export function MachineLearningJobWizardCommonProvider( // click away from time popover await testSubjects.click('mlJobWizardTimeRangeStep'); - const { endDate: newEndDate } = await this.getSelectedDateRange(); // assert time is set as expected - expect(newEndDate).to.eql( - shortDurationEndDate, - `Expect [${newEndDate}] to eql [${shortDurationEndDate}]` - ); + await this.assertDateRangeSelection(origStartDate as string, shortDurationEndDate); }, async goBackToJobDetailsStep() { From 9ea07a31300ac3ebb5b6b8ed8ac39bba648a9fe8 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 15 Apr 2024 09:39:25 +0100 Subject: [PATCH 19/44] switch to method --- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index d57cbac45fa66..70505fc9f2adc 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -654,7 +654,7 @@ export function MachineLearningJobWizardCommonProvider( }); // click away from time popover - await testSubjects.click('mlJobWizardTimeRangeStep'); + await this.goToTimeRangeStep(); // assert time is set as expected await this.assertDateRangeSelection(origStartDate as string, shortDurationEndDate); From db7ff28bee1b130e0f97e92586c65f013f1c0255 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 15 Apr 2024 09:44:19 +0100 Subject: [PATCH 20/44] Fixup test subj --- .../functional/services/ml/data_frame_analytics_creation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 50d7738abf732..219918fc36bba 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 @@ -553,7 +553,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider( async assertValidationCalloutsExists() { await retry.tryForTime(4000, async () => { - await testSubjects.existOrFail('mlValidationCallout'); + await testSubjects.existOrFail('~mlValidationCallout'); }); }, From e3d5652c42c4632923ed409f821cfb4f0c99aab9 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 15 Apr 2024 11:19:29 +0100 Subject: [PATCH 21/44] update test subj --- .../functional/services/ml/data_frame_analytics_creation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 219918fc36bba..8e0c1e84b4f5d 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 @@ -558,7 +558,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider( }, async assertAllValidationCalloutsPresent(expectedNumCallouts: number) { - const validationCallouts = await testSubjects.findAll('mlValidationCallout'); + const validationCallouts = await testSubjects.findAll('~mlValidationCallout'); expect(validationCallouts.length).to.eql(expectedNumCallouts); }, From 1bfe1b38d2e71913a921f507213a7853d929ae74 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 15 Apr 2024 13:10:46 +0100 Subject: [PATCH 22/44] change name --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 4 ++-- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index d741c9bcbb897..95a97db92d825 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -437,13 +437,13 @@ export default function ({ getService }: FtrProviderContext) { }); it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { - await ml.jobWizardCommon.goBackToJobDetailsStep(); + await ml.jobWizardCommon.goToJobDetailsStep(); await ml.jobWizardCommon.ensureAdvancedSectionOpen(); await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); }); it('job creation memory limit too large results in validation callout', async () => { - await ml.jobWizardCommon.goBackToJobDetailsStep(); + await ml.jobWizardCommon.goToJobDetailsStep(); const tooLarge = '100000000MB'; await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 70505fc9f2adc..1df2ed8270f79 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -660,7 +660,7 @@ export function MachineLearningJobWizardCommonProvider( await this.assertDateRangeSelection(origStartDate as string, shortDurationEndDate); }, - async goBackToJobDetailsStep() { + async goToJobDetailsStep() { await testSubjects.existOrFail('mlJobWizardJobDetailsStep', { timeout: 3_000, }); From 1f9611a6705951a925efd2e0c0a6f40a8554921e Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 17 Apr 2024 12:08:08 +0100 Subject: [PATCH 23/44] Use popper props per Lene G. --- .../common/components/time_range_picker.tsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx index 7bfa461e881cd..bf52a1638ccbe 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx @@ -85,23 +85,25 @@ export const TimeRangePicker: FC = ({ setTimeRange, timeRange }) => { /> } endDateControl={ - - - + } /> From 6c22755cf512f0c857e587255ef0063e73662c17 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 17 Apr 2024 13:52:24 +0100 Subject: [PATCH 24/44] cleanup --- .../functional/services/ml/job_wizard_common.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 1df2ed8270f79..c6997e5dfc5b9 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -677,16 +677,16 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async assertCalloutText(testSubj: string, text: RegExp) { - const allOfTestSubj = await testSubjects.getVisibleTextAll(testSubj); + async assertCalloutText(calloutStatusTestSubj: string, expectedText: RegExp) { + const allCalloutStatusTexts = await testSubjects.getVisibleTextAll(calloutStatusTestSubj); - const oneOfVisibleTextMatches = allOfTestSubj.some( - (visibleText) => !!visibleText.match(text) + const oneCalloutMatches = allCalloutStatusTexts.some( + (visibleText) => !!visibleText.match(expectedText) ); - expect(oneOfVisibleTextMatches).to.eql( + expect(oneCalloutMatches).to.eql( true, - `Expect one of the visible text entries to match [${text}], instead found ${JSON.stringify( - allOfTestSubj, + `Expect one of the callouts [${calloutStatusTestSubj}] to match [${expectedText}], instead found ${JSON.stringify( + allCalloutStatusTexts, null, 2 )}` From 43d2b26483fcab899903a843f1f94bb0f878e780 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 29 Apr 2024 16:01:26 +0100 Subject: [PATCH 25/44] drop togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout method per cr. --- .../single_metric_job.ts | 7 ++++++- .../services/ml/job_wizard_common.ts | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 95a97db92d825..0b951400d1cce 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -439,7 +439,12 @@ export default function ({ getService }: FtrProviderContext) { it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => { await ml.jobWizardCommon.goToJobDetailsStep(); await ml.jobWizardCommon.ensureAdvancedSectionOpen(); - await ml.jobWizardCommon.togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout(); + + await ml.commonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', false); + await ml.jobWizardCommon.assertAnnotationRecommendationCalloutVisible(); + + await ml.commonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', true); + await ml.jobWizardCommon.assertAnnotationRecommendationCalloutVisible(false); }); it('job creation memory limit too large results in validation callout', async () => { diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index c6997e5dfc5b9..e32ebbf04acba 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -620,15 +620,16 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout() { - await mlCommonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', false); - await testSubjects.existOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { - timeout: 3_000, - }); - await mlCommonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', true); - await testSubjects.missingOrFail('mlJobWizardAlsoEnableAnnotationsRecommendationCallout', { - timeout: 3_000, - }); + async assertAnnotationRecommendationCalloutVisible(expectVisible: boolean = true) { + const callOutTestSubj = 'mlJobWizardAlsoEnableAnnotationsRecommendationCallout'; + if (expectVisible) + await testSubjects.existOrFail(callOutTestSubj, { + timeout: 3_000, + }); + else + await testSubjects.missingOrFail(callOutTestSubj, { + timeout: 3_000, + }); }, async goToTimeRangeStep() { From 9ac54489cdb4848def0add2a53e39a3fb3589a40 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 29 Apr 2024 16:03:49 +0100 Subject: [PATCH 26/44] drop cloneJob method per cr --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- x-pack/test/functional/services/ml/job_wizard_common.ts | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 0b951400d1cce..33626d9600a24 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -394,7 +394,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.navigation.navigateToJobManagement(); await ml.testExecution.logTestStep(`cloning job: [${jobId}]`); - await ml.jobWizardCommon.cloneJob(); + await ml.jobTable.clickCloneJobAction(jobId); await ml.testExecution.logTestStep('job creation displays the time range step'); await ml.jobWizardCommon.assertTimeRangeSectionExists(); diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index e32ebbf04acba..dc4266450f805 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -693,13 +693,5 @@ export function MachineLearningJobWizardCommonProvider( )}` ); }, - - async cloneJob() { - await testSubjects.click('euiCollapsedItemActionsButton'); - await testSubjects.click('mlActionButtonCloneJob'); - await testSubjects.existOrFail('mlPageJobWizardHeader-single_metric', { - timeout: 3_000, - }); - }, }; } From 82afd941532d0cc32196403c66be6e519154c0ea Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 6 May 2024 11:30:09 +0100 Subject: [PATCH 27/44] Drop ts ignore. --- .../jobs/new_job/common/components/time_range_picker.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx index bf52a1638ccbe..c00a68af8af9c 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx @@ -86,7 +86,6 @@ export const TimeRangePicker: FC = ({ setTimeRange, timeRange }) => { } endDateControl={ Date: Mon, 6 May 2024 13:17:36 +0100 Subject: [PATCH 28/44] drop unused method --- x-pack/test/functional/services/ml/common_ui.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index bbb9e208780dc..04f97a51225bb 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -453,16 +453,6 @@ export function MachineLearningCommonUIProvider({ return isSelected === 'true'; }, - async getAnnotationsSwitchCheckedState(expectedValue: boolean) { - const actualCheckedState = await this.getSwitchCheckedState('mlJobWizardSwitchAnnotations'); - expect(actualCheckedState).to.eql( - expectedValue, - `Expected annotations switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${ - actualCheckedState ? 'enabled' : 'disabled' - }')` - ); - }, - async toggleSwitchIfNeeded(testSubj: string, targetState: boolean) { if ((await this.getSwitchCheckedState(testSubj)) !== targetState) { await retry.tryForTime(5 * 1000, async () => { From dfa29d5957e95836cef92d53ade61c9fb5e06254 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 6 May 2024 14:18:45 +0100 Subject: [PATCH 29/44] drop assertShortDurationTimeRange --- .../ml/anomaly_detection_jobs/single_metric_job.ts | 14 +++++++++++++- .../functional/services/ml/job_wizard_common.ts | 10 +--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index bf3dfb644748e..a97161d8a7011 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -408,7 +408,19 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.goToTimeRangeStep(); - await ml.jobWizardCommon.assertShortDurationTimeRange(); + const { startDate: origStartDate } = await ml.jobWizardCommon.getSelectedDateRange(); + + await ml.testExecution.logTestStep('calculate the new end date'); + const shortDurationEndDate = `${origStartDate?.split(':', 1)[0]}:01:00.000`; + + await ml.testExecution.logTestStep('set the new end date'); + await ml.jobWizardCommon.setShortDurationTimeRange(shortDurationEndDate); + + // assert time is set as expected + await ml.jobWizardCommon.assertDateRangeSelection( + origStartDate as string, + shortDurationEndDate + ); await ml.jobWizardCommon.clickNextButton(); await ml.jobWizardCommon.clickNextButton(); diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 76dd30b472c55..477f4a0a21510 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -651,12 +651,7 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async assertShortDurationTimeRange() { - const { startDate: origStartDate } = await this.getSelectedDateRange(); - - // calculate the new end datedate - const shortDurationEndDate = `${origStartDate?.split(':', 1)[0]}:01:00.000`; - + async setShortDurationTimeRange(shortDurationEndDate: string) { // set the new end date await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', shortDurationEndDate, { clearWithKeyboard: true, @@ -665,9 +660,6 @@ export function MachineLearningJobWizardCommonProvider( // click away from time popover await this.goToTimeRangeStep(); - - // assert time is set as expected - await this.assertDateRangeSelection(origStartDate as string, shortDurationEndDate); }, async goToJobDetailsStep() { From c5237caf7125a5782683b2b2488b0e11c34bb87d Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Tue, 7 May 2024 16:29:08 +0100 Subject: [PATCH 30/44] wrap in retry --- .../test/functional/services/ml/job_wizard_common.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 477f4a0a21510..01c65a60fc841 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -642,12 +642,10 @@ export function MachineLearningJobWizardCommonProvider( }, async goToTimeRangeStep() { - await testSubjects.existOrFail('mlJobWizardTimeRangeStep', { - timeout: 3_000, - }); - await testSubjects.click('mlJobWizardTimeRangeStep'); - await testSubjects.existOrFail('mlJobWizardStepTitleTimeRange', { - timeout: 3_000, + await retry.tryForTime(60_000, async () => { + await testSubjects.existOrFail('mlJobWizardTimeRangeStep'); + await testSubjects.click('mlJobWizardTimeRangeStep'); + await testSubjects.existOrFail('mlJobWizardStepTitleTimeRange'); }); }, From 66488da8d0b6df4ea457d9e8c4dc6d993ba3866e Mon Sep 17 00:00:00 2001 From: Tre Date: Wed, 8 May 2024 13:17:03 +0100 Subject: [PATCH 31/44] Update x-pack/test/functional/services/ml/job_wizard_common.ts Co-authored-by: Dima Arnautov --- x-pack/test/functional/services/ml/job_wizard_common.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 01c65a60fc841..d83a689b2f3ef 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -657,7 +657,8 @@ export function MachineLearningJobWizardCommonProvider( }); // click away from time popover - await this.goToTimeRangeStep(); + // escape popover + await browser.pressKeys(browser.keys.ESCAPE); }, async goToJobDetailsStep() { From a7a75e3a7d7c1d03875cd2fc4a70317038197486 Mon Sep 17 00:00:00 2001 From: Tre Date: Wed, 8 May 2024 13:18:03 +0100 Subject: [PATCH 32/44] Update x-pack/test/functional/services/ml/job_wizard_common.ts Co-authored-by: Dima Arnautov --- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index d83a689b2f3ef..03b6b70daeaf4 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -649,7 +649,7 @@ export function MachineLearningJobWizardCommonProvider( }); }, - async setShortDurationTimeRange(shortDurationEndDate: string) { + async setTimeRange(shortDurationEndDate: string) { // set the new end date await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', shortDurationEndDate, { clearWithKeyboard: true, From ea3e6dc0bf854150520a479bc359977cf47a81ba Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 8 May 2024 14:58:53 +0100 Subject: [PATCH 33/44] final fixups? --- .../common/components/time_range_picker.tsx | 3 +++ .../anomaly_detection_jobs/single_metric_job.ts | 4 ++-- .../functional/services/ml/job_wizard_common.ts | 17 ++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx index c00a68af8af9c..c086320718a52 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/components/time_range_picker.tsx @@ -69,6 +69,9 @@ export const TimeRangePicker: FC = ({ setTimeRange, timeRange }) => { fullWidth={true} startDateControl={ Date: Fri, 24 May 2024 13:09:20 +0100 Subject: [PATCH 34/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index bdb3e326f4fcb..dd058b60238d8 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -466,7 +466,7 @@ export default function ({ getService }: FtrProviderContext) { const tooLarge = '100000000MB'; await ml.jobWizardCommon.setModelMemoryLimit(tooLarge); - await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.advanceToValidationSection(); await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout warning']); await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout warning', From a1fe7e4025842d6aa12187690b41c887eab2e3a9 Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:09:56 +0100 Subject: [PATCH 35/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index dd058b60238d8..4c5418ad50089 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -426,7 +426,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobWizardCommon.clickNextButton(); await ml.jobWizardCommon.assertJobIdInputExists(); await ml.jobWizardCommon.setJobId(`${jobIdClone}-again`); - await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.advanceToValidationSection(); await ml.jobWizardCommon.assertValidationCallouts([ 'mlValidationCallout warning', 'mlValidationCallout error', From 0f62a46880d311ea32aa9a37fe43d2d91a7a499b Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:08 +0100 Subject: [PATCH 36/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 4c5418ad50089..d0bd5cd970332 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -422,8 +422,8 @@ export default function ({ getService }: FtrProviderContext) { shortDurationEndDate ); - await ml.jobWizardCommon.clickNextButton(); - await ml.jobWizardCommon.clickNextButton(); + await ml.jobWizardCommon.advanceToPickFieldsSection(); + await ml.jobWizardCommon.advanceToJobDetailsSection(); await ml.jobWizardCommon.assertJobIdInputExists(); await ml.jobWizardCommon.setJobId(`${jobIdClone}-again`); await ml.jobWizardCommon.advanceToValidationSection(); From d8edc00c6f55cbbeedd548435572f422c9e43e4c Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:15 +0100 Subject: [PATCH 37/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index d0bd5cd970332..dda8f5263f0a0 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -400,7 +400,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep('job creation displays the time range step'); await ml.jobWizardCommon.assertTimeRangeSectionExists(); - await ml.testExecution.logTestStep('job creation sets the time range'); + await ml.testExecution.logTestStep('job cloning sets the time range'); await ml.jobWizardCommon.clickUseFullDataButton( 'Feb 7, 2016 @ 00:00:00.000', 'Feb 11, 2016 @ 23:59:54.000' From 9d7a2a2a71b37145898176176cf4b1fc5203d91b Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:24 +0100 Subject: [PATCH 38/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index dda8f5263f0a0..0fceba1eca3db 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -397,7 +397,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.testExecution.logTestStep(`cloning job: [${jobId}]`); await ml.jobTable.clickCloneJobAction(jobId); - await ml.testExecution.logTestStep('job creation displays the time range step'); + await ml.testExecution.logTestStep('job cloning displays the time range step'); await ml.jobWizardCommon.assertTimeRangeSectionExists(); await ml.testExecution.logTestStep('job cloning sets the time range'); From a0e555707dc1f6dbcedd7ddec4dd654b146dd12d Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:35 +0100 Subject: [PATCH 39/44] Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts Co-authored-by: Robert Oskamp --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index 0fceba1eca3db..a4968ec411231 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -390,7 +390,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('job cloning with too short of a job creation time range results in validation callouts', async () => { - await ml.testExecution.logTestStep('job creation loads the job management page'); + await ml.testExecution.logTestStep('job cloning loads the job management page'); await ml.navigation.navigateToMl(); await ml.navigation.navigateToJobManagement(); From 4be34abaf47042550ba9f99a4ad163742d9b19a0 Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:48 +0100 Subject: [PATCH 40/44] Update x-pack/test/functional/services/ml/job_wizard_common.ts Co-authored-by: Robert Oskamp --- x-pack/test/functional/services/ml/job_wizard_common.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 5a9ff7e3ab6c7..0166872af3c73 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -669,9 +669,7 @@ export function MachineLearningJobWizardCommonProvider( timeout: 3_000, }); await testSubjects.click('mlJobWizardJobDetailsStep'); - await testSubjects.existOrFail('mlJobWizardStepTitleJobDetails', { - timeout: 3_000, - }); + await this.assertJobDetailsSectionExists(); }, async assertValidationCallouts(expectedCallOutSelectors: string[]) { From 820e96c838394facd11be239cbf6d36cc9f72d8a Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:10:58 +0100 Subject: [PATCH 41/44] Update x-pack/test/functional/services/ml/job_wizard_common.ts Co-authored-by: Robert Oskamp --- x-pack/test/functional/services/ml/job_wizard_common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index 0166872af3c73..ee8cd0b09018a 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -646,7 +646,7 @@ export function MachineLearningJobWizardCommonProvider( await retry.tryForTime(60_000, async () => { await testSubjects.existOrFail('mlJobWizardTimeRangeStep'); await testSubjects.click('mlJobWizardTimeRangeStep'); - await testSubjects.existOrFail('mlJobWizardStepTitleTimeRange'); + await this.assertTimeRangeSectionExists(); }); }, From 0355263342c86132123593684ff7d5f9350b7d71 Mon Sep 17 00:00:00 2001 From: Tre Date: Fri, 24 May 2024 13:11:20 +0100 Subject: [PATCH 42/44] Update x-pack/test/functional/services/ml/common_ui.ts Co-authored-by: Robert Oskamp --- x-pack/test/functional/services/ml/common_ui.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index 04f97a51225bb..282ae1aba5033 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -448,18 +448,8 @@ export function MachineLearningCommonUIProvider({ } }, - async getSwitchCheckedState(testSubj: string): Promise { - const isSelected = await testSubjects.getAttribute(testSubj, 'aria-checked'); - return isSelected === 'true'; - }, - async toggleSwitchIfNeeded(testSubj: string, targetState: boolean) { - if ((await this.getSwitchCheckedState(testSubj)) !== targetState) { - await retry.tryForTime(5 * 1000, async () => { - await testSubjects.clickWhenNotDisabledWithoutRetry(testSubj); - await this.getSwitchCheckedState(testSubj); - }); - } + await testSubjects.setEuiSwitch(testSubj, targetState ? 'check' : 'uncheck'); }, }; } From dd28646e6a887733eafaf2966684e1122ab70afd Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 24 May 2024 14:18:29 +0100 Subject: [PATCH 43/44] fixups per cr --- .../apps/ml/anomaly_detection_jobs/single_metric_job.ts | 2 +- x-pack/test/functional/services/ml/job_wizard_common.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts index a4968ec411231..957ac090e1ade 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_metric_job.ts @@ -441,7 +441,7 @@ export default function ({ getService }: FtrProviderContext) { 'Feb 7, 2016 @ 00:00:00.000', 'Feb 11, 2016 @ 23:59:54.000' ); - await ml.jobWizardCommon.advanceToValidationSection(); + await ml.jobWizardCommon.goToValidationStep(); await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout success']); await ml.jobWizardCommon.assertCalloutText( 'mlValidationCallout success', diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index ee8cd0b09018a..e89f0033b16b3 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -650,6 +650,13 @@ export function MachineLearningJobWizardCommonProvider( }); }, + async goToValidationStep() { + await retry.tryForTime(60_000, async () => { + await testSubjects.existOrFail('mlJobWizardValidationStep'); + await testSubjects.click('mlJobWizardValidationStep'); + }); + }, + async setTimeRange({ startTime, endTime }: { startTime?: string; endTime?: string }) { const opts = { clearWithKeyboard: true, From d4bea26be7305fe6f5ed90bc3132f2d201e40c1a Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 24 May 2024 16:35:58 +0100 Subject: [PATCH 44/44] add assertion per cr --- x-pack/test/functional/services/ml/job_wizard_common.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test/functional/services/ml/job_wizard_common.ts b/x-pack/test/functional/services/ml/job_wizard_common.ts index e89f0033b16b3..b1671626f191f 100644 --- a/x-pack/test/functional/services/ml/job_wizard_common.ts +++ b/x-pack/test/functional/services/ml/job_wizard_common.ts @@ -654,6 +654,7 @@ export function MachineLearningJobWizardCommonProvider( await retry.tryForTime(60_000, async () => { await testSubjects.existOrFail('mlJobWizardValidationStep'); await testSubjects.click('mlJobWizardValidationStep'); + await this.assertValidationSectionExists(); }); },