Skip to content

Commit 76b51e4

Browse files
committed
add functional test ensuring _search request only pulls what is needed
1 parent 00c6a15 commit 76b51e4

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
export default function ({ getPageObjects, getService }) {
10+
const PageObjects = getPageObjects(['maps']);
11+
const inspector = getService('inspector');
12+
const testSubjects = getService('testSubjects');
13+
const log = getService('log');
14+
15+
describe('docvalue_fields', () => {
16+
before(async () => {
17+
await PageObjects.maps.loadSavedMap('document example');
18+
});
19+
20+
async function getResponse() {
21+
await inspector.open();
22+
await inspector.openInspectorRequestsView();
23+
await testSubjects.click('inspectorRequestDetailResponse');
24+
const responseBody = await testSubjects.getVisibleText('inspectorResponseBody');
25+
log.info(responseBody);
26+
await inspector.close();
27+
return JSON.parse(responseBody);
28+
}
29+
30+
it('should only fetch geo_point field and nothing else when source does not have data driven styling', async () => {
31+
await PageObjects.maps.loadSavedMap('document example');
32+
const response = await getResponse();
33+
const firstHit = response.hits.hits[0];
34+
expect(Object.keys(firstHit).join(',')).to.equal('_index,_type,_id,_score,fields');
35+
expect(Object.keys(firstHit.fields).join(',')).to.equal('geo.coordinates');
36+
});
37+
38+
it('should only fetch geo_point field and data driven styling fields', async () => {
39+
await PageObjects.maps.loadSavedMap('document example with data driven styles');
40+
const response = await getResponse();
41+
const firstHit = response.hits.hits[0];
42+
expect(Object.keys(firstHit).join(',')).to.equal('_index,_type,_id,_score,fields');
43+
expect(Object.keys(firstHit.fields).join(',')).to.equal('geo.coordinates,bytes,hour_of_day');
44+
});
45+
46+
});
47+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
export default function ({ loadTestFile }) {
88
describe('documents source', function () {
9+
loadTestFile(require.resolve('./docvalue_fields'));
910
loadTestFile(require.resolve('./search_hits'));
1011
loadTestFile(require.resolve('./top_hits'));
1112
});

0 commit comments

Comments
 (0)