File tree Expand file tree Collapse file tree 5 files changed +17
-5
lines changed
plugins/ml/public/application/datavisualizer/file_based/components/fields_stats Expand file tree Collapse file tree 5 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export function FieldStatsCard({ field }) {
2626
2727 return (
2828 < EuiPanel hasShadow = { false } className = "mlFieldDataCard" >
29- < div className = "ml-field-data-card" >
29+ < div className = "ml-field-data-card" data-test-subj = "mlPageFileDataVisFieldDataCard" >
3030 < div className = { `ml-field-title-bar ${ type } ` } >
3131 < FieldTypeIcon type = { type } needsAria = { false } />
3232 < div className = "field-name" tabIndex = "0" aria-label = { `${ cardTitleAriaLabel . join ( ', ' ) } ` } >
Original file line number Diff line number Diff line change @@ -50,14 +50,14 @@ function createFields(results) {
5050 timestamp_field : timestampField ,
5151 } = results ;
5252
53- if ( mappings && fieldStats ) {
53+ if ( mappings && mappings . properties && fieldStats ) {
5454 const fieldNames = getFieldNames ( results ) ;
5555
5656 return fieldNames . map ( ( name ) => {
5757 if ( fieldStats [ name ] !== undefined ) {
5858 const field = { name } ;
5959 const f = fieldStats [ name ] ;
60- const m = mappings [ name ] ;
60+ const m = mappings . properties [ name ] ;
6161
6262 // sometimes the timestamp field is not in the mappings, and so our
6363 // collection of fields will be missing a time field with a type of date
@@ -93,7 +93,7 @@ function createFields(results) {
9393 // this could be the message field for a semi-structured log file or a
9494 // field which the endpoint has not been able to work out any information for
9595 const type =
96- mappings [ name ] && mappings [ name ] . type === ML_JOB_FIELD_TYPES . TEXT
96+ mappings . properties [ name ] && mappings . properties [ name ] . type === ML_JOB_FIELD_TYPES . TEXT
9797 ? ML_JOB_FIELD_TYPES . TEXT
9898 : ML_JOB_FIELD_TYPES . UNKNOWN ;
9999
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export function getFieldNames(results) {
1616 // there may be fields in the mappings which do not exist in the field_stats
1717 // e.g. the message field for a semi-structured log file, as they have no stats.
1818 // add any extra fields to the list
19- const differenceFields = difference ( Object . keys ( mappings ) , tempFields ) ;
19+ const differenceFields = difference ( Object . keys ( mappings . properties ) , tempFields ) ;
2020
2121 // except @timestamp
2222 const timestampIndex = differenceFields . indexOf ( '@timestamp' ) ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export default function ({ getService }: FtrProviderContext) {
2020 expected : {
2121 results : {
2222 title : 'artificial_server_log' ,
23+ numberOfFields : 4 ,
2324 } ,
2425 } ,
2526 } ,
@@ -62,6 +63,9 @@ export default function ({ getService }: FtrProviderContext) {
6263 await ml . dataVisualizerFileBased . assertFileContentPanelExists ( ) ;
6364 await ml . dataVisualizerFileBased . assertSummaryPanelExists ( ) ;
6465 await ml . dataVisualizerFileBased . assertFileStatsPanelExists ( ) ;
66+ await ml . dataVisualizerFileBased . assertNumberOfFieldCards (
67+ testData . expected . results . numberOfFields
68+ ) ;
6569
6670 await ml . testExecution . logTestStep ( 'loads the import settings page' ) ;
6771 await ml . dataVisualizerFileBased . navigateToFileImport ( ) ;
Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ export function MachineLearningDataVisualizerFileBasedProvider(
5454 await testSubjects . existOrFail ( 'mlFileDataVisFileStatsPanel' ) ;
5555 } ,
5656
57+ async assertNumberOfFieldCards ( number : number ) {
58+ const cards = await testSubjects . findAll ( 'mlPageFileDataVisFieldDataCard' ) ;
59+ expect ( cards . length ) . to . eql (
60+ number ,
61+ `expected ${ number } field cards to exist, but found ${ cards . length } `
62+ ) ;
63+ } ,
64+
5765 async assertImportButtonEnabled ( expectedValue : boolean ) {
5866 const isEnabled = await testSubjects . isEnabled ( 'mlFileDataVisOpenImportPageButton' ) ;
5967 expect ( isEnabled ) . to . eql (
You can’t perform that action at this time.
0 commit comments