mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
1a25a22466
commit
530553d344
5 changed files with 64 additions and 13 deletions
|
@ -34,5 +34,8 @@ export function includedFields(type, fields) {
|
|||
return sourceFields.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');
|
||||
});
|
||||
|
|
|
@ -1073,11 +1073,20 @@ describe('SavedObjectsRepository', () => {
|
|||
await savedObjectsRepository.find({ type: 'foo', fields: ['title'] });
|
||||
|
||||
expect(callAdminCluster).toHaveBeenCalledTimes(1);
|
||||
expect(callAdminCluster).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
|
||||
_source: [
|
||||
'foo.title', 'namespace', 'type', 'title'
|
||||
]
|
||||
}));
|
||||
expect(callAdminCluster).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
_source: [
|
||||
'foo.title',
|
||||
'namespace',
|
||||
'type',
|
||||
'references',
|
||||
'migrationVersion',
|
||||
'updated_at',
|
||||
'title',
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
expect(onBeforeWrite).not.toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -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