Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Sep 23, 2020
1 parent 2e6cbcf commit 796b52c
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
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 @@ -47,6 +47,7 @@ export default function ({ loadTestFile, getService }) {
loadTestFile(require.resolve('./es_pew_pew_source'));
loadTestFile(require.resolve('./joins'));
loadTestFile(require.resolve('./mvt_scaling'));
loadTestFile(require.resolve('./mvt_super_fine'));
loadTestFile(require.resolve('./add_layer_panel'));
loadTestFile(require.resolve('./import_geojson'));
loadTestFile(require.resolve('./layer_errors'));
Expand Down
80 changes: 80 additions & 0 deletions x-pack/test/functional/apps/maps/mvt_super_fine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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';

const MB_VECTOR_SOURCE_ID = 'g1xkv';

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

describe('mvt grid layer', () => {
before(async () => {
await security.testUser.setRoles(
['global_maps_all', 'test_logstash_reader', 'geoshape_data_reader'],
false
);
await PageObjects.maps.loadSavedMap('geo grid vector grid example (SUPER_FINE resolution)');
});

after(async () => {
await inspector.close();
await security.testUser.restoreDefaults();
});

it('should render with mvt-source', async () => {
const mapboxStyle = await PageObjects.maps.getMapboxStyle();

//Source should be correct
expect(mapboxStyle.sources[MB_VECTOR_SOURCE_ID].tiles[0]).to.equal(
"/api/maps/mvt/getGridTile?x={x}&y={y}&z={z}&geometryFieldName=geo.coordinates&index=logstash-*&requestBody=(_source:(excludes:!()),aggs:(gridSplit:(aggs:(gridCentroid:(geo_centroid:(field:geo.coordinates)),max_of_bytes:(max:(field:bytes))),geotile_grid:(bounds:!n,field:geo.coordinates,precision:!n,shard_size:65535,size:65535))),docvalue_fields:!((field:'@timestamp',format:date_time),(field:'relatedContent.article:modified_time',format:date_time),(field:'relatedContent.article:published_time',format:date_time),(field:utc_time,format:date_time)),query:(bool:(filter:!((match_all:()),(range:('@timestamp':(format:strict_date_optional_time,gte:'2015-09-20T00:00:00.000Z',lte:'2015-09-20T01:00:00.000Z')))),must:!(),must_not:!(),should:!())),script_fields:(hour_of_day:(script:(lang:painless,source:'doc[!'@timestamp!'].value.getHour()'))),size:0,stored_fields:!('*'))&requestType=grid&geoFieldType=geo_point"
);

//Should correctly load meta for style-rule (sigma is set to 1, opacity to 1)
const fillLayer = mapboxStyle.layers.find(
(layer) => layer.id === MB_VECTOR_SOURCE_ID + '_fill'
);

expect(fillLayer.paint).to.eql({
'fill-color': [
'interpolate',
['linear'],
[
'coalesce',
[
'case',
['==', ['get', 'max_of_bytes'], null],
1622,
['max', ['min', ['to-number', ['get', 'max_of_bytes']], 9790], 1623],
],
1622,
],
1622,
'rgba(0,0,0,0)',
1623,
'#ecf1f7',
2643.875,
'#d9e3ef',
3664.75,
'#c5d5e7',
4685.625,
'#b2c7df',
5706.5,
'#9eb9d8',
6727.375,
'#8bacd0',
7748.25,
'#769fc8',
8769.125,
'#6092c0',
],
'fill-opacity': 0.75,
});
});
});
}
31 changes: 31 additions & 0 deletions x-pack/test/functional/es_archives/maps/kibana/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,37 @@
}
}

{
"type": "doc",
"value": {
"id": "map:78116c8c-fd2a-11ea-adc1-0242ac120002",
"index": ".kibana",
"source": {
"map": {
"bounds": {
"coordinates": [
[
-140.62361,
54.11832
],
[
-55.49169,
18.17193
]
],
"type": "envelope"
},
"description": "",
"layerListJSON": "[{\"id\":\"g1xkv\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"sourceDescriptor\":{\"resolution\": \"SUPER_FINE\",\"type\":\"ES_GEO_GRID\",\"id\":\"9305f6ea-4518-4c06-95b9-33321aa38d6a\",\"indexPatternId\":\"c698b940-e149-11e8-a35a-370a8516603a\",\"geoField\":\"geo.coordinates\",\"requestType\":\"grid\",\"metrics\":[{\"type\":\"count\"},{\"type\":\"max\",\"field\":\"bytes\"}]},\"visible\":true,\"temporary\":false,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"max of bytes\",\"name\":\"max_of_bytes\",\"origin\":\"source\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#cccccc\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}},\"temporary\":true,\"previousStyle\":null},\"type\":\"TILED_VECTOR\"}]",
"mapStateJSON": "{\"zoom\":3.59,\"center\":{\"lon\":-98.05765,\"lat\":38.32288},\"timeFilters\":{\"from\":\"2015-09-20T00:00:00.000Z\",\"to\":\"2015-09-20T01:00:00.000Z\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":1000}}",
"title": "geo grid vector grid example (SUPER_FINE resolution)",
"uiStateJSON": "{\"isDarkMode\":false}"
},
"type": "map"
}
}
}

{
"type": "doc",
"value": {
Expand Down

0 comments on commit 796b52c

Please sign in to comment.