forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove id attribute from canvas attributes (elastic#30736)
* Remove id attribute from canvas attributes * Fix create and update API * Add migration tests * Use constants * Add API tests * Cleanup tests * Apply PR feedback
- Loading branch information
Showing
9 changed files
with
431 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CANVAS_TYPE } from './common/lib'; | ||
|
||
export const migrations = { | ||
[CANVAS_TYPE]: { | ||
'7.0.0': doc => { | ||
if (doc.attributes) { | ||
delete doc.attributes.id; | ||
} | ||
return doc; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { migrations } from './migrations'; | ||
import { CANVAS_TYPE } from './common/lib'; | ||
|
||
describe(CANVAS_TYPE, () => { | ||
describe('7.0.0', () => { | ||
const migrate = doc => migrations[CANVAS_TYPE]['7.0.0'](doc); | ||
|
||
it('does not throw error on empty object', () => { | ||
const migratedDoc = migrate({}); | ||
expect(migratedDoc).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
|
||
it('removes id from "attributes"', () => { | ||
const migratedDoc = migrate({ | ||
foo: true, | ||
attributes: { | ||
id: '123', | ||
bar: true, | ||
}, | ||
}); | ||
expect(migratedDoc).toMatchInlineSnapshot(` | ||
Object { | ||
"attributes": Object { | ||
"bar": true, | ||
}, | ||
"foo": true, | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.