From 5b3411af77445d46f2508e14d8c9b09662cedd42 Mon Sep 17 00:00:00 2001 From: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:14:12 +0100 Subject: [PATCH] [ML] Memory usage accessibility tests (#198306) ## Summary Adds accessibility tests for the ML memory usage page. --- .../apps/group2/ml_memory_usage.ts | 55 +++++++++++++++++++ .../functional/services/ml/memory_usage.ts | 7 ++- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 x-pack/test/accessibility/apps/group2/ml_memory_usage.ts diff --git a/x-pack/test/accessibility/apps/group2/ml_memory_usage.ts b/x-pack/test/accessibility/apps/group2/ml_memory_usage.ts new file mode 100644 index 0000000000000..363aa2bab1197 --- /dev/null +++ b/x-pack/test/accessibility/apps/group2/ml_memory_usage.ts @@ -0,0 +1,55 @@ +/* + * 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 { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const a11y = getService('a11y'); + const ml = getService('ml'); + + const jobId = 'sample_job'; + + describe('machine learning memory usage page Accessibility', function () { + before(async () => { + await ml.securityCommon.createMlRoles(); + await ml.securityCommon.createMlUsers(); + await ml.securityUI.loginAsMlPowerUser(); + + const jobConfig = ml.commonConfig.getADFqSingleMetricJobConfig(jobId); + await ml.api.createAnomalyDetectionJob(jobConfig); + await ml.api.openAnomalyDetectionJob(jobId); + + await ml.navigation.navigateToMl(); + await ml.navigation.navigateToMemoryUsage(); + }); + + after(async () => { + await ml.securityCommon.cleanMlUsers(); + await ml.securityCommon.cleanMlRoles(); + + await ml.api.closeAnomalyDetectionJob(jobId); + await ml.api.cleanMlIndices(); + }); + + it('memory usage - nodes tab - page', async () => { + await a11y.testAppSnapshot(); + }); + + it('memory usage - nodes tab - node details and node memory usage', async () => { + await ml.memoryUsage.expandRow(); + await a11y.testAppSnapshot(); + + await ml.memoryUsage.selectNodeExpandedRowTab('mlNodesOverviewPanelMemoryTab'); + await a11y.testAppSnapshot(); + }); + + it('memory usage - memory usage tab - page', async () => { + await ml.memoryUsage.selectTab('memory-usage'); + await a11y.testAppSnapshot(); + }); + }); +} diff --git a/x-pack/test/functional/services/ml/memory_usage.ts b/x-pack/test/functional/services/ml/memory_usage.ts index 76d6259bc57d5..dadb1d10b2b83 100644 --- a/x-pack/test/functional/services/ml/memory_usage.ts +++ b/x-pack/test/functional/services/ml/memory_usage.ts @@ -8,6 +8,9 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; +type NodeExpandedRowTab = 'mlNodesOverviewPanelMemoryTab' | 'mlNodesOverviewPanelDetailsTab'; +type PageTab = 'memory-usage' | 'nodes'; + export function MachineLearningMemoryUsageProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const comboBox = getService('comboBox'); @@ -22,7 +25,7 @@ export function MachineLearningMemoryUsageProvider({ getService }: FtrProviderCo await testSubjects.existOrFail(`mlNodesOverviewPanel ${tabName}Tab`); }, - async selectTab(tabName: string) { + async selectTab(tabName: PageTab) { await testSubjects.click(`mlMemoryUsageTab-${tabName}`); }, @@ -79,7 +82,7 @@ export function MachineLearningMemoryUsageProvider({ getService }: FtrProviderCo await testSubjects.setValue('mlNodesTableSearchInput', nodeId); }, - async selectNodeExpandedRowTab(tabName: string) { + async selectNodeExpandedRowTab(tabName: NodeExpandedRowTab) { await testSubjects.click(tabName); },