@@ -13,6 +13,7 @@ import {
1313 ColumnEditablePropertyTestComponent
1414} from '../../test-utils/grid-samples.spec' ;
1515import { DebugElement } from '@angular/core' ;
16+ import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec' ;
1617
1718const DEBOUNCETIME = 30 ;
1819const CELL_CSS_CLASS = '.igx-grid__td' ;
@@ -381,38 +382,36 @@ describe('IgxGrid - Cell Editing #grid', () => {
381382 } ) ;
382383
383384 it ( 'When cell in editMode and try to navigate with `ArrowUp` - focus should remain over the input.' , ( async ( ) => {
384- const verticalScroll = grid . verticalScrollContainer . getScroll ( ) ;
385- let expectedScroll ;
386- let cellElem ;
387- GridFunctions . scrollTop ( grid , 1000 ) ;
388- await wait ( 500 ) ;
385+ setupGridScrollDetection ( fixture , grid ) ;
386+ grid . navigateTo ( 8 ) ;
387+ await wait ( DEBOUNCETIME ) ;
388+ fixture . detectChanges ( ) ;
389+ await wait ( DEBOUNCETIME ) ;
389390 fixture . detectChanges ( ) ;
390391
391- let testCells = grid . getColumnByName ( 'firstName' ) . cells ;
392+ const testCells = grid . getColumnByName ( 'firstName' ) . cells ;
392393 let cell = testCells [ testCells . length - 1 ] ;
393- cellElem = cell . nativeElement ;
394+ const cellRowIndex = cell . rowIndex ;
395+ let cellElem = cell . nativeElement ;
394396
395- cellElem . dispatchEvent ( new Event ( 'focus' ) ) ;
396- cellElem . dispatchEvent ( new MouseEvent ( 'dblclick' ) ) ;
397+ UIInteractions . simulateDoubleClickAndSelectEvent ( cellElem ) ;
398+ await wait ( DEBOUNCETIME ) ;
397399 fixture . detectChanges ( ) ;
398- await wait ( 50 ) ;
399400
400- let inputElem : HTMLInputElement = document . activeElement as HTMLInputElement ;
401+ const inputElem : HTMLInputElement = document . activeElement as HTMLInputElement ;
401402 expect ( cell . editMode ) . toBeTruthy ( ) ;
402403 expect ( cellElem . classList . contains ( CELL_CLASS_IN_EDIT_MODE ) ) . toBe ( true ) ;
403- expectedScroll = verticalScroll . scrollTop ;
404+ const expectedScroll = grid . verticalScrollContainer . getScroll ( ) . scrollTop ;
404405
405406 UIInteractions . triggerKeyDownEvtUponElem ( 'ArrowUp' , inputElem , true ) ;
406- fixture . detectChanges ( ) ;
407407 await wait ( DEBOUNCETIME ) ;
408+ fixture . detectChanges ( ) ;
408409
409- inputElem = document . activeElement as HTMLInputElement ;
410- testCells = grid . getColumnByName ( 'firstName' ) . cells ;
411- cell = testCells [ testCells . length - 1 ] ;
410+ cell = grid . getCellByColumn ( cellRowIndex , 'firstName' ) ;
412411 cellElem = cell . nativeElement ;
413412 expect ( cell . editMode ) . toBeTruthy ( ) ;
414413 expect ( cellElem . classList . contains ( CELL_CLASS_IN_EDIT_MODE ) ) . toBe ( true ) ;
415- expect ( verticalScroll . scrollTop ) . toBe ( expectedScroll ) ;
414+ expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . toBe ( expectedScroll ) ;
416415 } ) ) ;
417416
418417 it ( 'When cell in editMode and try to navigate with `ArrowRight` - focus should remain over the input.' , ( async ( ) => {
0 commit comments