diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts index a187a857c3f38..5a8b9bfc114ee 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts @@ -328,16 +328,15 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataVisualizerIndexBased.assertTotalDocCountChartExist(); await ml.testExecution.logTestStep( - `${testData.suiteTitle} displays elements in the search panel correctly` + `${testData.suiteTitle} displays elements in the data visualizer table correctly` ); + await ml.dataVisualizerIndexBased.assertDataVisualizerTableExist(); + await ml.dataVisualizerTable.assertSearchPanelExist(); await ml.dataVisualizerTable.assertSampleSizeInputExists(); await ml.dataVisualizerTable.assertFieldTypeInputExists(); await ml.dataVisualizerTable.assertFieldNameInputExists(); - await ml.testExecution.logTestStep( - `${testData.suiteTitle} displays elements in the field count panel correctly` - ); await ml.dataVisualizerIndexBased.assertFieldCountPanelExist(); await ml.dataVisualizerIndexBased.assertMetricFieldsSummaryExist(); await ml.dataVisualizerIndexBased.assertFieldsSummaryExist(); @@ -352,11 +351,6 @@ export default function ({ getService }: FtrProviderContext) { ); await ml.dataVisualizerIndexBased.assertTotalFieldsCount(testData.expected.totalFieldsCount); - await ml.testExecution.logTestStep( - `${testData.suiteTitle} displays the data visualizer table` - ); - await ml.dataVisualizerIndexBased.assertDataVisualizerTableExist(); - await ml.testExecution.logTestStep( 'displays details for metric fields and non-metric fields correctly' ); diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index ef2fccab8a2cc..8113a1ab9ac5f 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -20,6 +20,7 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte const retry = getService('retry'); const testSubjects = getService('testSubjects'); const find = getService('find'); + const browser = getService('browser'); return { async setValueWithChecks( @@ -116,5 +117,49 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte await label.click(); await this.assertRadioGroupValue(testSubject, value); }, + + async setMultiSelectFilter(testDataSubj: string, fieldTypes: string[]) { + await testSubjects.clickWhenNotDisabled(`${testDataSubj}-button`); + await testSubjects.existOrFail(`${testDataSubj}-popover`); + await testSubjects.existOrFail(`${testDataSubj}-searchInput`); + const searchBarInput = await testSubjects.find(`${testDataSubj}-searchInput`); + + for (const fieldType of fieldTypes) { + await retry.tryForTime(5000, async () => { + await searchBarInput.clearValueWithKeyboard(); + await searchBarInput.type(fieldType); + if (!(await testSubjects.exists(`${testDataSubj}-option-${fieldType}-checked`))) { + await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}`); + await testSubjects.click(`${testDataSubj}-option-${fieldType}`); + await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}-checked`); + } + }); + } + + // escape popover + await browser.pressKeys(browser.keys.ESCAPE); + }, + + async removeMultiSelectFilter(testDataSubj: string, fieldTypes: string[]) { + await testSubjects.clickWhenNotDisabled(`${testDataSubj}-button`); + await testSubjects.existOrFail(`${testDataSubj}-popover`); + await testSubjects.existOrFail(`${testDataSubj}-searchInput`); + const searchBarInput = await testSubjects.find(`${testDataSubj}-searchInput`); + + for (const fieldType of fieldTypes) { + await retry.tryForTime(5000, async () => { + await searchBarInput.clearValueWithKeyboard(); + await searchBarInput.type(fieldType); + if (!(await testSubjects.exists(`${testDataSubj}-option-${fieldType}`))) { + await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}-checked`); + await testSubjects.click(`${testDataSubj}-option-${fieldType}-checked`); + await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}`); + } + }); + } + + // escape popover + await browser.pressKeys(browser.keys.ESCAPE); + }, }; } diff --git a/x-pack/test/functional/services/ml/data_visualizer_table.ts b/x-pack/test/functional/services/ml/data_visualizer_table.ts index f5f9770508235..f8623842a596d 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_table.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_table.ts @@ -7,12 +7,15 @@ import expect from '@kbn/expect'; import { ProvidedType } from '@kbn/test/types/ftr'; import { FtrProviderContext } from '../../ftr_provider_context'; import { ML_JOB_FIELD_TYPES } from '../../../../plugins/ml/common/constants/field_types'; +import { MlCommonUI } from './common_ui'; export type MlDataVisualizerTable = ProvidedType; -export function MachineLearningDataVisualizerTableProvider({ getService }: FtrProviderContext) { +export function MachineLearningDataVisualizerTableProvider( + { getService }: FtrProviderContext, + mlCommonUI: MlCommonUI +) { const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const browser = getService('browser'); return new (class DataVisualizerTable { public async parseDataVisualizerTable() { @@ -60,7 +63,7 @@ export function MachineLearningDataVisualizerTableProvider({ getService }: FtrPr const tableRows = await this.parseDataVisualizerTable(); expect(tableRows).to.have.length( expectedRowCount, - `Filtered Data Visualizer table should have ${expectedRowCount} row(s) (got '${tableRows.length}')` + `Data Visualizer table should have ${expectedRowCount} row(s) (got '${tableRows.length}')` ); }); } @@ -169,94 +172,28 @@ export function MachineLearningDataVisualizerTableProvider({ getService }: FtrPr }); } - public async setMultiSelectFilter( - testDataSubj: string, - fieldTypes: string[], - expectedRowCount = 1 - ) { - await testSubjects.clickWhenNotDisabled(`${testDataSubj}-button`); - await testSubjects.existOrFail(`${testDataSubj}-popover`); - await testSubjects.existOrFail(`${testDataSubj}-searchInput`); - const searchBarInput = await testSubjects.find(`${testDataSubj}-searchInput`); - - for (const fieldType of fieldTypes) { - await retry.tryForTime(5000, async () => { - await searchBarInput.clearValueWithKeyboard(); - await searchBarInput.type(fieldType); - if (!(await testSubjects.exists(`${testDataSubj}-option-${fieldType}-checked`))) { - await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}`); - await testSubjects.click(`${testDataSubj}-option-${fieldType}`); - await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}-checked`); - } - }); - } - - // escape popover - await browser.pressKeys(browser.keys.ESCAPE); - await this.assertTableRowCount(expectedRowCount); - } - - async removeMultiSelectFilter( - testDataSubj: string, - fieldTypes: string[], - expectedRowCount = 1 - ) { - await testSubjects.clickWhenNotDisabled(`${testDataSubj}-button`); - await testSubjects.existOrFail(`${testDataSubj}-popover`); - await testSubjects.existOrFail(`${testDataSubj}-searchInput`); - const searchBarInput = await testSubjects.find(`${testDataSubj}-searchInput`); - - for (const fieldType of fieldTypes) { - await retry.tryForTime(5000, async () => { - await searchBarInput.clearValueWithKeyboard(); - await searchBarInput.type(fieldType); - if (!(await testSubjects.exists(`${testDataSubj}-option-${fieldType}`))) { - await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}-checked`); - await testSubjects.click(`${testDataSubj}-option-${fieldType}-checked`); - await testSubjects.existOrFail(`${testDataSubj}-option-${fieldType}`); - } - }); - } - - // escape popover - await browser.pressKeys(browser.keys.ESCAPE); - await this.assertTableRowCount(expectedRowCount); - } - public async setFieldTypeFilter(fieldTypes: string[], expectedRowCount = 1) { await this.assertFieldTypeInputExists(); - await this.setMultiSelectFilter( - 'mlDataVisualizerFieldTypeSelect', - fieldTypes, - expectedRowCount - ); + await mlCommonUI.setMultiSelectFilter('mlDataVisualizerFieldTypeSelect', fieldTypes); + await this.assertTableRowCount(expectedRowCount); } async removeFieldTypeFilter(fieldTypes: string[], expectedRowCount = 1) { await this.assertFieldTypeInputExists(); - await this.removeMultiSelectFilter( - 'mlDataVisualizerFieldTypeSelect', - fieldTypes, - expectedRowCount - ); + await mlCommonUI.removeMultiSelectFilter('mlDataVisualizerFieldTypeSelect', fieldTypes); + await this.assertTableRowCount(expectedRowCount); } public async setFieldNameFilter(fieldNames: string[], expectedRowCount = 1) { await this.assertFieldNameInputExists(); - await this.setMultiSelectFilter( - 'mlDataVisualizerFieldNameSelect', - fieldNames, - expectedRowCount - ); + await mlCommonUI.setMultiSelectFilter('mlDataVisualizerFieldNameSelect', fieldNames); + await this.assertTableRowCount(expectedRowCount); } public async removeFieldNameFilter(fieldNames: string[], expectedRowCount: number) { await this.assertFieldNameInputExists(); - await this.removeMultiSelectFilter( - 'mlDataVisualizerFieldNameSelect', - fieldNames, - expectedRowCount - ); + await mlCommonUI.removeMultiSelectFilter('mlDataVisualizerFieldNameSelect', fieldNames); + await this.assertTableRowCount(expectedRowCount); } public async assertShowEmptyFieldsSwitchExists() { diff --git a/x-pack/test/functional/services/ml/index.ts b/x-pack/test/functional/services/ml/index.ts index b5c823b0cbd65..8f8f8b7251242 100644 --- a/x-pack/test/functional/services/ml/index.ts +++ b/x-pack/test/functional/services/ml/index.ts @@ -63,7 +63,7 @@ export function MachineLearningProvider(context: FtrProviderContext) { const dataFrameAnalyticsTable = MachineLearningDataFrameAnalyticsTableProvider(context); const dataVisualizer = MachineLearningDataVisualizerProvider(context); - const dataVisualizerTable = MachineLearningDataVisualizerTableProvider(context); + const dataVisualizerTable = MachineLearningDataVisualizerTableProvider(context, commonUI); const dataVisualizerFileBased = MachineLearningDataVisualizerFileBasedProvider(context, commonUI); const dataVisualizerIndexBased = MachineLearningDataVisualizerIndexBasedProvider(context);