Skip to content

Commit

Permalink
[Maps] Fix apis Maps endpoints getTile should return vector tile cont…
Browse files Browse the repository at this point in the history
…aining document (#114509)

* [Maps] Fix apis Maps endpoints getTile should return vector tile containing document

* use find instead of if statement

* eslint

* can not use layer.feature.find is layer.feature is not an array

* unskip other test where fix has been merged

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/test/api_integration/apis/maps/get_tile.js
  • Loading branch information
nreese committed Oct 12, 2021
1 parent 0f15cce commit d8ed940
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions x-pack/test/api_integration/apis/maps/get_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ import Protobuf from 'pbf';
import expect from '@kbn/expect';
import { MVT_SOURCE_LAYER_NAME } from '../../../../plugins/maps/common/constants';

function findFeature(layer, callbackFn) {
for (let i = 0; i < layer.length; i++) {
const feature = layer.feature(i);
if (callbackFn(feature)) {
return feature;
}
}
}

export default function ({ getService }) {
const supertest = getService('supertest');

// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/114471
// FLAKY: https://github.com/elastic/kibana/issues/114417
describe.skip('getTile', () => {
describe('getTile', () => {
it('should return vector tile containing document', async () => {
const resp = await supertest
.get(
Expand All @@ -33,8 +40,12 @@ export default function ({ getService }) {
const layer = jsonTile.layers[MVT_SOURCE_LAYER_NAME];
expect(layer.length).to.be(3); // 2 docs + the metadata feature

// 1st doc
const feature = layer.feature(0);
// Verify ES document

const feature = findFeature(layer, (feature) => {
return feature.properties._id === 'AU_x3_BsGFA8no6Qjjug';
});
expect(feature).not.to.be(undefined);
expect(feature.type).to.be(1);
expect(feature.extent).to.be(4096);
expect(feature.id).to.be(undefined);
Expand All @@ -47,8 +58,11 @@ export default function ({ getService }) {
});
expect(feature.loadGeometry()).to.eql([[{ x: 44, y: 2382 }]]);

// Metadata feature
const metadataFeature = layer.feature(2);
// Verify metadata feature
const metadataFeature = findFeature(layer, (feature) => {
return feature.properties.__kbn_metadata_feature__;
});
expect(metadataFeature).not.to.be(undefined);
expect(metadataFeature.type).to.be(3);
expect(metadataFeature.extent).to.be(4096);
expect(metadataFeature.id).to.be(undefined);
Expand Down

0 comments on commit d8ed940

Please sign in to comment.