mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
be92bf37ba
commit
0eaaade078
3 changed files with 64 additions and 19 deletions
|
@ -1,16 +1,50 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`IndexPatterns correctly composes runtime field 1`] = `
|
||||
FldList [
|
||||
Object {
|
||||
"aggregatable": true,
|
||||
"conflictDescriptions": undefined,
|
||||
"count": 5,
|
||||
"customLabel": "A Runtime Field",
|
||||
"esTypes": Array [
|
||||
"keyword",
|
||||
],
|
||||
"lang": undefined,
|
||||
"name": "aRuntimeField",
|
||||
"readFromDocValues": false,
|
||||
"script": undefined,
|
||||
"scripted": false,
|
||||
"searchable": true,
|
||||
"subType": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`IndexPatterns savedObjectToSpec 1`] = `
|
||||
Object {
|
||||
"allowNoIndex": undefined,
|
||||
"fieldAttrs": Object {},
|
||||
"fieldAttrs": Object {
|
||||
"aRuntimeField": Object {
|
||||
"count": 5,
|
||||
"customLabel": "A Runtime Field",
|
||||
},
|
||||
},
|
||||
"fieldFormats": Object {
|
||||
"field": Object {},
|
||||
},
|
||||
"fields": Object {},
|
||||
"id": "id",
|
||||
"intervalName": undefined,
|
||||
"runtimeFieldMap": Object {},
|
||||
"runtimeFieldMap": Object {
|
||||
"aRuntimeField": Object {
|
||||
"script": Object {
|
||||
"source": "emit('hello')",
|
||||
},
|
||||
"type": "keyword",
|
||||
},
|
||||
},
|
||||
"sourceFilters": Array [
|
||||
Object {
|
||||
"value": "item1",
|
||||
|
|
|
@ -26,6 +26,25 @@ function setDocsourcePayload(id: string | null, providedPayload: any) {
|
|||
object = defaults(providedPayload || {}, stubbedSavedObjectIndexPattern(id));
|
||||
}
|
||||
|
||||
const savedObject = {
|
||||
id: 'id',
|
||||
version: 'version',
|
||||
attributes: {
|
||||
title: 'kibana-*',
|
||||
timeFieldName: '@timestamp',
|
||||
fields: '[]',
|
||||
sourceFilters: '[{"value":"item1"},{"value":"item2"}]',
|
||||
fieldFormatMap: '{"field":{}}',
|
||||
typeMeta: '{}',
|
||||
type: '',
|
||||
runtimeFieldMap:
|
||||
'{"aRuntimeField": { "type": "keyword", "script": {"source": "emit(\'hello\')"}}}',
|
||||
fieldAttrs: '{"aRuntimeField": { "count": 5, "customLabel": "A Runtime Field"}}',
|
||||
},
|
||||
type: 'index-pattern',
|
||||
references: [],
|
||||
};
|
||||
|
||||
describe('IndexPatterns', () => {
|
||||
let indexPatterns: IndexPatternsService;
|
||||
let savedObjectsClient: SavedObjectsClientCommon;
|
||||
|
@ -220,23 +239,14 @@ describe('IndexPatterns', () => {
|
|||
});
|
||||
|
||||
test('savedObjectToSpec', () => {
|
||||
const savedObject = {
|
||||
id: 'id',
|
||||
version: 'version',
|
||||
attributes: {
|
||||
title: 'kibana-*',
|
||||
timeFieldName: '@timestamp',
|
||||
fields: '[]',
|
||||
sourceFilters: '[{"value":"item1"},{"value":"item2"}]',
|
||||
fieldFormatMap: '{"field":{}}',
|
||||
typeMeta: '{}',
|
||||
type: '',
|
||||
},
|
||||
type: 'index-pattern',
|
||||
references: [],
|
||||
};
|
||||
const spec = indexPatterns.savedObjectToSpec(savedObject);
|
||||
expect(spec).toMatchSnapshot();
|
||||
});
|
||||
|
||||
expect(indexPatterns.savedObjectToSpec(savedObject)).toMatchSnapshot();
|
||||
test('correctly composes runtime field', async () => {
|
||||
setDocsourcePayload('id', savedObject);
|
||||
const indexPattern = await indexPatterns.get('id');
|
||||
expect(indexPattern.fields).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('failed requests are not cached', async () => {
|
||||
|
|
|
@ -429,8 +429,9 @@ export class IndexPatternsService {
|
|||
runtimeField: value,
|
||||
aggregatable: true,
|
||||
searchable: true,
|
||||
count: 0,
|
||||
readFromDocValues: false,
|
||||
customLabel: spec.fieldAttrs?.[key]?.customLabel,
|
||||
count: spec.fieldAttrs?.[key]?.count,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue