@@ -112,24 +112,93 @@ describe('AnalyticalTable', () => {
112112 cy . findByText ( 'Name' ) . click ( ) ;
113113 cy . get ( '[ui5-popover]' ) . should ( 'be.visible' ) ;
114114 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Ascending' ) ;
115- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
116- detail : { column : { id : 'name' } , sortDirection : 'asc' } ,
117- } ) ;
115+ cy . get ( '@onSortSpy' )
116+ . its ( 'lastCall' )
117+ . should ( 'have.been.calledWithMatch' , {
118+ detail : { column : { id : 'name' } , sortDirection : 'asc' } ,
119+ } ) ;
118120 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
119121
120122 cy . findByText ( 'Name' ) . click ( ) ;
121123 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Clear Sorting' ) ;
122- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
123- detail : { column : { id : 'name' } , sortDirection : 'clear' } ,
124- } ) ;
124+ cy . get ( '@onSortSpy' )
125+ . its ( 'lastCall' )
126+ . should ( 'have.been.calledWithMatch' , {
127+ detail : { column : { id : 'name' } , sortDirection : 'clear' } ,
128+ } ) ;
125129 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'X' ) ;
126130
127131 cy . findByText ( 'Name' ) . click ( ) ;
128132 cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Descending' ) ;
129- cy . get ( '@onSortSpy' ) . should ( 'have.been.calledWithMatch' , {
130- detail : { column : { id : 'name' } , sortDirection : 'desc' } ,
131- } ) ;
133+ cy . get ( '@onSortSpy' )
134+ . its ( 'lastCall' )
135+ . should ( 'have.been.calledWithMatch' , {
136+ detail : { column : { id : 'name' } , sortDirection : 'desc' } ,
137+ } ) ;
138+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
139+
140+ cy . log ( 'subRows sorting' ) ;
141+ const treeData = [
142+ {
143+ category : 'Number' ,
144+ subRows : [ { category : '2' } , { category : '1' } , { category : '3' } ] ,
145+ } ,
146+ {
147+ category : 'Alphabet' ,
148+ subRows : [ { category : 'B' } , { category : 'A' } , { category : 'C' } ] ,
149+ } ,
150+ ] ;
151+ const treeColumns : AnalyticalTableColumnDefinition [ ] = [ { Header : 'Category' , accessor : 'category' } ] ;
152+ cy . mount ( < AnalyticalTable data = { treeData } columns = { treeColumns } sortable isTreeTable onSort = { sort } /> ) ;
153+ // expand rows
154+ cy . get ( '[ui5-button]' ) . click ( { multiple : true } ) ;
155+ cy . findByText ( 'Category' ) . click ( ) ;
156+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Ascending' ) ;
157+ cy . get ( '@onSortSpy' )
158+ . its ( 'lastCall' )
159+ . should ( 'have.been.calledWithMatch' , {
160+ detail : { column : { id : 'category' } , sortDirection : 'asc' } ,
161+ } ) ;
162+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
163+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
132164 cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
165+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
166+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
167+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
168+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
169+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
170+
171+ cy . findByText ( 'Category' ) . click ( ) ;
172+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Sort Descending' ) ;
173+ cy . get ( '@onSortSpy' )
174+ . its ( 'lastCall' )
175+ . should ( 'have.been.calledWithMatch' , {
176+ detail : { column : { id : 'category' } , sortDirection : 'desc' } ,
177+ } ) ;
178+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
179+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
180+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
181+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
182+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
183+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
184+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
185+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
186+
187+ cy . findByText ( 'Category' ) . click ( ) ;
188+ cy . get ( '[ui5-list]' ) . clickUi5ListItemByText ( 'Clear Sorting' ) ;
189+ cy . get ( '@onSortSpy' )
190+ . its ( 'lastCall' )
191+ . should ( 'have.been.calledWithMatch' , {
192+ detail : { column : { id : 'category' } , sortDirection : 'clear' } ,
193+ } ) ;
194+ cy . get ( '[aria-rowindex="1"] > [aria-colindex="1"]' ) . should ( 'text' , 'Number' ) ;
195+ cy . get ( '[aria-rowindex="2"] > [aria-colindex="1"]' ) . should ( 'text' , '2' ) ;
196+ cy . get ( '[aria-rowindex="3"] > [aria-colindex="1"]' ) . should ( 'text' , '1' ) ;
197+ cy . get ( '[aria-rowindex="4"] > [aria-colindex="1"]' ) . should ( 'text' , '3' ) ;
198+ cy . get ( '[aria-rowindex="5"] > [aria-colindex="1"]' ) . should ( 'text' , 'Alphabet' ) ;
199+ cy . get ( '[aria-rowindex="6"] > [aria-colindex="1"]' ) . should ( 'text' , 'B' ) ;
200+ cy . get ( '[aria-rowindex="7"] > [aria-colindex="1"]' ) . should ( 'text' , 'A' ) ;
201+ cy . get ( '[aria-rowindex="8"] > [aria-colindex="1"]' ) . should ( 'text' , 'C' ) ;
133202 } ) ;
134203
135204 it ( 'row count modes' , ( ) => {
0 commit comments