Fix visualization migration when savedSearchId is empty string (#40172) (#40211)

* Fix visualization migration when savedSearchId is empty string

* Apply PR feedback

* Apply PR feedback pt2
This commit is contained in:
Mike Côté 2019-07-02 18:04:13 -04:00 committed by GitHub
parent 45d0d41958
commit ca1fe491b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -199,8 +199,8 @@ export const migrations = {
id: savedSearchId,
});
doc.attributes.savedSearchRefName = 'search_0';
delete doc.attributes.savedSearchId;
}
delete doc.attributes.savedSearchId;
// Migrate controls
const visStateJSON = get(doc, 'attributes.visState');

View file

@ -572,6 +572,32 @@ Object {
`);
});
it('delete savedSearchId when empty string in doc', () => {
const doc = {
id: '1',
attributes: {
visState: '{}',
kibanaSavedObjectMeta: {
searchSourceJSON: '{}',
},
savedSearchId: '',
},
};
const migratedDoc = migrate(doc);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"kibanaSavedObjectMeta": Object {
"searchSourceJSON": "{}",
},
"visState": "{}",
},
"id": "1",
"references": Array [],
}
`);
});
it('should return a new object if vis is table and has multiple split aggs', () => {
const aggs = [
{