@@ -3257,12 +3257,11 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32573257
32583258 it ( 'Should not throw error when deleting the last chip' , ( async ( ) => {
32593259 grid . width = '700px' ;
3260- await wait ( 16 ) ;
32613260 fix . detectChanges ( ) ;
3261+ await wait ( 16 ) ;
32623262
32633263 GridFunctions . clickFilterCellChip ( fix , 'ProductName' ) ;
32643264 fix . detectChanges ( ) ;
3265- await wait ( 16 ) ;
32663265
32673266 // Add first chip.
32683267 GridFunctions . typeValueInFilterRowInput ( 'a' , fix ) ;
@@ -3287,7 +3286,7 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32873286
32883287 verifyMultipleChipsVisibility ( fix , [ false , false , false , true ] ) ;
32893288 const filterUIRow = fix . debugElement . query ( By . css ( FILTER_UI_ROW ) ) ;
3290- let chips = filterUIRow . queryAll ( By . directive ( IgxChipComponent ) ) ;
3289+ const chips = filterUIRow . queryAll ( By . directive ( IgxChipComponent ) ) ;
32913290 expect ( chips . length ) . toBe ( 4 ) ;
32923291
32933292 const leftArrowButton = GridFunctions . getFilterRowLeftArrowButton ( fix ) . nativeElement ;
@@ -3297,33 +3296,61 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32973296 expect ( rightArrowButton ) . toBeTruthy ( 'Right scroll arrow should be visible' ) ;
32983297 expect ( grid . rowList . length ) . toBe ( 2 ) ;
32993298
3300- try {
3301- GridFunctions . removeFilterChipByIndex ( 3 , filterUIRow ) ;
3302- fix . detectChanges ( ) ;
3303- await wait ( 400 ) ;
3304- } catch ( ex ) {
3305- expect ( ex ) . toBeNull ( 'Error deleting the last chip' ) ;
3306- }
3299+ let chipToRemove = filterUIRow . componentInstance . expressionsList [ 3 ] ;
3300+ expect ( ( ) => { filterUIRow . componentInstance . onChipRemoved ( null , chipToRemove ) ; } )
3301+ . not . toThrowError ( / \' i d \' o f u n d e f i n e d / ) ;
3302+ fix . detectChanges ( ) ;
3303+ await wait ( 500 ) ;
3304+ fix . detectChanges ( ) ;
3305+
3306+ chipToRemove = filterUIRow . componentInstance . expressionsList [ 2 ] ;
3307+ expect ( ( ) => { filterUIRow . componentInstance . onChipRemoved ( null , chipToRemove ) ; } )
3308+ . not . toThrowError ( / \' i d \' o f u n d e f i n e d / ) ;
33073309 fix . detectChanges ( ) ;
33083310 await wait ( 100 ) ;
3311+ } ) ) ;
3312+
3313+ it ( 'should scroll correct chip in view when one is deleted' , async ( ) => {
3314+ grid . width = '700px' ;
3315+ fix . detectChanges ( ) ;
3316+
3317+ GridFunctions . clickFilterCellChip ( fix , 'ProductName' ) ;
3318+ fix . detectChanges ( ) ;
3319+
3320+ GridFunctions . applyFilter ( 'a' , fix ) ;
3321+ await wait ( 16 ) ;
3322+ GridFunctions . applyFilter ( 'e' , fix ) ;
3323+ await wait ( 16 ) ;
3324+ GridFunctions . applyFilter ( 'i' , fix ) ;
3325+ await wait ( 16 ) ;
3326+ GridFunctions . applyFilter ( 'o' , fix ) ;
3327+ // wait for chip to be scrolled in view
3328+ await wait ( 200 ) ;
3329+ fix . detectChanges ( ) ;
3330+ await wait ( 100 ) ;
3331+ verifyMultipleChipsVisibility ( fix , [ false , false , false , true ] ) ;
3332+
3333+ const filterUIRow = fix . debugElement . query ( By . css ( FILTER_UI_ROW ) ) ;
3334+ GridFunctions . removeFilterChipByIndex ( 3 , filterUIRow ) ;
3335+ // wait for chip to be scrolled in view
3336+ fix . detectChanges ( ) ;
3337+ await wait ( 200 ) ;
3338+
33093339 verifyMultipleChipsVisibility ( fix , [ false , true , false ] ) ;
3310- chips = filterUIRow . queryAll ( By . directive ( IgxChipComponent ) ) ;
3340+ let chips = filterUIRow . queryAll ( By . directive ( IgxChipComponent ) ) ;
33113341 expect ( chips . length ) . toBe ( 3 ) ;
33123342
3313- try {
3314- GridFunctions . removeFilterChipByIndex ( 2 , filterUIRow ) ;
3315- fix . detectChanges ( ) ;
3316- await wait ( 400 ) ;
3317- } catch ( ex ) {
3318- expect ( ex ) . toBeNull ( 'Error deleting the last chip' ) ;
3319- }
3343+ GridFunctions . removeFilterChipByIndex ( 2 , filterUIRow ) ;
33203344 fix . detectChanges ( ) ;
3321- await wait ( 100 ) ;
3345+ // wait for chip to be scrolled in view
3346+ fix . detectChanges ( ) ;
3347+ await wait ( 200 ) ;
3348+
33223349 verifyMultipleChipsVisibility ( fix , [ true , false ] ) ;
33233350 chips = filterUIRow . queryAll ( By . directive ( IgxChipComponent ) ) ;
33243351 expect ( chips . length ) . toBe ( 2 ) ;
33253352 expect ( grid . rowList . length ) . toBe ( 3 ) ;
3326- } ) ) ;
3353+ } ) ;
33273354
33283355 it ( 'Should close filter row when hide the current column' , ( async ( ) => {
33293356 grid . height = '700px' ;
0 commit comments