@@ -22,9 +22,28 @@ import { addFocusableElementBefore } from '../../../../helpers/domUtils';
2222
2323const CLASS = ClassNames ;
2424const FOCUS_ASSERTION_TIMEOUT = 3000 ;
25+ // Ctrl+End/Ctrl+Home over virtual/infinite scrolling renders the far row/column
26+ // asynchronously, which can exceed a short budget on a loaded CI machine.
27+ const KEYBOARD_NAVIGATION_TIMEOUT = 7000 ;
2528
2629const getOnKeyDownCallCount = ClientFunction ( ( ) => ( window as any ) . onKeyDownCallCount ) ;
2730
31+ const isKeyboardNavigationInProgress = ClientFunction ( ( ) => {
32+ const dataGrid = ( $ ( '#container' ) as any ) . dxDataGrid ( 'instance' ) ;
33+
34+ return dataGrid
35+ . getController ( 'keyboardNavigation' )
36+ . navigationToCellInProgress ( ) ;
37+ } ) ;
38+
39+ // Waits until the keyboard navigation controller has finished scrolling to / focusing the
40+ // target cell, so the focus state and the recorded focus events are settled before asserting.
41+ const waitForKeyboardNavigation = async ( t : TestController ) : Promise < void > => {
42+ await t
43+ . expect ( isKeyboardNavigationInProgress ( ) )
44+ . notOk ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } ) ;
45+ } ;
46+
2847fixture . disablePageReloads `Keyboard Navigation - common`
2948 . page ( url ( __dirname , '../../../container.html' ) ) ;
3049
@@ -5763,7 +5782,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
57635782 // assert
57645783 await t
57655784 . expect ( dataGrid . getDataCell ( 0 , 14 ) . element . focused )
5766- . ok ( )
5785+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
57675786 . expect ( getOrderOfEventCalls ( ) )
57685787 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
57695788
@@ -5840,7 +5859,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
58405859 // assert
58415860 await t
58425861 . expect ( dataGrid . getDataCell ( 0 , 34 ) . element . focused )
5843- . ok ( )
5862+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
58445863 . expect ( getOrderOfEventCalls ( ) )
58455864 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
58465865
@@ -5918,7 +5937,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
59185937 // assert
59195938 await t
59205939 . expect ( dataGrid . getDataCell ( 0 , 14 ) . element . focused )
5921- . ok ( )
5940+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
59225941 . expect ( getOrderOfEventCalls ( ) )
59235942 . eql ( [ 'onFocusedCellChanging' , 'onFocusedRowChanging' , 'onFocusedCellChanged' ] ) ;
59245943
@@ -6002,7 +6021,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
60026021 // assert
60036022 await t
60046023 . expect ( dataGrid . getDataCell ( 0 , 34 ) . element . focused )
6005- . ok ( )
6024+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
60066025 . expect ( getOrderOfEventCalls ( ) )
60076026 . eql ( [ 'onFocusedCellChanging' , 'onFocusedRowChanging' , 'onFocusedCellChanged' ] ) ;
60086027
@@ -6088,7 +6107,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
60886107 // assert
60896108 await t
60906109 . expect ( dataGrid . getDataCell ( 19 , 14 ) . element . focused )
6091- . ok ( )
6110+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
60926111 . expect ( getOrderOfEventCalls ( ) )
60936112 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
60946113
@@ -6165,7 +6184,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
61656184 // assert
61666185 await t
61676186 . expect ( dataGrid . getDataCell ( 19 , 34 ) . element . focused )
6168- . ok ( )
6187+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
61696188 . expect ( getOrderOfEventCalls ( ) )
61706189 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
61716190
@@ -6239,12 +6258,12 @@ test('The last cell should be focused after changing the page size (T1063530)',
62396258
62406259 // act
62416260 await t . pressKey ( 'ctrl+end' ) ;
6242- await t . wait ( 100 ) ;
6261+ await waitForKeyboardNavigation ( t ) ;
62436262
62446263 // assert
62456264 await t
62466265 . expect ( dataGrid . getDataCell ( 199 , 34 ) . element . focused )
6247- . ok ( )
6266+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
62486267 . expect ( getOrderOfEventCalls ( ) )
62496268 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
62506269
@@ -6318,14 +6337,13 @@ test('The last cell should be focused after changing the page size (T1063530)',
63186337 await resetFocusedEventsTestData ( ) ;
63196338
63206339 // act
6321- await t
6322- . pressKey ( 'ctrl+end' )
6323- . wait ( 100 ) ;
6340+ await t . pressKey ( 'ctrl+end' ) ;
6341+ await waitForKeyboardNavigation ( t ) ;
63246342
63256343 // assert
63266344 await t
63276345 . expect ( dataGrid . getDataCell ( 19 , 14 ) . element . focused )
6328- . ok ( )
6346+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
63296347 . expect ( getOrderOfEventCalls ( ) )
63306348 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
63316349
@@ -6399,14 +6417,13 @@ test('The last cell should be focused after changing the page size (T1063530)',
63996417 await resetFocusedEventsTestData ( ) ;
64006418
64016419 // act
6402- await t
6403- . pressKey ( 'ctrl+end' )
6404- . wait ( 100 ) ;
6420+ await t . pressKey ( 'ctrl+end' ) ;
6421+ await waitForKeyboardNavigation ( t ) ;
64056422
64066423 // assert
64076424 await t
64086425 . expect ( dataGrid . getDataCell ( 19 , 14 ) . element . focused )
6409- . ok ( )
6426+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
64106427 . expect ( getOrderOfEventCalls ( ) )
64116428 . eql ( [ 'onFocusedCellChanging' , 'onFocusedCellChanged' ] ) ;
64126429
@@ -6484,7 +6501,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
64846501 // assert
64856502 await t
64866503 . expect ( dataGrid . getDataCell ( 19 , 14 ) . element . focused )
6487- . ok ( )
6504+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
64886505 . expect ( getOrderOfEventCalls ( ) )
64896506 . eql ( [ 'onFocusedCellChanging' , 'onFocusedRowChanging' , 'onFocusedRowChanged' , 'onFocusedCellChanged' ] ) ;
64906507
@@ -6572,7 +6589,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
65726589 // assert
65736590 await t
65746591 . expect ( dataGrid . getDataCell ( 19 , 34 ) . element . focused )
6575- . ok ( )
6592+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
65766593 . expect ( getOrderOfEventCalls ( ) )
65776594 . eql ( [ 'onFocusedCellChanging' , 'onFocusedRowChanging' , 'onFocusedRowChanged' , 'onFocusedCellChanged' ] ) ;
65786595
@@ -6662,7 +6679,7 @@ test('The last cell should be focused after changing the page size (T1063530)',
66626679 // assert
66636680 await t
66646681 . expect ( dataGrid . getDataCell ( 199 , 34 ) . element . focused )
6665- . ok ( )
6682+ . ok ( { timeout : KEYBOARD_NAVIGATION_TIMEOUT } )
66666683 . expect ( getOrderOfEventCalls ( ) )
66676684 . eql ( [ 'onFocusedCellChanging' , 'onFocusedRowChanging' , 'onFocusedRowChanged' , 'onFocusedCellChanged' ] ) ;
66686685
0 commit comments