From 8569adc0dcffbc31f29486be23a7abfc0c07af21 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Fri, 20 Sep 2019 21:37:38 +0200 Subject: [PATCH] [ML] Update navigation tests to handle main and sub tabs (#45793) (#46242) This PR updates the navigation tests to handle and validate the new main and sub tabs. --- .../components/navigation_menu/main_tabs.tsx | 10 +-- .../components/navigation_menu/tabs.tsx | 13 ++-- .../functional/apps/machine_learning/pages.ts | 11 ++- .../machine_learning/data_frame_analytics.ts | 17 +++++ .../services/machine_learning/index.ts | 1 + .../services/machine_learning/navigation.ts | 69 +++++++++++++++---- x-pack/test/functional/services/ml.ts | 3 + 7 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 x-pack/test/functional/services/machine_learning/data_frame_analytics.ts diff --git a/x-pack/legacy/plugins/ml/public/components/navigation_menu/main_tabs.tsx b/x-pack/legacy/plugins/ml/public/components/navigation_menu/main_tabs.tsx index 3e72e50ec45c1..1b2b3e61a27c4 100644 --- a/x-pack/legacy/plugins/ml/public/components/navigation_menu/main_tabs.tsx +++ b/x-pack/legacy/plugins/ml/public/components/navigation_menu/main_tabs.tsx @@ -67,10 +67,10 @@ interface TabData { const TAB_DATA: Record = { // overview: { testSubject: 'mlTabOverview', pathId: 'overview' }, - anomaly_detection: { testSubject: 'mlTabAnomalyDetection', pathId: 'jobs' }, - data_frames: { testSubject: 'mlTabDataFrames' }, - data_frame_analytics: { testSubject: 'mlTabDataFrameAnalytics' }, - datavisualizer: { testSubject: 'mlTabDataVisualizer' }, + anomaly_detection: { testSubject: 'mlMainTab anomalyDetection', pathId: 'jobs' }, + data_frames: { testSubject: 'mlMainTab dataFrames' }, + data_frame_analytics: { testSubject: 'mlMainTab dataFrameAnalytics' }, + datavisualizer: { testSubject: 'mlMainTab dataVisualizer' }, }; export const MainTabs: FC = ({ tabId, disableLinks }) => { @@ -89,7 +89,7 @@ export const MainTabs: FC = ({ tabId, disableLinks }) => { const defaultPathId = TAB_DATA[id].pathId || id; return ( = ({ tabId, mainTabId, disableLinks }) => { const id = tab.id; return ( { + await ml.navigation.navigateToAnomalyDetection(); + }); + it('loads the job management page', async () => { await ml.navigation.navigateToJobManagement(); await ml.jobManagement.assertJobStatsBarExists(); @@ -32,7 +36,7 @@ export default function({ getService }: FtrProviderContext) { }); it('loads the anomaly explorer page', async () => { - await ml.navigation.navigateToAnomalyExplorert(); + await ml.navigation.navigateToAnomalyExplorer(); await ml.anomalyExplorer.assertAnomalyExplorerEmptyListMessageExists(); }); @@ -52,6 +56,11 @@ export default function({ getService }: FtrProviderContext) { await ml.dataFrames.assertDataFrameEmptyListMessageExists(); }); + it('loads the data frame analytics page', async () => { + await ml.navigation.navigateToDataFrameAnalytics(); + await ml.dataFrameAnalytics.assertEmptyListMessageExists(); + }); + it('loads the data visualizer page', async () => { await ml.navigation.navigateToDataVisualizer(); await ml.dataVisualizer.assertDataVisualizerImportDataCardExists(); diff --git a/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts b/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts new file mode 100644 index 0000000000000..fe7f16eea642d --- /dev/null +++ b/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export function MachineLearningDataFrameAnalyticsProvider({ getService }: FtrProviderContext) { + const testSubjects = getService('testSubjects'); + + return { + async assertEmptyListMessageExists() { + await testSubjects.existOrFail('mlNoDataFrameAnalyticsFound'); + }, + }; +} diff --git a/x-pack/test/functional/services/machine_learning/index.ts b/x-pack/test/functional/services/machine_learning/index.ts index 56b0e835124de..9e2f70c1827ff 100644 --- a/x-pack/test/functional/services/machine_learning/index.ts +++ b/x-pack/test/functional/services/machine_learning/index.ts @@ -6,6 +6,7 @@ export { MachineLearningAnomalyExplorerProvider } from './anomaly_explorer'; export { MachineLearningAPIProvider } from './api'; +export { MachineLearningDataFrameAnalyticsProvider } from './data_frame_analytics'; export { MachineLearningDataFramesProvider } from './data_frames'; export { MachineLearningDataVisualizerProvider } from './data_visualizer'; export { MachineLearningJobManagementProvider } from './job_management'; diff --git a/x-pack/test/functional/services/machine_learning/navigation.ts b/x-pack/test/functional/services/machine_learning/navigation.ts index 652a82239efc6..3ddf7196c52bb 100644 --- a/x-pack/test/functional/services/machine_learning/navigation.ts +++ b/x-pack/test/functional/services/machine_learning/navigation.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; @@ -19,37 +20,79 @@ export function MachineLearningNavigationProvider({ return await PageObjects.common.navigateToApp('ml'); }, + async assertTabsExist(tabTypeSubject: string, areaSubjects: string[]) { + await retry.try(async () => { + expect(await testSubjects.findAll(`~${tabTypeSubject}`, 3)).to.have.length( + areaSubjects.length + ); + for (const areaSubj of areaSubjects) { + await testSubjects.existOrFail(`~${tabTypeSubject}&~${areaSubj}`); + } + }); + }, + async navigateToArea(linkSubject: string, pageSubject: string) { await retry.try(async () => { - if ((await testSubjects.exists(pageSubject)) === false) { + if ((await testSubjects.exists(`${linkSubject} selected`)) === false) { await testSubjects.click(linkSubject); + await testSubjects.existOrFail(`${linkSubject} selected`); await testSubjects.existOrFail(pageSubject); } }); }, - async navigateToJobManagement() { - await this.navigateToArea('mlTabJobManagement', 'mlPageJobManagement'); + async assertMainTabsExist() { + await this.assertTabsExist('mlMainTab', [ + 'anomalyDetection', + 'dataFrames', + 'dataFrameAnalytics', + 'dataVisualizer', + ]); }, - async navigateToAnomalyExplorert() { - await this.navigateToArea('mlTabAnomalyExplorer', 'mlPageAnomalyExplorer'); + async navigateToAnomalyDetection() { + await this.navigateToArea('mlMainTab anomalyDetection', 'mlPageJobManagement'); + await this.assertTabsExist('mlSubTab', [ + 'jobManagement', + 'anomalyExplorer', + 'singleMetricViewer', + 'settings', + ]); }, - async navigateToSingleMetricViewer() { - await this.navigateToArea('mlTabSingleMetricViewer', 'mlPageSingleMetricViewer'); + async navigateToDataFrames() { + await this.navigateToArea('mlMainTab dataFrames', 'mlPageDataFrame'); + await this.assertTabsExist('mlSubTab', []); }, - async navigateToSettings() { - await this.navigateToArea('mlTabSettings', 'mlPageSettings'); + async navigateToDataFrameAnalytics() { + await this.navigateToArea('mlMainTab dataFrameAnalytics', 'mlPageDataFrameAnalytics'); + await this.assertTabsExist('mlSubTab', []); }, - async navigateToDataFrames() { - await this.navigateToArea('mlTabDataFrames', 'mlPageDataFrame'); + async navigateToDataVisualizer() { + await this.navigateToArea('mlMainTab dataVisualizer', 'mlPageDataVisualizerSelector'); + await this.assertTabsExist('mlSubTab', []); }, - async navigateToDataVisualizer() { - await this.navigateToArea('mlTabDataVisualizer', 'mlPageDataVisualizerSelector'); + async navigateToJobManagement() { + await this.navigateToAnomalyDetection(); + await this.navigateToArea('mlSubTab jobManagement', 'mlPageJobManagement'); + }, + + async navigateToAnomalyExplorer() { + await this.navigateToAnomalyDetection(); + await this.navigateToArea('mlSubTab anomalyExplorer', 'mlPageAnomalyExplorer'); + }, + + async navigateToSingleMetricViewer() { + await this.navigateToAnomalyDetection(); + await this.navigateToArea('mlSubTab singleMetricViewer', 'mlPageSingleMetricViewer'); + }, + + async navigateToSettings() { + await this.navigateToAnomalyDetection(); + await this.navigateToArea('mlSubTab settings', 'mlPageSettings'); }, }; } diff --git a/x-pack/test/functional/services/ml.ts b/x-pack/test/functional/services/ml.ts index c063a48b81eaa..5b2f168301818 100644 --- a/x-pack/test/functional/services/ml.ts +++ b/x-pack/test/functional/services/ml.ts @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; import { MachineLearningAnomalyExplorerProvider, MachineLearningAPIProvider, + MachineLearningDataFrameAnalyticsProvider, MachineLearningDataFramesProvider, MachineLearningDataVisualizerProvider, MachineLearningJobManagementProvider, @@ -26,6 +27,7 @@ import { export function MachineLearningProvider(context: FtrProviderContext) { const anomalyExplorer = MachineLearningAnomalyExplorerProvider(context); const api = MachineLearningAPIProvider(context); + const dataFrameAnalytics = MachineLearningDataFrameAnalyticsProvider(context); const dataFrames = MachineLearningDataFramesProvider(context); const dataVisualizer = MachineLearningDataVisualizerProvider(context); const jobManagement = MachineLearningJobManagementProvider(context); @@ -42,6 +44,7 @@ export function MachineLearningProvider(context: FtrProviderContext) { return { anomalyExplorer, api, + dataFrameAnalytics, dataFrames, dataVisualizer, jobManagement,