@@ -6,6 +6,7 @@ import { IgxTreeGridGroupByAreaComponent } from 'igniteui-angular/grids/tree-gri
66import { TreeGridFunctions } from '../../../test-utils/tree-grid-functions.spec' ;
77import { IgxTreeGridComponent } from './tree-grid.component' ;
88import { DefaultSortingStrategy } from 'igniteui-angular/core' ;
9+ import { GridFunctions } from '../../../test-utils/grid-functions.spec' ;
910
1011describe ( 'IgxTreeGrid' , ( ) => {
1112
@@ -24,7 +25,7 @@ describe('IgxTreeGrid', () => {
2425 let groupByArea : IgxTreeGridGroupByAreaComponent ;
2526
2627 const DROP_AREA_MSG = 'Drag a column header and drop it here to group by that column.' ;
27- describe ( ' GroupByArea Standalone' , ( ) => {
28+ describe ( ' GroupByArea Standalone' , ( ) => {
2829
2930 beforeEach ( ( ) => {
3031 fix = TestBed . createComponent ( IgxTreeGridGroupByAreaTestComponent ) ;
@@ -53,7 +54,7 @@ describe('IgxTreeGrid', () => {
5354 expect ( spanElement . innerText ) . toEqual ( DROP_AREA_MSG ) ;
5455 } ) ) ;
5556
56- it ( 'has the expected default properties\' values' , fakeAsync ( ( ) => {
57+ it ( 'has the expected default properties\' values' , fakeAsync ( ( ) => {
5758 expect ( groupByArea ) . toBeDefined ( ) ;
5859 expect ( groupByArea . grid ) . toEqual ( treeGrid ) ;
5960 expect ( groupByArea . expressions ) . toEqual ( [ ] ) ;
@@ -97,7 +98,7 @@ describe('IgxTreeGrid', () => {
9798 clearGridSubs ( ) ;
9899 } ) ;
99100
100- it ( 'GroupByArea has the expected properties\' values set' , fakeAsync ( ( ) => {
101+ it ( 'GroupByArea has the expected properties\' values set' , fakeAsync ( ( ) => {
101102 expect ( groupByArea ) . toBeDefined ( ) ;
102103 expect ( groupByArea . expressions . length ) . toEqual ( 2 ) ;
103104 expect ( groupByArea . grid ) . toEqual ( treeGrid ) ;
@@ -132,7 +133,7 @@ describe('IgxTreeGrid', () => {
132133 expect ( chips [ 0 ] . id ) . toEqual ( 'OnPTO' ) ;
133134 expect ( chips [ 1 ] . id ) . toEqual ( 'HireDate' ) ;
134135
135- groupingExpressions . push ( { fieldName : 'JobTitle' , dir : 2 , ignoreCase : true , strategy : DefaultSortingStrategy . instance ( ) } ) ;
136+ groupingExpressions . push ( { fieldName : 'JobTitle' , dir : 2 , ignoreCase : true , strategy : DefaultSortingStrategy . instance ( ) } ) ;
136137 fix . detectChanges ( ) ;
137138 tick ( ) ;
138139
@@ -180,7 +181,7 @@ describe('IgxTreeGrid', () => {
180181
181182 expect ( treeGrid . getColumnByName ( 'HireDate' ) . hidden ) . toBeFalse ( ) ;
182183
183- groupingExpressions . push ( { fieldName : 'JobTitle' , dir : 2 , ignoreCase : true , strategy : DefaultSortingStrategy . instance ( ) } ) ;
184+ groupingExpressions . push ( { fieldName : 'JobTitle' , dir : 2 , ignoreCase : true , strategy : DefaultSortingStrategy . instance ( ) } ) ;
184185 groupByArea . expressions = [ ...groupingExpressions ] ;
185186 fix . detectChanges ( ) ;
186187 tick ( ) ;
@@ -195,7 +196,7 @@ describe('IgxTreeGrid', () => {
195196 const aggregations = [ {
196197 field : 'HireDate' ,
197198 aggregate : ( _parent : any , children : any [ ] ) => children . map ( ( c ) => c . HireDate )
198- . reduce ( ( min , c ) => min < c ? min : c , new Date ( ) )
199+ . reduce ( ( min , c ) => min < c ? min : c , new Date ( ) )
199200 } ] ;
200201
201202 fix . componentInstance . aggregations = aggregations ;
@@ -296,6 +297,51 @@ describe('IgxTreeGrid', () => {
296297 expect ( treeGrid . getColumnByName ( 'OnPTO' ) . hidden ) . toBeTrue ( ) ;
297298 expect ( treeGrid . getColumnByName ( 'HireDate' ) . hidden ) . toBeTrue ( ) ;
298299 } ) ) ;
300+
301+ it ( 'should handle excel style filtering when grouping is applied and 3 or more items are selected' , fakeAsync ( ( ) => {
302+ treeGrid . filterMode = 'excelStyleFilter' ;
303+ treeGrid . allowFiltering = true ;
304+ treeGrid . expansionDepth = Infinity ;
305+ fix . detectChanges ( ) ;
306+ GridFunctions . clickExcelFilterIconFromCode ( fix , treeGrid , 'Name' ) ;
307+ const checkboxes = GridFunctions . getExcelStyleFilteringCheckboxes ( fix , null , 'igx-tree-grid' ) ;
308+ // unselect all
309+ checkboxes [ 0 ] . click ( ) ;
310+ fix . detectChanges ( ) ;
311+
312+ checkboxes [ 2 ] . click ( ) ;
313+ checkboxes [ 3 ] . click ( ) ;
314+ checkboxes [ 4 ] . click ( ) ;
315+ fix . detectChanges ( ) ;
316+
317+ GridFunctions . clickApplyExcelStyleFiltering ( fix , null , 'igx-tree-grid' ) ;
318+ fix . detectChanges ( ) ;
319+
320+
321+ expect ( treeGrid . filteredData . length ) . toEqual ( 8 ) ;
322+ } ) ) ;
323+
324+ it ( 'should handle excel style filtering when grouping is applied and preserve all checked esf items' , fakeAsync ( ( ) => {
325+ treeGrid . filterMode = 'excelStyleFilter' ;
326+ treeGrid . allowFiltering = true ;
327+ treeGrid . expansionDepth = Infinity ;
328+ fix . detectChanges ( ) ;
329+ GridFunctions . clickExcelFilterIconFromCode ( fix , treeGrid , 'Name' ) ;
330+ let checkboxes : HTMLInputElement [ ] = Array . from ( GridFunctions . getExcelStyleFilteringCheckboxes ( fix , null , 'igx-tree-grid' ) as HTMLInputElement [ ] ) ;
331+ // unselect just one
332+ checkboxes [ 2 ] . click ( ) ;
333+ fix . detectChanges ( ) ;
334+
335+ GridFunctions . clickApplyExcelStyleFiltering ( fix , null , 'igx-tree-grid' ) ;
336+ fix . detectChanges ( ) ;
337+
338+ GridFunctions . clickExcelFilterIconFromCode ( fix , treeGrid , 'Name' ) ;
339+ checkboxes = Array . from ( GridFunctions . getExcelStyleFilteringCheckboxes ( fix , null , 'igx-tree-grid' ) as HTMLInputElement [ ] ) ;
340+
341+ const uncheckedItem = checkboxes . splice ( 2 , 1 ) [ 0 ] ;
342+ expect ( uncheckedItem . checked ) . toBeFalse ( ) ;
343+ checkboxes . forEach ( c => expect ( c . checked ) . toBeTrue ( ) ) ;
344+ } ) ) ;
299345 } ) ;
300346
301347 const getChips = ( fixture ) => {
0 commit comments