@@ -4106,7 +4106,7 @@ describe('IgxGrid Component Tests', () => {
41064106 } ) ;
41074107
41084108 describe ( 'Row Editing - Grouping' , ( ) => {
4109- it ( 'Hide/show row editing dialog with group collapsing/expanding' , fakeAsync ( ( ) => {
4109+ it ( 'Hide row editing dialog with group collapsing/expanding' , fakeAsync ( ( ) => {
41104110 const fix = TestBed . createComponent ( IgxGridRowEditingWithFeaturesComponent ) ;
41114111 const grid = fix . componentInstance . instance ;
41124112 grid . primaryKey = 'ID' ;
@@ -4119,86 +4119,85 @@ describe('IgxGrid Component Tests', () => {
41194119 } ) ;
41204120 tick ( 16 ) ;
41214121 fix . detectChanges ( ) ;
4122- const cell = grid . getCellByColumn ( 1 , 'ProductName' ) ;
4122+
4123+ let cell = grid . getCellByColumn ( 6 , 'ProductName' ) ;
4124+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
4125+
4126+ // set cell in second group in edit mode
41234127 cell . setEditMode ( true ) ;
41244128 tick ( 16 ) ;
41254129 fix . detectChanges ( ) ;
4130+
4131+ expect ( grid . crudService . inEditMode ) . toBeTruthy ( ) ;
41264132 const groupRows = grid . groupsRowList . toArray ( ) ;
4133+ expect ( groupRows [ 0 ] . expanded ) . toBeTruthy ( ) ;
41274134
4128- expect ( groupRows [ 0 ] . expanded ) . toEqual ( true ) ;
4135+ // collapse first group
41294136 grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
41304137 tick ( 16 ) ;
41314138 fix . detectChanges ( ) ;
4132- expect ( groupRows [ 0 ] . expanded ) . toEqual ( false ) ;
4133- const overlayContent = grid . rowEditingOverlay . element . parentElement ;
4134- expect ( overlayContent . style . display ) . toEqual ( 'none' ) ;
4139+
4140+ expect ( groupRows [ 0 ] . expanded ) . toBeFalsy ( ) ;
4141+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
4142+
4143+ // expand first group
41354144 grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
41364145 tick ( 16 ) ;
41374146 fix . detectChanges ( ) ;
4138- expect ( groupRows [ 0 ] . expanded ) . toEqual ( true ) ;
4139- expect ( overlayContent . style . display ) . toEqual ( '' ) ;
4140- } ) ) ;
41414147
4142- it ( 'Do not hide/show row editing dialog when another group is collapsing/expanding and check that overlay is moving with row' ,
4143- fakeAsync ( ( ) => {
4144- const fix = TestBed . createComponent ( IgxGridRowEditingWithFeaturesComponent ) ;
4145- const grid = fix . componentInstance . instance ;
4146- grid . primaryKey = 'ID' ;
4147- fix . detectChanges ( ) ;
4148- tick ( 16 ) ;
4148+ expect ( groupRows [ 0 ] . expanded ) . toBeTruthy ( ) ;
4149+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
41494150
4150- grid . groupBy ( {
4151- fieldName : 'Released' , dir : SortingDirection . Desc , ignoreCase : false ,
4152- strategy : DefaultSortingStrategy . instance ( )
4153- } ) ;
4154- tick ( 16 ) ;
4155- fix . detectChanges ( ) ;
4156- let row : HTMLElement ;
4157- const cell = grid . getCellByColumn ( 7 , 'ProductName' ) ;
4158- cell . setEditMode ( true ) ;
4159- tick ( 16 ) ;
4160- fix . detectChanges ( ) ;
4161- const overlayElem : HTMLElement = document . getElementsByClassName ( EDIT_OVERLAY_CONTENT ) [ 0 ] as HTMLElement ;
4162- const groupRows = grid . groupsRowList . toArray ( ) ;
4151+ // collapse first group
4152+ grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4153+ tick ( 16 ) ;
4154+ fix . detectChanges ( ) ;
41634155
4164- grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4165- tick ( 16 ) ;
4166- fix . detectChanges ( ) ;
4167- const overlayContent = grid . rowEditingOverlay . element . parentElement ;
4168- expect ( overlayContent . style . display ) . toEqual ( '' ) ;
4156+ expect ( groupRows [ 0 ] . expanded ) . toBeFalsy ( ) ;
4157+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
41694158
4170- row = grid . getRowByIndex ( 3 ) . nativeElement ;
4171- expect ( row . getBoundingClientRect ( ) . bottom === overlayElem . getBoundingClientRect ( ) . top ) . toBeTruthy ( ) ;
4172- grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4173- tick ( 16 ) ;
4174- fix . detectChanges ( ) ;
4175- expect ( overlayContent . style . display ) . toEqual ( '' ) ;
4176- row = grid . getRowByIndex ( 7 ) . nativeElement ;
4177- expect ( row . getBoundingClientRect ( ) . bottom === overlayElem . getBoundingClientRect ( ) . top ) . toBeTruthy ( ) ;
4159+ // set cell in second group in edit mode
4160+ cell . setEditMode ( true ) ;
4161+ tick ( 16 ) ;
4162+ fix . detectChanges ( ) ;
41784163
4179- grid . toggleGroup ( groupRows [ 1 ] . groupRow ) ;
4180- tick ( 16 ) ;
4181- fix . detectChanges ( ) ;
4182- expect ( overlayContent . style . display ) . toEqual ( 'none' ) ;
4164+ expect ( grid . crudService . inEditMode ) . toBeTruthy ( ) ;
41834165
4184- grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4185- tick ( 16 ) ;
4186- fix . detectChanges ( ) ;
4187- expect ( overlayContent . style . display ) . toEqual ( 'none' ) ;
4188- grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4189- tick ( 16 ) ;
4190- fix . detectChanges ( ) ;
4191- expect ( overlayContent . style . display ) . toEqual ( 'none' ) ;
4166+ // expand first group
4167+ grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4168+ tick ( 16 ) ;
4169+ fix . detectChanges ( ) ;
41924170
4193- grid . toggleGroup ( groupRows [ 1 ] . groupRow ) ;
4194- tick ( 16 ) ;
4195- fix . detectChanges ( ) ;
4196- expect ( overlayContent . style . display ) . toEqual ( '' ) ;
4197- row = grid . getRowByIndex ( 7 ) . nativeElement ;
4198- expect ( row . getBoundingClientRect ( ) . bottom === overlayElem . getBoundingClientRect ( ) . top ) . toBeTruthy ( ) ;
4199- } ) ) ;
4171+ expect ( groupRows [ 0 ] . expanded ) . toBeTruthy ( ) ;
4172+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
4173+
4174+ // set cell in first group in edit mode
4175+ cell = grid . getCellByColumn ( 1 , 'ProductName' ) ;
4176+ cell . setEditMode ( true ) ;
4177+ tick ( 16 ) ;
4178+ fix . detectChanges ( ) ;
4179+
4180+ expect ( grid . crudService . inEditMode ) . toBeTruthy ( ) ;
4181+ expect ( groupRows [ 0 ] . expanded ) . toBeTruthy ( ) ;
4182+
4183+ // collapse first group
4184+ grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4185+ tick ( 16 ) ;
4186+ fix . detectChanges ( ) ;
4187+
4188+ expect ( groupRows [ 0 ] . expanded ) . toBeFalsy ( ) ;
4189+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
4190+
4191+ // expand first group
4192+ grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
4193+ tick ( 16 ) ;
4194+ fix . detectChanges ( ) ;
4195+
4196+ expect ( groupRows [ 0 ] . expanded ) . toBeTruthy ( ) ;
4197+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
4198+ } ) ) ;
42004199
4201- it ( 'Hide/show row editing dialog when hierarchical group is collapsed/expanded' ,
4200+ it ( 'Hide row editing dialog when hierarchical group is collapsed/expanded' ,
42024201 fakeAsync ( ( ) => {
42034202 const fix = TestBed . createComponent ( IgxGridRowEditingWithFeaturesComponent ) ;
42044203 const grid = fix . componentInstance . instance ;
@@ -4217,21 +4216,22 @@ describe('IgxGrid Component Tests', () => {
42174216 } ) ;
42184217 tick ( 16 ) ;
42194218 fix . detectChanges ( ) ;
4219+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
42204220 const cell = grid . getCellByColumn ( 2 , 'ProductName' ) ;
42214221 cell . setEditMode ( true ) ;
42224222 tick ( 16 ) ;
42234223 fix . detectChanges ( ) ;
4224+ expect ( grid . crudService . inEditMode ) . toBeTruthy ( ) ;
42244225 const groupRows = grid . groupsRowList . toArray ( ) ;
42254226
42264227 grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
42274228 tick ( 16 ) ;
42284229 fix . detectChanges ( ) ;
4229- const overlayContent = grid . rowEditingOverlay . element . parentElement ;
4230- expect ( overlayContent . style . display ) . toEqual ( 'none' ) ;
4230+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
42314231 grid . toggleGroup ( groupRows [ 0 ] . groupRow ) ;
42324232 tick ( 16 ) ;
42334233 fix . detectChanges ( ) ;
4234- expect ( overlayContent . style . display ) . toEqual ( '' ) ;
4234+ expect ( grid . crudService . inEditMode ) . toBeFalsy ( ) ;
42354235 } ) ) ;
42364236 } ) ;
42374237 } ) ;
0 commit comments