@@ -1076,6 +1076,50 @@ for _ in range(50):
1076
1076
}
1077
1077
} ) ;
1078
1078
1079
+ test ( 'Navigating cells using up/down keys while focus is set to editor' , async ( ) => {
1080
+ wrapper . update ( ) ;
1081
+
1082
+ const firstCell = 0 ;
1083
+ const secondCell = 1 ;
1084
+
1085
+ // Set focus to the first cell.
1086
+ let update = waitForUpdate ( wrapper , NativeEditor , 1 ) ;
1087
+ clickCell ( firstCell ) ;
1088
+ await update ;
1089
+ update = waitForMessage ( ioc , InteractiveWindowMessages . FocusedCellEditor ) ;
1090
+ simulateKeyPressOnCell ( firstCell , { code : 'Enter' } ) ;
1091
+ await update ;
1092
+ assert . ok ( isCellFocused ( wrapper , 'NativeCell' , firstCell ) ) ;
1093
+
1094
+ // Now press the down arrow, and focus should go to the next cell.
1095
+ update = waitForMessage ( ioc , InteractiveWindowMessages . FocusedCellEditor ) ;
1096
+ let monacoEditor = getNativeFocusedEditor ( wrapper ) ! . instance ( ) as MonacoEditor ;
1097
+ monacoEditor . getCurrentVisibleLine = ( ) => 0 ;
1098
+ monacoEditor . getVisibleLineCount = ( ) => 1 ;
1099
+ simulateKeyPressOnCell ( firstCell , { code : 'ArrowDown' } ) ;
1100
+ await update ;
1101
+
1102
+ // The next cell must be focused, but not selected.
1103
+ assert . isFalse ( isCellFocused ( wrapper , 'NativeCell' , firstCell ) , 'First new cell must not be focused' ) ;
1104
+ assert . isTrue ( isCellFocused ( wrapper , 'NativeCell' , secondCell ) , 'Second new cell must be focused' ) ;
1105
+ assert . isFalse ( isCellSelected ( wrapper , 'NativeCell' , firstCell ) , 'First new cell must not be selected' ) ;
1106
+ assert . isFalse ( isCellSelected ( wrapper , 'NativeCell' , secondCell ) , 'Second new cell must not be selected' ) ;
1107
+
1108
+ // Now press the up arrow, and focus should go back to the first cell.
1109
+ update = waitForMessage ( ioc , InteractiveWindowMessages . FocusedCellEditor ) ;
1110
+ monacoEditor = getNativeFocusedEditor ( wrapper ) ! . instance ( ) as MonacoEditor ;
1111
+ monacoEditor . getCurrentVisibleLine = ( ) => 0 ;
1112
+ monacoEditor . getVisibleLineCount = ( ) => 1 ;
1113
+ simulateKeyPressOnCell ( firstCell , { code : 'ArrowUp' } ) ;
1114
+ await update ;
1115
+
1116
+ // The first cell must be focused, but not selected.
1117
+ assert . isTrue ( isCellFocused ( wrapper , 'NativeCell' , firstCell ) , 'First new cell must not be focused' ) ;
1118
+ assert . isFalse ( isCellFocused ( wrapper , 'NativeCell' , secondCell ) , 'Second new cell must be focused' ) ;
1119
+ assert . isFalse ( isCellSelected ( wrapper , 'NativeCell' , firstCell ) , 'First new cell must not be selected' ) ;
1120
+ assert . isFalse ( isCellSelected ( wrapper , 'NativeCell' , secondCell ) , 'Second new cell must not be selected' ) ;
1121
+ } ) ;
1122
+
1079
1123
test ( "Pressing 'd' on a selected cell twice deletes the cell" , async ( ) => {
1080
1124
// Initially 3 cells.
1081
1125
wrapper . update ( ) ;
0 commit comments