diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_integrations/lens_to_ml.ts b/x-pack/test/functional/apps/ml/anomaly_detection_integrations/lens_to_ml.ts index 935ae3c599ac0..bb9c58991a28d 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_integrations/lens_to_ml.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_integrations/lens_to_ml.ts @@ -38,6 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('create jobs from lens', function () { this.tags(['ml']); + let jobId: string; before(async () => { await ml.testResources.setKibanaTimeZoneToUTC(); @@ -57,9 +58,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToApp('dashboard'); }); + afterEach(async () => { + await ml.api.deleteAnomalyDetectionJobES(jobId); + }); + it('can create a single metric job from vis with single layer', async () => { const selectedPanelTitle = 'panel2'; - const jobId = 'job_from_lens_1'; + jobId = 'job_from_lens_1'; const numberOfCompatibleLayers = 1; const layerIndex = 0; @@ -87,13 +92,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await ml.jobSelection.assertJobSelection([jobId]); await ml.api.assertModelMemoryLimitForJob(jobId, '11mb'); - - await ml.api.deleteAnomalyDetectionJobES(jobId); }); it('can create multi metric job from vis with single layer', async () => { const selectedPanelTitle = 'panel1'; - const jobId = 'job_from_lens_2'; + jobId = 'job_from_lens_2'; const numberOfCompatibleLayers = 1; const layerIndex = 0; @@ -121,8 +124,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await ml.jobSelection.assertJobSelection([jobId]); await ml.api.assertModelMemoryLimitForJob(jobId, '12mb'); - - await ml.api.deleteAnomalyDetectionJobES(jobId); }); }); }