Skip to content

Commit

Permalink
[Maps] fix point to point source regression (#60930)
Browse files Browse the repository at this point in the history
* [Maps] fix pew pew regression

* add functional test for pew pew source
  • Loading branch information
nreese authored Mar 23, 2020
1 parent 73deba1 commit d32c4c8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ export class ESSearchSource extends AbstractESSource {
}

renderSourceSettingsEditor({ onChange }) {
const getGeoField = () => {
return this._getGeoField();
};
return (
<UpdateSourceEditor
source={this}
indexPatternId={this.getIndexPatternId()}
getGeoField={this._getGeoField}
getGeoField={getGeoField}
onChange={onChange}
tooltipFields={this._tooltipFields}
sortField={this._descriptor.sortField}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/maps/public/layers/sources/es_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class AbstractESSource extends AbstractVectorSource {
}
}

_getGeoField = async () => {
async _getGeoField() {
const indexPattern = await this.getIndexPattern();
const geoField = indexPattern.fields.getByName(this._descriptor.geoField);
if (!geoField) {
Expand All @@ -243,7 +243,7 @@ export class AbstractESSource extends AbstractVectorSource {
);
}
return geoField;
};
}

async getDisplayName() {
try {
Expand Down
39 changes: 39 additions & 0 deletions x-pack/test/functional/apps/maps/es_pew_pew_source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 expect from '@kbn/expect';

export default function({ getPageObjects, getService }) {
const PageObjects = getPageObjects(['maps']);
const inspector = getService('inspector');

const VECTOR_SOURCE_ID = '67c1de2c-2fc5-4425-8983-094b589afe61';

describe('point to point source', () => {
before(async () => {
await PageObjects.maps.loadSavedMap('pew pew demo');
});

it('should request source clusters for destination locations', async () => {
await inspector.open();
await inspector.openInspectorRequestsView();
const requestStats = await inspector.getTableData();
const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits');
const totalHits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits (total)');
await inspector.close();

expect(hits).to.equal('0');
expect(totalHits).to.equal('4');
});

it('should render lines', async () => {
const mapboxStyle = await PageObjects.maps.getMapboxStyle();
const features = mapboxStyle.sources[VECTOR_SOURCE_ID].data.features;
expect(features.length).to.equal(2);
expect(features[0].geometry.type).to.equal('LineString');
});
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function({ loadTestFile, getService }) {
describe('', function() {
this.tags('ciGroup10');
loadTestFile(require.resolve('./es_geo_grid_source'));
loadTestFile(require.resolve('./es_pew_pew_source'));
loadTestFile(require.resolve('./joins'));
loadTestFile(require.resolve('./add_layer_panel'));
loadTestFile(require.resolve('./import_geojson'));
Expand Down

0 comments on commit d32c4c8

Please sign in to comment.