mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Fix includeFields function to return root saved object properties (#33847)
* Fix includeFields function to return root saved object properties * Fix broken tests
This commit is contained in:
parent
d3ad8a4b0b
commit
00e1b3ca5e
5 changed files with 59 additions and 9 deletions
|
@ -35,5 +35,8 @@ export function includedFields(type, fields) {
|
|||
.map(f => `${sourceType}.${f}`)
|
||||
.concat('namespace')
|
||||
.concat('type')
|
||||
.concat('references')
|
||||
.concat('migrationVersion')
|
||||
.concat('updated_at')
|
||||
.concat(fields); // v5 compatibility
|
||||
}
|
||||
|
|
|
@ -26,33 +26,51 @@ describe('includedFields', () => {
|
|||
|
||||
it('includes type', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(4);
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('type');
|
||||
});
|
||||
|
||||
it('includes namespace', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(4);
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('namespace');
|
||||
});
|
||||
|
||||
it('includes references', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('references');
|
||||
});
|
||||
|
||||
it('includes migrationVersion', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('migrationVersion');
|
||||
});
|
||||
|
||||
it('includes updated_at', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('updated_at');
|
||||
});
|
||||
|
||||
it('accepts field as string', () => {
|
||||
const fields = includedFields('config', 'foo');
|
||||
expect(fields).toHaveLength(4);
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('config.foo');
|
||||
});
|
||||
|
||||
it('accepts fields as an array', () => {
|
||||
const fields = includedFields('config', ['foo', 'bar']);
|
||||
|
||||
expect(fields).toHaveLength(6);
|
||||
expect(fields).toHaveLength(9);
|
||||
expect(fields).toContain('config.foo');
|
||||
expect(fields).toContain('config.bar');
|
||||
});
|
||||
|
||||
it('uses wildcard when type is not provided', () => {
|
||||
const fields = includedFields(undefined, 'foo');
|
||||
expect(fields).toHaveLength(4);
|
||||
expect(fields).toHaveLength(7);
|
||||
expect(fields).toContain('*.foo');
|
||||
});
|
||||
|
||||
|
@ -60,7 +78,7 @@ describe('includedFields', () => {
|
|||
it('includes legacy field path', () => {
|
||||
const fields = includedFields('config', ['foo', 'bar']);
|
||||
|
||||
expect(fields).toHaveLength(6);
|
||||
expect(fields).toHaveLength(9);
|
||||
expect(fields).toContain('foo');
|
||||
expect(fields).toContain('bar');
|
||||
});
|
||||
|
|
|
@ -1224,7 +1224,15 @@ describe('SavedObjectsRepository', () => {
|
|||
expect(callAdminCluster).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
_source: ['foo.title', 'namespace', 'type', 'title'],
|
||||
_source: [
|
||||
'foo.title',
|
||||
'namespace',
|
||||
'type',
|
||||
'references',
|
||||
'migrationVersion',
|
||||
'updated_at',
|
||||
'title',
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -46,7 +46,17 @@ export default function ({ getService }) {
|
|||
attributes: {
|
||||
'title': 'Count of requests'
|
||||
},
|
||||
references: [],
|
||||
migrationVersion: {
|
||||
visualization: '7.0.0',
|
||||
},
|
||||
references: [
|
||||
{
|
||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
||||
type: 'index-pattern',
|
||||
},
|
||||
],
|
||||
updated_at: '2017-09-21T18:51:23.794Z',
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -68,6 +68,7 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
|
|||
name: 'My favorite global object',
|
||||
},
|
||||
references: [],
|
||||
updated_at: '2017-09-21T18:59:16.270Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -100,7 +101,17 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest<any>)
|
|||
attributes: {
|
||||
title: 'Count of requests',
|
||||
},
|
||||
references: [],
|
||||
migrationVersion: {
|
||||
visualization: '7.0.0',
|
||||
},
|
||||
references: [
|
||||
{
|
||||
id: `${getIdPrefix(spaceId)}91200a00-9efd-11e7-acb3-3dab96693fab`,
|
||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
||||
type: 'index-pattern',
|
||||
},
|
||||
],
|
||||
updated_at: '2017-09-21T18:51:23.794Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue