Skip to content

Commit 796b52c

Browse files
add integration test
1 parent 2e6cbcf commit 796b52c

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

x-pack/test/functional/apps/maps/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default function ({ loadTestFile, getService }) {
4747
loadTestFile(require.resolve('./es_pew_pew_source'));
4848
loadTestFile(require.resolve('./joins'));
4949
loadTestFile(require.resolve('./mvt_scaling'));
50+
loadTestFile(require.resolve('./mvt_super_fine'));
5051
loadTestFile(require.resolve('./add_layer_panel'));
5152
loadTestFile(require.resolve('./import_geojson'));
5253
loadTestFile(require.resolve('./layer_errors'));
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import expect from '@kbn/expect';
8+
9+
const MB_VECTOR_SOURCE_ID = 'g1xkv';
10+
11+
export default function ({ getPageObjects, getService }) {
12+
const PageObjects = getPageObjects(['maps']);
13+
const inspector = getService('inspector');
14+
const security = getService('security');
15+
16+
describe('mvt grid layer', () => {
17+
before(async () => {
18+
await security.testUser.setRoles(
19+
['global_maps_all', 'test_logstash_reader', 'geoshape_data_reader'],
20+
false
21+
);
22+
await PageObjects.maps.loadSavedMap('geo grid vector grid example (SUPER_FINE resolution)');
23+
});
24+
25+
after(async () => {
26+
await inspector.close();
27+
await security.testUser.restoreDefaults();
28+
});
29+
30+
it('should render with mvt-source', async () => {
31+
const mapboxStyle = await PageObjects.maps.getMapboxStyle();
32+
33+
//Source should be correct
34+
expect(mapboxStyle.sources[MB_VECTOR_SOURCE_ID].tiles[0]).to.equal(
35+
"/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"
36+
);
37+
38+
//Should correctly load meta for style-rule (sigma is set to 1, opacity to 1)
39+
const fillLayer = mapboxStyle.layers.find(
40+
(layer) => layer.id === MB_VECTOR_SOURCE_ID + '_fill'
41+
);
42+
43+
expect(fillLayer.paint).to.eql({
44+
'fill-color': [
45+
'interpolate',
46+
['linear'],
47+
[
48+
'coalesce',
49+
[
50+
'case',
51+
['==', ['get', 'max_of_bytes'], null],
52+
1622,
53+
['max', ['min', ['to-number', ['get', 'max_of_bytes']], 9790], 1623],
54+
],
55+
1622,
56+
],
57+
1622,
58+
'rgba(0,0,0,0)',
59+
1623,
60+
'#ecf1f7',
61+
2643.875,
62+
'#d9e3ef',
63+
3664.75,
64+
'#c5d5e7',
65+
4685.625,
66+
'#b2c7df',
67+
5706.5,
68+
'#9eb9d8',
69+
6727.375,
70+
'#8bacd0',
71+
7748.25,
72+
'#769fc8',
73+
8769.125,
74+
'#6092c0',
75+
],
76+
'fill-opacity': 0.75,
77+
});
78+
});
79+
});
80+
}

x-pack/test/functional/es_archives/maps/kibana/data.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,37 @@
615615
}
616616
}
617617

618+
{
619+
"type": "doc",
620+
"value": {
621+
"id": "map:78116c8c-fd2a-11ea-adc1-0242ac120002",
622+
"index": ".kibana",
623+
"source": {
624+
"map": {
625+
"bounds": {
626+
"coordinates": [
627+
[
628+
-140.62361,
629+
54.11832
630+
],
631+
[
632+
-55.49169,
633+
18.17193
634+
]
635+
],
636+
"type": "envelope"
637+
},
638+
"description": "",
639+
"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\"}]",
640+
"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}}",
641+
"title": "geo grid vector grid example (SUPER_FINE resolution)",
642+
"uiStateJSON": "{\"isDarkMode\":false}"
643+
},
644+
"type": "map"
645+
}
646+
}
647+
}
648+
618649
{
619650
"type": "doc",
620651
"value": {

0 commit comments

Comments
 (0)