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

* 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 20:45:53 -04:00 committed by GitHub
parent f68b5a1edb
commit b41e82fcde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -412,8 +412,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 = [
{