handle "null" in "timepicker:quickRanges" migration (#95767)
This commit is contained in:
parent
357c4a5457
commit
2745a6e957
|
@ -76,6 +76,23 @@ describe('ui_settings 7.12.0 migrations', () => {
|
|||
const migrated = migration(doc);
|
||||
expect(JSON.parse(migrated.attributes['timepicker:quickRanges'])).toEqual([migratedQuickRange]);
|
||||
});
|
||||
|
||||
// https://github.com/elastic/kibana/issues/95616
|
||||
test('returns doc when "timepicker:quickRanges" is null', () => {
|
||||
const doc = {
|
||||
type: 'config',
|
||||
id: '8.0.0',
|
||||
attributes: {
|
||||
buildNum: 9007199254740991,
|
||||
'timepicker:quickRanges': null,
|
||||
},
|
||||
references: [],
|
||||
updated_at: '2020-06-09T20:18:20.349Z',
|
||||
migrationVersion: {},
|
||||
};
|
||||
const migrated = migration(doc);
|
||||
expect(migrated).toEqual(doc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ui_settings 7.13.0 migrations', () => {
|
||||
|
|
|
@ -32,7 +32,7 @@ export const migrations = {
|
|||
...doc,
|
||||
...(doc.attributes && {
|
||||
attributes: Object.keys(doc.attributes).reduce((acc, key) => {
|
||||
if (key === 'timepicker:quickRanges' && doc.attributes[key].indexOf('section') > -1) {
|
||||
if (key === 'timepicker:quickRanges' && doc.attributes[key]?.indexOf('section') > -1) {
|
||||
const ranges = JSON.parse(doc.attributes[key]).map(
|
||||
({ from, to, display }: { from: string; to: string; display: string }) => {
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue