diff --git a/x-pack/test/functional/services/ml/memory_usage.ts b/x-pack/test/functional/services/ml/memory_usage.ts index dadb1d10b2b83..64c9483c4f488 100644 --- a/x-pack/test/functional/services/ml/memory_usage.ts +++ b/x-pack/test/functional/services/ml/memory_usage.ts @@ -106,5 +106,13 @@ export function MachineLearningMemoryUsageProvider({ getService }: FtrProviderCo async assertEmptyTreeChartExists() { await testSubjects.existOrFail('mlJobTreeMap empty'); }, + + async assertJobTreeComboBoxExists() { + await testSubjects.existOrFail('mlJobTreeMapComboBox'); + }, + + async getJobTreeComboBoxOptions() { + return await comboBox.getOptions('mlJobTreeMapComboBox'); + }, }; } diff --git a/x-pack/test/functional/services/ml/notifications.ts b/x-pack/test/functional/services/ml/notifications.ts index 2365717d7226b..fb8d803cbb57f 100644 --- a/x-pack/test/functional/services/ml/notifications.ts +++ b/x-pack/test/functional/services/ml/notifications.ts @@ -16,6 +16,7 @@ export function NotificationsProvider( tableService: MlTableService ) { const testSubjects = getService('testSubjects'); + const find = getService('find'); return { async assertNotificationIndicatorExist(expectExist = true) { @@ -31,6 +32,21 @@ export function NotificationsProvider( expect(actualCount).to.greaterThan(expectedCount); }, + // This is a workaround for receiving available filter dropdown options, + // since EUI doesn't allow testSubjects for filters. + async getAvailableTypeFilters() { + const filterButton = await find.byCssSelector( + '.euiFilterGroup > *:nth-child(2) .euiFilterButton' + ); + await filterButton.click(); + const optionElements = await find.allByCssSelector('li[role="option"].euiSelectableListItem'); + const optionTexts = await Promise.all( + optionElements.map(async (element) => await element.getVisibleText()) + ); + + return optionTexts; + }, + table: tableService.getServiceInstance( 'NotificationsTable', 'mlNotificationsTable', diff --git a/x-pack/test_serverless/functional/services/ml/observability_navigation.ts b/x-pack/test_serverless/functional/services/ml/observability_navigation.ts index 5181d4981321a..83bfc80c462f5 100644 --- a/x-pack/test_serverless/functional/services/ml/observability_navigation.ts +++ b/x-pack/test_serverless/functional/services/ml/observability_navigation.ts @@ -26,5 +26,11 @@ export function MachineLearningNavigationProviderObservability({ async navigateToAnomalyDetection() { await navigateToArea('anomalyDetection'); }, + async navigateToMemoryUsage() { + await navigateToArea('memoryUsage'); + }, + async navigateToNotifications() { + await navigateToArea('notifications'); + }, }; } diff --git a/x-pack/test_serverless/functional/services/ml/security_navigation.ts b/x-pack/test_serverless/functional/services/ml/security_navigation.ts index 17ebe65b45194..70db8900b93e4 100644 --- a/x-pack/test_serverless/functional/services/ml/security_navigation.ts +++ b/x-pack/test_serverless/functional/services/ml/security_navigation.ts @@ -28,5 +28,11 @@ export function MachineLearningNavigationProviderSecurity({ getService }: FtrPro async navigateToTrainedModels() { await navigateToArea('nodesOverview'); }, + async navigateToMemoryUsage() { + await navigateToArea('memoryUsage'); + }, + async navigateToNotifications() { + await navigateToArea('notifications'); + }, }; } diff --git a/x-pack/test_serverless/functional/test_suites/observability/ml/index.ts b/x-pack/test_serverless/functional/test_suites/observability/ml/index.ts index ba88fce593abf..6a9b475f479b5 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/ml/index.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/ml/index.ts @@ -14,5 +14,7 @@ export default function ({ loadTestFile }: FtrProviderContext) { this.tags(['failsOnMKI']); loadTestFile(require.resolve('./anomaly_detection_jobs_list')); loadTestFile(require.resolve('./search_bar_features')); + loadTestFile(require.resolve('./memory_usage')); + loadTestFile(require.resolve('./notifications')); }); } diff --git a/x-pack/test_serverless/functional/test_suites/observability/ml/memory_usage.ts b/x-pack/test_serverless/functional/test_suites/observability/ml/memory_usage.ts new file mode 100644 index 0000000000000..98906601f3a14 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/observability/ml/memory_usage.ts @@ -0,0 +1,37 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const ml = getService('ml'); + const svlMl = getService('svlMl'); + const PageObjects = getPageObjects(['svlCommonPage']); + + const availableMLObjectTypes = ['Anomaly detection jobs', 'Trained models']; + + describe('Memory usage page', function () { + before(async () => { + await PageObjects.svlCommonPage.loginWithPrivilegedRole(); + }); + + it('opens page with all available ML object types for Observability', async () => { + await ml.navigation.navigateToMl(); + await svlMl.navigation.observability.navigateToMemoryUsage(); + + await ml.memoryUsage.assertJobTreeComboBoxExists(); + + const selectedItems = await ml.memoryUsage.getSelectedChartItems(); + expect(selectedItems).to.eql(availableMLObjectTypes); + + // Make sure there are no other available indicies + const options = await ml.memoryUsage.getJobTreeComboBoxOptions(); + expect(options).empty(); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/ml/notifications.ts b/x-pack/test_serverless/functional/test_suites/observability/ml/notifications.ts new file mode 100644 index 0000000000000..c4119bec904aa --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/observability/ml/notifications.ts @@ -0,0 +1,30 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const ml = getService('ml'); + const svlMl = getService('svlMl'); + const PageObjects = getPageObjects(['svlCommonPage']); + + const expectedObservabilityTypeFilters = ['Anomaly Detection', 'Inference', 'System']; + + describe('Notifications page', function () { + before(async () => { + await PageObjects.svlCommonPage.loginWithPrivilegedRole(); + }); + + it('displays only notification types for observability projects', async () => { + await svlMl.navigation.observability.navigateToNotifications(); + const availableTypeFilters = await ml.notifications.getAvailableTypeFilters(); + + expect(availableTypeFilters).to.eql(expectedObservabilityTypeFilters); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/ml/index.ts b/x-pack/test_serverless/functional/test_suites/security/ml/index.ts index 5b486161646df..ef2108b99f4eb 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ml/index.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ml/index.ts @@ -13,5 +13,7 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./data_frame_analytics_jobs_list')); loadTestFile(require.resolve('./trained_models_list')); loadTestFile(require.resolve('./search_bar_features')); + loadTestFile(require.resolve('./memory_usage')); + loadTestFile(require.resolve('./notifications')); }); } diff --git a/x-pack/test_serverless/functional/test_suites/security/ml/memory_usage.ts b/x-pack/test_serverless/functional/test_suites/security/ml/memory_usage.ts new file mode 100644 index 0000000000000..15be625d0510f --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/ml/memory_usage.ts @@ -0,0 +1,41 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const ml = getService('ml'); + const svlMl = getService('svlMl'); + const PageObjects = getPageObjects(['svlCommonPage']); + + const availableMLObjectTypes = [ + 'Anomaly detection jobs', + 'Data frame analytics jobs', + 'Trained models', + ]; + + describe('Memory usage page', function () { + before(async () => { + await PageObjects.svlCommonPage.loginWithPrivilegedRole(); + }); + + it('opens page with all available ML object types for Security', async () => { + await ml.navigation.navigateToMl(); + await svlMl.navigation.security.navigateToMemoryUsage(); + + await ml.memoryUsage.assertJobTreeComboBoxExists(); + + const selectedItems = await ml.memoryUsage.getSelectedChartItems(); + expect(selectedItems).to.eql(availableMLObjectTypes); + + // Make sure there are no other available indicies + const options = await ml.memoryUsage.getJobTreeComboBoxOptions(); + expect(options).empty(); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/ml/notifications.ts b/x-pack/test_serverless/functional/test_suites/security/ml/notifications.ts new file mode 100644 index 0000000000000..7d8ecec984957 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/ml/notifications.ts @@ -0,0 +1,35 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const ml = getService('ml'); + const svlMl = getService('svlMl'); + const PageObjects = getPageObjects(['svlCommonPage']); + + const expectedSecurityTypeFilters = [ + 'Anomaly Detection', + 'Data Frame Analytics', + 'Inference', + 'System', + ]; + + describe('Notifications page', function () { + before(async () => { + await PageObjects.svlCommonPage.loginWithPrivilegedRole(); + }); + + it('displays only notification types for security projects', async () => { + await svlMl.navigation.security.navigateToNotifications(); + const availableTypeFilters = await ml.notifications.getAvailableTypeFilters(); + + expect(availableTypeFilters).to.eql(expectedSecurityTypeFilters); + }); + }); +}