@@ -163,24 +163,93 @@ describe('AnalyticalTable', () => {
163163 cy . findByText ( 'Name' ) . click ( ) ;
164164 cy . get ( '[ui5-popover]' ) . should ( 'be.visible' ) ;
165165 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Ascending' ) ;
166- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
167- detail : { column : { id : 'name' } , sortDirection : 'asc' } ,
168- } ) ;
166+ cy . get ( '@onSortSpy' )
167+ . its ( 'lastCall' )
168+ . should ( 'have.been.calledWithMatch' , {
169+ detail : { column : { id : 'name' } , sortDirection : 'asc' } ,
170+ } ) ;
169171 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
170172
171173 cy . findByText ( 'Name' ) . click ( ) ;
172174 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Clear Sorting' ) ;
173- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
174- detail : { column : { id : 'name' } , sortDirection : 'clear' } ,
175- } ) ;
175+ cy . get ( '@onSortSpy' )
176+ . its ( 'lastCall' )
177+ . should ( 'have.been.calledWithMatch' , {
178+ detail : { column : { id : 'name' } , sortDirection : 'clear' } ,
179+ } ) ;
176180 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'X' ) ;
177181
178182 cy . findByText ( 'Name' ) . click ( ) ;
179183 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Descending' ) ;
180- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
181- detail : { column : { id : 'name' } , sortDirection : 'desc' } ,
182- } ) ;
184+ cy . get ( '@onSortSpy' )
185+ . its ( 'lastCall' )
186+ . should ( 'have.been.calledWithMatch' , {
187+ detail : { column : { id : 'name' } , sortDirection : 'desc' } ,
188+ } ) ;
189+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
190+
191+ cy . log ( 'subRows sorting' ) ;
192+ const treeData = [
193+ {
194+ category : 'Number' ,
195+ subRows : [ { category : '2' } , { category : '1' } , { category : '3' } ] ,
196+ } ,
197+ {
198+ category : 'Alphabet' ,
199+ subRows : [ { category : 'B' } , { category : 'A' } , { category : 'C' } ] ,
200+ } ,
201+ ] ;
202+ const treeColumns : AnalyticalTableColumnDefinition [ ] = [ { Header : 'Category' , accessor : 'category' } ] ;
203+ cy . mount ( < AnalyticalTable data = { treeData } columns = { treeColumns } sortable isTreeTable onSort = { sort } /> ) ;
204+ // expand rows
205+ cy . get ( '[ui5-button]' ) . click ( { multiple : true } ) ;
206+ cy . findByText ( 'Category' ) . click ( ) ;
207+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Ascending' ) ;
208+ cy . get ( '@onSortSpy' )
209+ . its ( 'lastCall' )
210+ . should ( 'have.been.calledWithMatch' , {
211+ detail : { column : { id : 'category' } , sortDirection : 'asc' } ,
212+ } ) ;
213+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
214+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
183215 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
216+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
217+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
218+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
219+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
220+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
221+
222+ cy . findByText ( 'Category' ) . click ( ) ;
223+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Descending' ) ;
224+ cy . get ( '@onSortSpy' )
225+ . its ( 'lastCall' )
226+ . should ( 'have.been.calledWithMatch' , {
227+ detail : { column : { id : 'category' } , sortDirection : 'desc' } ,
228+ } ) ;
229+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
230+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
231+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
232+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
233+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
234+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
235+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
236+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
237+
238+ cy . findByText ( 'Category' ) . click ( ) ;
239+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Clear Sorting' ) ;
240+ cy . get ( '@onSortSpy' )
241+ . its ( 'lastCall' )
242+ . should ( 'have.been.calledWithMatch' , {
243+ detail : { column : { id : 'category' } , sortDirection : 'clear' } ,
244+ } ) ;
245+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
246+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
247+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
248+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
249+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
250+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
251+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
252+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
184253 } ) ;
185254
186255 it ( 'row count modes' , ( ) => {
0 commit comments