From b0d650796b05cd06cdeccd8bb37dcf178ca957c0 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 29 Sep 2020 17:25:16 -0600 Subject: [PATCH 1/4] add functional test for searchBar filters. remove boolean schema from datagrid --- .../ml/public/application/components/data_grid/common.ts | 3 --- .../exploration_query_bar/exploration_query_bar.tsx | 6 ++++-- .../apps/ml/data_frame_analytics/classification_creation.ts | 1 + .../apps/ml/data_frame_analytics/regression_creation.ts | 1 + .../functional/services/ml/data_frame_analytics_results.ts | 6 ++++++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/common.ts b/x-pack/plugins/ml/public/application/components/data_grid/common.ts index a33b2e6b3e2d6..7195b1e7af820 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/common.ts +++ b/x-pack/plugins/ml/public/application/components/data_grid/common.ts @@ -105,9 +105,6 @@ export const getDataGridSchemasFromFieldTypes = (fieldTypes: FieldTypes, results case 'geo_point': schema = 'json'; break; - case 'boolean': - schema = 'boolean'; - break; case 'text': schema = NON_AGGREGATABLE; } diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx index c2f3e71e2e492..06bcdfd364d66 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx @@ -163,7 +163,10 @@ export const ExplorationQueryBar: FC = ({ /> {filters && filters.options && ( - + = ({ } )} name="analyticsQueryBarFilterButtons" - data-test-subj="mlDFAnalyticsExplorationQueryBarFilterButtons" options={filters.options} type="multi" idToSelectedMap={idToSelectedMap} diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts index e12c853a0be83..5ff2039ac80e4 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts @@ -205,6 +205,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataFrameAnalyticsResults.assertClassificationEvaluatePanelElementsExists(); await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists(); await ml.dataFrameAnalyticsResults.assertResultsTableExists(); + await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist(); await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty(); }); }); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts index c58220f2d1ad2..dad3d990cfcaa 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts @@ -205,6 +205,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataFrameAnalyticsResults.assertRegressionEvaluatePanelElementsExists(); await ml.dataFrameAnalyticsResults.assertRegressionTablePanelExists(); await ml.dataFrameAnalyticsResults.assertResultsTableExists(); + await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist(); await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty(); }); }); diff --git a/x-pack/test/functional/services/ml/data_frame_analytics_results.ts b/x-pack/test/functional/services/ml/data_frame_analytics_results.ts index a4d8fa8e692bd..8781a2cd216f2 100644 --- a/x-pack/test/functional/services/ml/data_frame_analytics_results.ts +++ b/x-pack/test/functional/services/ml/data_frame_analytics_results.ts @@ -43,6 +43,12 @@ export function MachineLearningDataFrameAnalyticsResultsProvider({ await testSubjects.existOrFail('mlExplorationDataGrid loaded', { timeout: 5000 }); }, + async assertResultsTableTrainingFiltersExist() { + await testSubjects.existOrFail('mlDFAnalyticsExplorationQueryBarFilterButtons', { + timeout: 5000, + }); + }, + async getResultTableRows() { return await testSubjects.findAll('mlExplorationDataGrid loaded > dataGridRow'); }, From be28b153bb7247ca9911caed6e285aeba2d70a19 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 30 Sep 2020 12:14:03 -0600 Subject: [PATCH 2/4] always use string version of key for charts --- .../application/components/data_grid/column_chart.tsx | 2 +- .../application/components/data_grid/use_column_chart.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx b/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx index a3a67fbb8bb75..97fac052df1f6 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx @@ -51,7 +51,7 @@ export const ColumnChart: FC = ({ chartData, columnType, dataTestSubj }) name="count" xScaleType={xScaleType} yScaleType="linear" - xAccessor="key" + xAccessor={'key_as_string'} yAccessors={['doc_count']} styleAccessor={(d) => d.datum.color} data={data} diff --git a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx index 6b5fbbb22120d..32522d3f65c0d 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx @@ -67,7 +67,7 @@ export const getFieldType = (schema: EuiDataGridColumn['schema']): KBN_FIELD_TYP interface NumericDataItem { key: number; - key_as_string?: string; + key_as_string: string | number; doc_count: number; } @@ -91,7 +91,7 @@ export const isNumericChartData = (arg: any): arg is NumericChartData => { interface OrdinalDataItem { key: string; - key_as_string?: string; + key_as_string: string; doc_count: number; } @@ -231,11 +231,13 @@ export const useColumnChart = ( if (isOrdinalChartData(chartData)) { data = chartData.data.map((d: OrdinalDataItem) => ({ ...d, + key_as_string: d.key_as_string || d.key, color: getColor(d), })); } else if (isNumericChartData(chartData)) { data = chartData.data.map((d: NumericDataItem) => ({ ...d, + key_as_string: d.key_as_string || d.key, color: getColor(d), })); } From e0dbfbee935ef9c079621ddf548f1d76813ea93e Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 30 Sep 2020 13:00:45 -0600 Subject: [PATCH 3/4] add schema back in for histogram label --- .../ml/public/application/components/data_grid/common.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/common.ts b/x-pack/plugins/ml/public/application/components/data_grid/common.ts index 7195b1e7af820..a33b2e6b3e2d6 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/common.ts +++ b/x-pack/plugins/ml/public/application/components/data_grid/common.ts @@ -105,6 +105,9 @@ export const getDataGridSchemasFromFieldTypes = (fieldTypes: FieldTypes, results case 'geo_point': schema = 'json'; break; + case 'boolean': + schema = 'boolean'; + break; case 'text': schema = NON_AGGREGATABLE; } From df3142afdc0f09a0b57c6bdd9e4c4ce67821a796 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 6 Oct 2020 10:20:07 -0600 Subject: [PATCH 4/4] use ?? instead of || for undefined check --- .../application/components/data_grid/use_column_chart.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx index 32522d3f65c0d..a3169dc14a3a8 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx @@ -67,7 +67,7 @@ export const getFieldType = (schema: EuiDataGridColumn['schema']): KBN_FIELD_TYP interface NumericDataItem { key: number; - key_as_string: string | number; + key_as_string?: string | number; doc_count: number; } @@ -91,7 +91,7 @@ export const isNumericChartData = (arg: any): arg is NumericChartData => { interface OrdinalDataItem { key: string; - key_as_string: string; + key_as_string?: string; doc_count: number; } @@ -231,7 +231,7 @@ export const useColumnChart = ( if (isOrdinalChartData(chartData)) { data = chartData.data.map((d: OrdinalDataItem) => ({ ...d, - key_as_string: d.key_as_string || d.key, + key_as_string: d.key_as_string ?? d.key, color: getColor(d), })); } else if (isNumericChartData(chartData)) {