@@ -44,3 +44,53 @@ describe('ui_settings 7.9.0 migrations', () => {
4444 } ) ;
4545 } ) ;
4646} ) ;
47+
48+ describe ( 'ui_settings 7.12.0 migrations' , ( ) => {
49+ const migration = migrations [ '7.12.0' ] ;
50+
51+ test ( 'returns doc on empty object' , ( ) => {
52+ expect ( migration ( { } as SavedObjectUnsanitizedDoc ) ) . toEqual ( {
53+ references : [ ] ,
54+ } ) ;
55+ } ) ;
56+ test ( 'properly migrates timepicker:quickRanges' , ( ) => {
57+ const initialQuickRange : any = {
58+ from : '123' ,
59+ to : '321' ,
60+ display : 'abc' ,
61+ section : 2 ,
62+ } ;
63+ const { section, ...migratedQuickRange } = initialQuickRange ;
64+
65+ const doc = {
66+ type : 'config' ,
67+ id : '8.0.0' ,
68+ attributes : {
69+ buildNum : 9007199254740991 ,
70+ 'timepicker:quickRanges' : JSON . stringify ( [ initialQuickRange ] ) ,
71+ } ,
72+ references : [ ] ,
73+ updated_at : '2020-06-09T20:18:20.349Z' ,
74+ migrationVersion : { } ,
75+ } ;
76+ const migrated = migration ( doc ) ;
77+ expect ( JSON . parse ( migrated . attributes [ 'timepicker:quickRanges' ] ) ) . toEqual ( [ migratedQuickRange ] ) ;
78+ } ) ;
79+
80+ // https://github.com/elastic/kibana/issues/95616
81+ test ( 'returns doc when "timepicker:quickRanges" is null' , ( ) => {
82+ const doc = {
83+ type : 'config' ,
84+ id : '8.0.0' ,
85+ attributes : {
86+ buildNum : 9007199254740991 ,
87+ 'timepicker:quickRanges' : null ,
88+ } ,
89+ references : [ ] ,
90+ updated_at : '2020-06-09T20:18:20.349Z' ,
91+ migrationVersion : { } ,
92+ } ;
93+ const migrated = migration ( doc ) ;
94+ expect ( migrated ) . toEqual ( doc ) ;
95+ } ) ;
96+ } ) ;
0 commit comments