@@ -3140,6 +3140,139 @@ fdescribe('IgxQueryBuilder', () => {
31403140 }
31413141 }
31423142 } ) ) ;
3143+
3144+ it ( 'Should commit drop upon hitting \'Enter\' when keyboard dragged.' , fakeAsync ( ( ) => {
3145+ const draggedIndicator = fix . debugElement . queryAll ( By . css ( '.igx-drag-indicator' ) ) [ 4 ] ;
3146+ const tree = fix . debugElement . query ( By . css ( '.igx-filter-tree' ) ) ;
3147+
3148+ draggedIndicator . triggerEventHandler ( 'focus' , { } ) ;
3149+ draggedIndicator . nativeElement . focus ( ) ;
3150+
3151+ spyOn ( tree . nativeElement , 'dispatchEvent' ) . and . callThrough ( ) ;
3152+ const dropGhostContent = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) [ 1 ] ;
3153+
3154+ tree . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
3155+ tick ( 20 ) ;
3156+ fix . detectChanges ( ) ;
3157+
3158+ tree . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
3159+ tick ( 20 ) ;
3160+ fix . detectChanges ( ) ;
3161+
3162+ //Verify that expressionTree is correct
3163+ const exprTree = JSON . stringify ( fix . componentInstance . queryBuilder . expressionTree , null , 2 ) ;
3164+ expect ( exprTree ) . toBe ( `{
3165+ "filteringOperands": [
3166+ {
3167+ "fieldName": "OrderName",
3168+ "condition": {
3169+ "name": "equals",
3170+ "isUnary": false,
3171+ "iconName": "filter_equal"
3172+ },
3173+ "conditionName": "equals",
3174+ "searchVal": "foo"
3175+ },
3176+ {
3177+ "fieldName": "OrderId",
3178+ "condition": {
3179+ "name": "inQuery",
3180+ "isUnary": false,
3181+ "isNestedQuery": true,
3182+ "iconName": "in"
3183+ },
3184+ "conditionName": "inQuery",
3185+ "searchTree": {
3186+ "filteringOperands": [
3187+ {
3188+ "fieldName": "Id",
3189+ "condition": {
3190+ "name": "equals",
3191+ "isUnary": false,
3192+ "iconName": "filter_equal"
3193+ },
3194+ "conditionName": "equals",
3195+ "searchVal": 123
3196+ },
3197+ {
3198+ "fieldName": "ProductName",
3199+ "condition": {
3200+ "name": "equals",
3201+ "isUnary": false,
3202+ "iconName": "filter_equal"
3203+ },
3204+ "conditionName": "equals",
3205+ "searchVal": "abc"
3206+ }
3207+ ],
3208+ "operator": 0,
3209+ "entity": "Products",
3210+ "returnFields": [
3211+ "OrderId"
3212+ ]
3213+ }
3214+ },
3215+ {
3216+ "filteringOperands": [
3217+ {
3218+ "fieldName": "OrderName",
3219+ "condition": {
3220+ "name": "endsWith",
3221+ "isUnary": false,
3222+ "iconName": "filter_ends_with"
3223+ },
3224+ "conditionName": "endsWith",
3225+ "searchVal": "a"
3226+ },
3227+ {
3228+ "fieldName": "OrderDate",
3229+ "condition": {
3230+ "name": "today",
3231+ "isUnary": true,
3232+ "iconName": "filter_today"
3233+ },
3234+ "conditionName": "today"
3235+ }
3236+ ],
3237+ "operator": 1,
3238+ "entity": "Orders",
3239+ "returnFields": [
3240+ "*"
3241+ ]
3242+ }
3243+ ],
3244+ "operator": 0,
3245+ "entity": "Orders",
3246+ "returnFields": [
3247+ "*"
3248+ ],
3249+ "fieldName": null
3250+ }` ) ;
3251+ } ) ) ;
3252+
3253+ fit ( 'Should cancel drop upon hitting \'Escape\' when keyboard dragged.' , fakeAsync ( ( ) => {
3254+ const draggedIndicator = fix . debugElement . queryAll ( By . css ( '.igx-drag-indicator' ) ) [ 4 ] ;
3255+ const tree = fix . debugElement . query ( By . css ( '.igx-filter-tree' ) ) ;
3256+
3257+ draggedIndicator . triggerEventHandler ( 'focus' , { } ) ;
3258+ draggedIndicator . nativeElement . focus ( ) ;
3259+
3260+ spyOn ( tree . nativeElement , 'dispatchEvent' ) . and . callThrough ( ) ;
3261+ const dropGhostContent = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) [ 1 ] ;
3262+
3263+ tree . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
3264+ tick ( 20 ) ;
3265+ fix . detectChanges ( ) ;
3266+
3267+ tree . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'Escape' } ) ) ;
3268+ tick ( 20 ) ;
3269+ fix . detectChanges ( ) ;
3270+
3271+ chipComponents = QueryBuilderFunctions . getVisibleChips ( fix ) ;
3272+ expect ( QueryBuilderFunctions . getChipContent ( chipComponents [ 2 ] . nativeElement ) ) . toBe ( "OrderName Ends With a" ) ;
3273+ expect ( QueryBuilderFunctions . getChipContent ( chipComponents [ 3 ] . nativeElement ) ) . toBe ( "OrderDate Today" ) ;
3274+ } ) ) ;
3275+
31433276 } ) ;
31443277} ) ;
31453278
0 commit comments