From fb3ff93e6f07d62d2ec453fe47f0b6741b8a7a51 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Wed, 23 Oct 2024 15:50:36 +0200 Subject: [PATCH 1/2] trained models accessibility tests --- .../components/help_icon/help_icon.tsx | 8 +-- .../test/accessibility/apps/group2/index.ts | 1 + .../apps/group2/ml_trained_models.ts | 66 +++++++++++++++++++ .../services/ml/add_trained_models_flyout.ts | 4 ++ 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 x-pack/test/accessibility/apps/group2/ml_trained_models.ts diff --git a/x-pack/plugins/ml/public/application/components/help_icon/help_icon.tsx b/x-pack/plugins/ml/public/application/components/help_icon/help_icon.tsx index 415c00092f73f..ec80630dd18c9 100644 --- a/x-pack/plugins/ml/public/application/components/help_icon/help_icon.tsx +++ b/x-pack/plugins/ml/public/application/components/help_icon/help_icon.tsx @@ -12,13 +12,7 @@ import { EuiIcon, EuiToolTip } from '@elastic/eui'; export const HelpIcon: FC<{ content: ReactNode | string }> = ({ content }) => { return ( - + ); }; diff --git a/x-pack/test/accessibility/apps/group2/index.ts b/x-pack/test/accessibility/apps/group2/index.ts index 2c6bf4e58a08b..787494c7874b4 100644 --- a/x-pack/test/accessibility/apps/group2/index.ts +++ b/x-pack/test/accessibility/apps/group2/index.ts @@ -13,5 +13,6 @@ export default ({ loadTestFile }: FtrProviderContext): void => { loadTestFile(require.resolve('./ml_anomaly_detection')); loadTestFile(require.resolve('./transform')); loadTestFile(require.resolve('./lens')); + loadTestFile(require.resolve('./ml_trained_models')); }); }; diff --git a/x-pack/test/accessibility/apps/group2/ml_trained_models.ts b/x-pack/test/accessibility/apps/group2/ml_trained_models.ts new file mode 100644 index 0000000000000..0c29b415586fa --- /dev/null +++ b/x-pack/test/accessibility/apps/group2/ml_trained_models.ts @@ -0,0 +1,66 @@ +/* + * 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'); + + describe('machine learning trained models page Accessibility', function () { + before(async () => { + await ml.securityCommon.createMlRoles(); + await ml.securityCommon.createMlUsers(); + await ml.securityUI.loginAsMlPowerUser(); + await ml.navigation.navigateToMl(); + await ml.navigation.navigateToTrainedModels(); + }); + + after(async () => { + await ml.securityCommon.cleanMlUsers(); + await ml.securityCommon.cleanMlRoles(); + await ml.securityUI.logout(); + }); + + it('trained models list', async () => { + await a11y.testAppSnapshot(); + }); + + it('trained model details', async () => { + await ml.trainedModelsTable.ensureRowIsExpanded('lang_ident_model_1'); + await a11y.testAppSnapshot(); + + await ml.testExecution.logTestStep('Assert the Details tab content'); + await ml.trainedModelsTable.assertDetailsTabContent(); + await a11y.testAppSnapshot(); + + await ml.testExecution.logTestStep('Assert the Models Map tab content'); + await ml.trainedModelsTable.assertModelsMapTabContent(); + await a11y.testAppSnapshot(); + + await ml.testExecution.logTestStep('Assert the Inference Config tab content'); + await ml.trainedModelsTable.assertInferenceConfigTabContent(); + await a11y.testAppSnapshot(); + + await ml.testExecution.logTestStep('Assert the Stats tab content'); + await ml.trainedModelsTable.assertStatsTabContent(); + await a11y.testAppSnapshot(); + + await ml.testExecution.logTestStep('Assert the Pipelines tab content'); + await ml.trainedModelsTable.assertPipelinesTabContent(); + await a11y.testAppSnapshot(); + }); + + it('add trained model flyout', async () => { + await ml.trainedModelsFlyout.open(); + await a11y.testAppSnapshot(); + + await ml.trainedModelsFlyout.changeTab('manualDownload'); + await a11y.testAppSnapshot(); + }); + }); +} diff --git a/x-pack/test/functional/services/ml/add_trained_models_flyout.ts b/x-pack/test/functional/services/ml/add_trained_models_flyout.ts index 3c3c1681a2f80..511f5e1b9437c 100644 --- a/x-pack/test/functional/services/ml/add_trained_models_flyout.ts +++ b/x-pack/test/functional/services/ml/add_trained_models_flyout.ts @@ -93,6 +93,10 @@ export function TrainedModelsFlyoutProvider({ getService }: FtrProviderContext) }); }, + async changeTab(tab: AddModelFlyoutTabId) { + await testSubjects.click(`mlAddTrainedModelFlyoutTab ${tab}`); + }, + async assertElandPythonClientCodeBlocks() { expect(await testSubjects.getVisibleText('mlElandPipInstallCodeBlock')).to.match( /python -m pip install eland/ From 673d955875bb9a058c5344f21549503c9555efe2 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Thu, 24 Oct 2024 10:03:44 +0200 Subject: [PATCH 2/2] create ingest pipeline for the tested model --- x-pack/test/accessibility/apps/group2/ml_trained_models.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/test/accessibility/apps/group2/ml_trained_models.ts b/x-pack/test/accessibility/apps/group2/ml_trained_models.ts index 0c29b415586fa..e9dcd18a7634f 100644 --- a/x-pack/test/accessibility/apps/group2/ml_trained_models.ts +++ b/x-pack/test/accessibility/apps/group2/ml_trained_models.ts @@ -11,16 +11,21 @@ export default function ({ getService }: FtrProviderContext) { const a11y = getService('a11y'); const ml = getService('ml'); + const testModelId = 'lang_ident_model_1'; + describe('machine learning trained models page Accessibility', function () { before(async () => { await ml.securityCommon.createMlRoles(); await ml.securityCommon.createMlUsers(); + await ml.api.createIngestPipeline(testModelId); await ml.securityUI.loginAsMlPowerUser(); await ml.navigation.navigateToMl(); await ml.navigation.navigateToTrainedModels(); }); after(async () => { + await ml.api.deleteIngestPipeline(testModelId); + await ml.securityCommon.cleanMlUsers(); await ml.securityCommon.cleanMlRoles(); await ml.securityUI.logout(); @@ -31,7 +36,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('trained model details', async () => { - await ml.trainedModelsTable.ensureRowIsExpanded('lang_ident_model_1'); + await ml.trainedModelsTable.ensureRowIsExpanded(testModelId); await a11y.testAppSnapshot(); await ml.testExecution.logTestStep('Assert the Details tab content');