@@ -96,22 +96,50 @@ describe('store: ui getters', function () {
9696 orderOf ( widgets , 'g1' ) . should . eql ( [ 'a' ] )
9797 } )
9898
99- it ( 'sinks widgets with an unset/zero order to the end ' , function ( ) {
99+ it ( 'sorts a widget with order 0 first, like the editor layout manager ' , function ( ) {
100100 const widgets = [
101- { id : 'a' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 0 } } ,
102- { id : 'b' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 2 } } ,
101+ { id : 'a' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 2 } } ,
102+ { id : 'b' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 0 } } ,
103103 { id : 'c' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 1 } }
104104 ]
105- orderOf ( widgets ) . should . eql ( [ 'c ' , 'b ' , 'a' ] )
105+ orderOf ( widgets ) . should . eql ( [ 'b ' , 'c ' , 'a' ] )
106106 } )
107107
108- it ( 'sinks a subflow with an unset/zero order to the end' , function ( ) {
108+ it ( 'sorts a string "0" order the same as a numeric 0 (#2367)' , function ( ) {
109+ const widgets = [
110+ { id : 'a' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : '2' } } ,
111+ { id : 'b' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 0 } } ,
112+ { id : 'c' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : '1' } } ,
113+ { id : 'd' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : '0' } }
114+ ]
115+ orderOf ( widgets ) . should . eql ( [ 'b' , 'd' , 'c' , 'a' ] )
116+ } )
117+
118+ it ( 'sorts subflow widgets with a mix of numeric and string orders (#2367)' , function ( ) {
119+ const widgets = [
120+ { id : 'zero' , type : 'ui-text' , props : { group : 'g1' , subflow : { id : 'sf1' , order : 1 } } , layout : { order : 0 } } ,
121+ { id : 'two' , type : 'ui-text' , props : { group : 'g1' , subflow : { id : 'sf1' , order : 1 } } , layout : { order : '2' } } ,
122+ { id : 'one' , type : 'ui-text' , props : { group : 'g1' , subflow : { id : 'sf1' , order : 1 } } , layout : { order : '1' } } ,
123+ { id : 'three' , type : 'ui-text' , props : { group : 'g1' , subflow : { id : 'sf1' , order : 1 } } , layout : { order : '3' } }
124+ ]
125+ orderOf ( widgets ) . should . eql ( [ 'zero' , 'one' , 'two' , 'three' ] )
126+ } )
127+
128+ it ( 'sorts a subflow with order 0 first' , function ( ) {
109129 const widgets = [
110130 { id : 'a' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 1 } } ,
111131 { id : 'b' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 2 } } ,
112132 { id : 's' , type : 'ui-template' , props : { group : 'g1' , templateScope : 'local' , subflow : { id : 'sf1' , order : 0 } } , layout : { order : 1 } }
113133 ]
114- orderOf ( widgets ) . should . eql ( [ 'a' , 'b' , 's' ] )
134+ orderOf ( widgets ) . should . eql ( [ 's' , 'a' , 'b' ] )
135+ } )
136+
137+ it ( 'sinks a widget with no order to the end' , function ( ) {
138+ const widgets = [
139+ { id : 'a' , type : 'ui-text' , props : { group : 'g1' } , layout : { } } ,
140+ { id : 'b' , type : 'ui-text' , props : { group : 'g1' } , layout : { order : 0 } }
141+ ]
142+ orderOf ( widgets ) . should . eql ( [ 'b' , 'a' ] )
115143 } )
116144 } )
117145
0 commit comments