@@ -3,8 +3,8 @@ import { By } from '@angular/platform-browser';
33import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
44import { IgxPivotGridModule } from 'igniteui-angular' ;
55import { configureTestSuite } from '../../test-utils/configure-suite' ;
6- import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
7- import { IgxPivotGridTestBaseComponent , IgxTotalSaleAggregate } from '../../test-utils/pivot-grid-samples.spec' ;
6+ import { GridFunctions , GridSelectionFunctions } from '../../test-utils/grid-functions.spec' ;
7+ import { IgxPivotGridTestBaseComponent , IgxPivotGridTestComplexHierarchyComponent , IgxTotalSaleAggregate } from '../../test-utils/pivot-grid-samples.spec' ;
88import { UIInteractions } from '../../test-utils/ui-interactions.spec' ;
99const CSS_CLASS_DROP_DOWN_BASE = 'igx-drop-down' ;
1010const CSS_CLASS_LIST = 'igx-drop-down__list' ;
@@ -409,3 +409,130 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
409409 } ) ;
410410 } ) ;
411411} ) ;
412+
413+ describe ( 'IgxPivotGrid complex hierarchy #pivotGrid' , ( ) => {
414+ let fixture ;
415+ configureTestSuite ( ( ( ) => {
416+ TestBed . configureTestingModule ( {
417+ declarations : [
418+ IgxPivotGridTestComplexHierarchyComponent
419+ ] ,
420+ imports : [
421+ NoopAnimationsModule , IgxPivotGridModule ]
422+ } ) ;
423+ } ) ) ;
424+
425+ beforeEach ( fakeAsync ( ( ) => {
426+ fixture = TestBed . createComponent ( IgxPivotGridTestComplexHierarchyComponent ) ;
427+ fixture . detectChanges ( ) ;
428+ } ) ) ;
429+
430+ it ( 'should select/deselect the correct row' , ( ) => {
431+ fixture . detectChanges ( ) ;
432+ const pivotGrid = fixture . componentInstance . pivotGrid ;
433+ const pivotRows = GridFunctions . getPivotRows ( fixture ) ;
434+ const row = pivotRows [ 2 ] . componentInstance ;
435+ row . selectPivotRow ( row . rowDimensionData [ 1 ] . column ) ;
436+ fixture . detectChanges ( ) ;
437+ expect ( row . selected ) . toBeTrue ( ) ;
438+ expect ( pivotGrid . selectedRows ) . not . toBeNull ( ) ;
439+ expect ( pivotGrid . selectedRows . length ) . toBe ( 1 ) ;
440+ const expected =
441+ {
442+ 'All cities' : 'All Cities' , 'All cities_level' : 0 ,
443+ ProductCategory : 'Clothing' , ProductCategory_level : 1 ,
444+ 'Bulgaria-AmountOfSale' : 3612.42 , 'Bulgaria-UnitsSold' : 282 ,
445+ 'US-AmountOfSale' : 14672.72 , 'US-UnitsSold' : 296 ,
446+ 'Uruguay-AmountOfSale' : 31158.48 , 'Uruguay-UnitsSold' : 456
447+ } ;
448+ expect ( pivotGrid . selectedRows [ 0 ] ) . toEqual ( expected ) ;
449+
450+ //deselect
451+ row . selectPivotRow ( row . rowDimensionData [ 1 ] . column ) ;
452+ fixture . detectChanges ( ) ;
453+ expect ( row . selected ) . toBeFalse ( ) ;
454+ expect ( pivotGrid . selectedRows . length ) . toBe ( 0 ) ;
455+ } ) ;
456+
457+ it ( 'should select/deselect the correct group of rows' , ( ) => {
458+ fixture . detectChanges ( ) ;
459+ const pivotGrid = fixture . componentInstance . pivotGrid ;
460+ const pivotRows = GridFunctions . getPivotRows ( fixture ) ;
461+ const row = pivotRows [ 2 ] . componentInstance ;
462+ row . selectPivotRow ( row . rowDimensionData [ 0 ] . column ) ;
463+ fixture . detectChanges ( ) ;
464+ for ( let i = 0 ; i < 5 ; ++ i ) {
465+ expect ( pivotRows [ i ] . componentInstance . selected ) . toBeTrue ( ) ;
466+ }
467+ expect ( pivotGrid . selectedRows ) . not . toBeNull ( ) ;
468+ expect ( pivotGrid . selectedRows . length ) . toBe ( 5 ) ;
469+ const expected =
470+ [
471+ {
472+ AllProducts : 'AllProducts' , 'All cities' : 'All Cities' ,
473+ 'All cities_level' : 0 , AllProducts_level : 0 , 'Bulgaria-UnitsSold' : 774 ,
474+ 'Bulgaria-AmountOfSale' : 11509.02 , 'US-UnitsSold' : 296 , 'US-AmountOfSale' : 14672.72 ,
475+ 'Uruguay-UnitsSold' : 524 , 'Uruguay-AmountOfSale' : 31400.56 ,
476+ 'UK-UnitsSold' : 293 , 'UK-AmountOfSale' : 25074.94 ,
477+ 'Japan-UnitsSold' : 240 , 'Japan-AmountOfSale' : 4351.2 ,
478+ } , {
479+ ProductCategory : 'Bikes' , 'All cities' : 'All Cities' ,
480+ ProductCategory_level : 1 , 'All cities_level' : 0 ,
481+ 'Uruguay-UnitsSold' : 68 , 'Uruguay-AmountOfSale' : 242.08 ,
482+ City : 'Ciudad de la Costa' , Country : 'Uruguay' ,
483+ Date : '01/06/2011' , SellerName : 'Lydia Burson' ,
484+ UnitPrice : 3.56 , UnitsSold : 68
485+ } , {
486+ ProductCategory : 'Clothing' , 'All cities' : 'All Cities' ,
487+ ProductCategory_level : 1 , 'All cities_level' : 0 , 'Bulgaria-UnitsSold' : 282 ,
488+ 'Bulgaria-AmountOfSale' : 3612.42 , 'US-UnitsSold' : 296 , 'US-AmountOfSale' : 14672.72 ,
489+ 'Uruguay-UnitsSold' : 456 , 'Uruguay-AmountOfSale' : 31158.48
490+ } , {
491+ ProductCategory : 'Accessories' , 'All cities' : 'All Cities' ,
492+ ProductCategory_level : 1 , 'All cities_level' : 0 ,
493+ 'UK-UnitsSold' : 293 , 'UK-AmountOfSale' : 25074.94 ,
494+ City : 'London' , Country : 'UK' , Date : '04/07/2012' ,
495+ SellerName : 'David Haley' , UnitPrice : 85.58 , UnitsSold : 293
496+ } , {
497+ ProductCategory : 'Components' , 'All cities' : 'All Cities' ,
498+ ProductCategory_level : 1 , 'All cities_level' : 0 ,
499+ 'Japan-UnitsSold' : 240 , 'Japan-AmountOfSale' : 4351.2 ,
500+ 'Bulgaria-UnitsSold' : 492 , 'Bulgaria-AmountOfSale' : 7896.6
501+ }
502+ ] ;
503+ expect ( pivotGrid . selectedRows ) . toEqual ( expected ) ;
504+ } ) ;
505+
506+ it ( 'should select/deselect the correct column' , ( ) => {
507+ fixture . detectChanges ( ) ;
508+ const pivotGrid = fixture . componentInstance . pivotGrid ;
509+ const unitsSold = pivotGrid . getColumnByName ( 'Bulgaria-UnitsSold' ) ;
510+ GridFunctions . clickColumnHeaderUI ( 'Bulgaria-UnitsSold' , fixture ) ;
511+ GridSelectionFunctions . verifyColumnAndCellsSelected ( unitsSold ) ;
512+ } ) ;
513+
514+ it ( 'should select/deselect the correct column group' , ( ) => {
515+ fixture . detectChanges ( ) ;
516+ const pivotGrid = fixture . componentInstance . pivotGrid ;
517+ const group = GridFunctions . getColGroup ( pivotGrid , 'Bulgaria' ) ;
518+ const unitsSold = pivotGrid . getColumnByName ( 'Bulgaria-UnitsSold' ) ;
519+ const amountOfSale = pivotGrid . getColumnByName ( 'Bulgaria-AmountOfSale' ) ;
520+ const unitsSoldUSA = pivotGrid . getColumnByName ( 'US-UnitsSold' ) ;
521+ const amountOfSaleUSA = pivotGrid . getColumnByName ( 'US-AmountOfSale' ) ;
522+
523+ GridFunctions . clickColumnGroupHeaderUI ( 'Bulgaria' , fixture ) ;
524+ fixture . detectChanges ( ) ;
525+
526+ GridSelectionFunctions . verifyColumnSelected ( unitsSold ) ;
527+ GridSelectionFunctions . verifyColumnSelected ( amountOfSale ) ;
528+ GridSelectionFunctions . verifyColumnGroupSelected ( fixture , group ) ;
529+
530+ GridSelectionFunctions . verifyColumnsSelected ( [ unitsSoldUSA , amountOfSaleUSA ] , false ) ;
531+
532+ GridFunctions . clickColumnGroupHeaderUI ( 'Bulgaria' , fixture ) ;
533+
534+ GridSelectionFunctions . verifyColumnSelected ( unitsSold , false ) ;
535+ GridSelectionFunctions . verifyColumnSelected ( amountOfSale , false ) ;
536+ GridSelectionFunctions . verifyColumnGroupSelected ( fixture , group , false ) ;
537+ } ) ;
538+ } ) ;
0 commit comments