Skip to content
Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@
"remark-stringify": "^8.0.3",
"require-in-the-middle": "^7.5.2",
"reselect": "^4.1.8",
"rison-node": "1.0.2",
"rison-node": "2.1.1",
"rxjs": "^7.8.2",
"safe-squel": "^5.12.5",
"seedrandom": "^3.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import { APP_ID, ES_GEO_FIELD_TYPE, SCALING_TYPES } from '../../../../common/con
jest.mock('../../../kibana_services');
jest.mock('./util/load_index_settings');

import { getIndexPatternService, getSearchService, getHttp } from '../../../kibana_services';
import type { SearchSource } from '@kbn/data-plugin/public';
import { decode } from '@kbn/rison';
import { getHttp, getIndexPatternService, getSearchService } from '../../../kibana_services';

import { loadIndexSettings } from './util/load_index_settings';

import { ESSearchSource } from './es_search_source';
import type { VectorSourceRequestMeta } from '../../../../common/descriptor_types';
import { ESSearchSource } from './es_search_source';

const mockDescriptor = { indexPatternId: 'foo', geoField: 'bar' };

Expand Down Expand Up @@ -132,15 +133,33 @@ describe('ESSearchSource', () => {
expect(urlParts[0]).toEqual('rootdir/internal/maps/mvt/getTile/{z}/{x}/{y}.pbf');

const params = new URLSearchParams(urlParts[1]);
expect(Object.fromEntries(params)).toEqual({

expect(Object.fromEntries(params)).toMatchObject({
buffer: '5',
geometryFieldName: 'bar',
hasLabels: 'false',
index: 'foobar-title-*',
requestBody:
"(fields:('0':('0':index,'1':(fields:(),title:'foobar-title-*')),'1':('0':size,'1':1000),'2':('0':filter,'1':!()),'3':('0':query),'4':('0':index,'1':(fields:(),title:'foobar-title-*')),'5':('0':query,'1':(language:KQL,query:'tooltipField: foobar')),'6':('0':fieldsFromSource,'1':!(_id)),'7':('0':source,'1':!f),'8':('0':fields,'1':!(tooltipField,styleField)),'9':('0':filter,'1':!((meta:(),query:(exists:(field:bar)))))))",
requestBody: expect.any(String),
token: '1234',
});

// Verify requestBody data after decoding from Rison
const requestBody = params.get('requestBody');
const requestBodyDecoded = requestBody ? decode(requestBody) : {};
expect(requestBodyDecoded).toEqual({
fields: {
'0': { '0': 'index', '1': { fields: {}, title: 'foobar-title-*' } },
'1': { '0': 'size', '1': 1000 },
'2': { '0': 'filter', '1': [] },
'3': { '0': 'query' },
'4': { '0': 'index', '1': { fields: {}, title: 'foobar-title-*' } },
'5': { '0': 'query', '1': { language: 'KQL', query: 'tooltipField: foobar' } },
'6': { '0': 'fieldsFromSource', '1': ['_id'] },
'7': { '0': 'source', '1': false },
'8': { '0': 'fields', '1': ['tooltipField', 'styleField'] },
'9': { '0': 'filter', '1': [{ meta: {}, query: { exists: { field: 'bar' } } }] },
},
});
});

it('should include executionContextId when provided', async () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29484,10 +29484,10 @@ ripemd160@=2.0.1, ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^2.0.0"
inherits "^2.0.1"

rison-node@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/rison-node/-/rison-node-1.0.2.tgz#b7b5f37f39f5ae2a51a973a33c9aa17239a33e4b"
integrity sha1-t7Xzfzn1ripRqXOjPJqhcjmjPks=
rison-node@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/rison-node/-/rison-node-2.1.1.tgz#3db68c6a736442a5494826f86fc8d675933934a5"
integrity sha512-GuV0OnSL2erZJ0j/9YUsrAdfSh3mGcrq+4wM4PqRftOYT7+TRhxbMrpVZaGC5YIPwncIoOM7PPnskDku5Ywg1Q==

robots-parser@^3.0.1:
version "3.0.1"
Expand Down