Skip to content

Commit

Permalink
[ML] update tests to test for geo field in file based
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jan 20, 2021
1 parent 7c30c47 commit 11eaf09
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function MlEmbeddedMapComponent({

return (
<div
data-test-subj="xpack.ml.dataVisualizer.embeddedMapPanel"
data-test-subj="mlEmbeddedMapContent"
className="mlEmbeddedMapContent"
ref={embeddableRoot}
/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export const GeoPointContent: FC<FieldDataRowProps> = ({ config }) => {
</EuiFlexItem>
)}
{formattedResults && Array.isArray(formattedResults.layerList) && (
<EuiFlexItem className={'mlDataVisualizerMapWrapper'}>
<EuiFlexItem
className={'mlDataVisualizerMapWrapper'}
data-test-subj={'mlDataVisualizerEmbeddedMap'}
>
<MlEmbeddedMapComponent layerList={formattedResults.layerList} />
</EuiFlexItem>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import React, { FC, useEffect, useState } from 'react';

import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import uuid from 'uuid';
import { ExamplesList } from '../../../index_based/components/field_data_row/examples_list';
import { FieldVisConfig } from '../../../stats_table/types';
import { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,47 @@ export default function ({ getService }: FtrProviderContext) {
fieldNameFiltersResultCount: 1,
},
},
{
suiteSuffix: 'with a file containing geo field',
filePath: path.join(__dirname, 'files_to_import', 'geo_file.csv'),
indexName: 'user-import_1',
createIndexPattern: false,
fieldTypeFilters: [ML_JOB_FIELD_TYPES.GEO_POINT],
fieldNameFilters: ['Coordinates'],
expected: {
results: {
title: 'geo_file.csv',
numberOfFields: 3,
},
metricFields: [],
nonMetricFields: [
{
fieldName: 'Context',
type: ML_JOB_FIELD_TYPES.UNKNOWN,
docCountFormatted: '0 (0%)',
exampleCount: 0,
},
{
fieldName: 'Coordinates',
type: ML_JOB_FIELD_TYPES.GEO_POINT,
docCountFormatted: '13 (100%)',
exampleCount: 7,
},
{
fieldName: 'Location',
type: ML_JOB_FIELD_TYPES.KEYWORD,
docCountFormatted: '13 (100%)',
exampleCount: 7,
},
],
visibleMetricFieldsCount: 0,
totalMetricFieldsCount: 0,
populatedFieldsCount: 3,
totalFieldsCount: 3,
fieldTypeFiltersResultCount: 1,
fieldNameFiltersResultCount: 1,
},
},
];

const testDataListNegative = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Coordinates,Location,Context
POINT (-2.516919 51.423683),On or near A4175,
POINT (-2.515072 51.419357),On or near Stockwood Hill,
POINT (-2.509126 51.416137),On or near St Francis Road,
POINT (-2.509384 51.40959),On or near Barnard Walk,
POINT (-2.509126 51.416137),On or near St Francis Road,
POINT (-2.516919 51.423683),On or near A4175,
POINT (-2.511571 51.414895),On or near Orchard Close,
POINT (-2.534338 51.417697),On or near Scotland Lane,
POINT (-2.509384 51.40959),On or near Barnard Walk,
POINT (-2.495055 51.422132),On or near Cross Street,
POINT (-2.509384 51.40959),On or near Barnard Walk,
POINT (-2.495055 51.422132),On or near Cross Street,
POINT (-2.509126 51.416137),On or near St Francis Road,
30 changes: 30 additions & 0 deletions x-pack/test/functional/services/ml/data_visualizer_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,32 @@ export function MachineLearningDataVisualizerTableProvider(
await this.ensureDetailsClosed(fieldName);
}

public async assertGeoPointFieldContents(
fieldName: string,
docCountFormatted: string,
topValuesCount: number
) {
await this.assertRowExists(fieldName);
await this.assertFieldDocCount(fieldName, docCountFormatted);
await this.ensureDetailsOpen(fieldName);

await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlFieldDataTopValues'));
await this.assertTopValuesContents(fieldName, topValuesCount);
await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlEmbeddedMapContent'));

await this.ensureDetailsClosed(fieldName);
}

public async assertUnknownFieldContents(fieldName: string, docCountFormatted: string) {
await this.assertRowExists(fieldName);
await this.assertFieldDocCount(fieldName, docCountFormatted);
await this.ensureDetailsOpen(fieldName);

await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlDVDocumentStatsContent'));

await this.ensureDetailsClosed(fieldName);
}

public async assertNonMetricFieldContents(
fieldType: string,
fieldName: string,
Expand All @@ -321,6 +347,10 @@ export function MachineLearningDataVisualizerTableProvider(
await this.assertKeywordFieldContents(fieldName, docCountFormatted, exampleCount);
} else if (fieldType === ML_JOB_FIELD_TYPES.TEXT) {
await this.assertTextFieldContents(fieldName, docCountFormatted, exampleCount);
} else if (fieldType === ML_JOB_FIELD_TYPES.GEO_POINT) {
await this.assertGeoPointFieldContents(fieldName, docCountFormatted, exampleCount);
} else if (fieldType === ML_JOB_FIELD_TYPES.UNKNOWN) {
await this.assertUnknownFieldContents(fieldName, docCountFormatted);
}
}

Expand Down

0 comments on commit 11eaf09

Please sign in to comment.