@@ -2380,7 +2380,8 @@ describe('IgxQueryBuilder', () => {
2380
2380
igx_query_builder_dialog_message : 'My changing entity message' ,
2381
2381
igx_query_builder_dialog_checkbox_text : 'My do not show this dialog again' ,
2382
2382
igx_query_builder_dialog_cancel : 'My Cancel' ,
2383
- igx_query_builder_dialog_confirm : 'My Confirm'
2383
+ igx_query_builder_dialog_confirm : 'My Confirm' ,
2384
+ igx_query_builder_drop_ghost_text : 'My Drop here to insert'
2384
2385
} ) ;
2385
2386
fix . detectChanges ( ) ;
2386
2387
@@ -2415,6 +2416,18 @@ describe('IgxQueryBuilder', () => {
2415
2416
expect ( dialogOutlet . querySelector ( '.igx-query-builder-dialog' ) . children [ 1 ] . textContent . trim ( ) ) . toBe ( 'My do not show this dialog again' ) ;
2416
2417
expect ( dialogOutlet . querySelector ( '.igx-dialog__window-actions' ) . children [ 0 ] . textContent . trim ( ) ) . toBe ( 'My Cancel' ) ;
2417
2418
expect ( dialogOutlet . querySelector ( '.igx-dialog__window-actions' ) . children [ 1 ] . textContent . trim ( ) ) . toBe ( 'My Confirm' ) ;
2419
+
2420
+ //Drag ghost text check
2421
+ queryBuilder . expressionTree = QueryBuilderFunctions . generateExpressionTree ( ) ;
2422
+ fix . detectChanges ( ) ;
2423
+ tick ( 100 ) ;
2424
+ fix . detectChanges ( ) ;
2425
+ const draggedChip = fix . debugElement . queryAll ( By . directive ( IgxChipComponent ) ) [ 3 ] . componentInstance ;
2426
+ UIInteractions . moveDragDirective ( fix , draggedChip . dragDirective , 10 , 10 , false ) ;
2427
+ const dropGhost = QueryBuilderFunctions . getDropGhost ( fix ) as HTMLElement ;
2428
+ expect ( draggedChip . dragDirective . ghostElement ) . toBeTruthy ( ) ;
2429
+ expect ( dropGhost ) . toBeDefined ( ) ;
2430
+ expect ( dropGhost . innerText ) . toBe ( 'My Drop here to insert' ) ;
2418
2431
} ) ) ;
2419
2432
} ) ;
2420
2433
@@ -2917,64 +2930,144 @@ describe('IgxQueryBuilder', () => {
2917
2930
expect ( QueryBuilderFunctions . getChipContent ( newGroupConditions [ 0 ] ) ) . toBe ( "OrderDate Today" ) ;
2918
2931
} ) ;
2919
2932
2920
- it ( 'should render drop ghost properly when keyboard dragged.' , async ( ) => {
2933
+ it ( 'should render drop ghost properly when keyboard dragged.' , ( ) => {
2921
2934
const draggedIndicator = fix . debugElement . queryAll ( By . css ( '.igx-drag-indicator' ) ) [ 1 ] ;
2922
2935
const tree = fix . debugElement . query ( By . css ( '.igx-filter-tree' ) ) ;
2923
- let keyPress = new KeyboardEvent ( 'keydown' , { code : 'ArrowDown' } ) ;
2924
2936
2925
2937
draggedIndicator . triggerEventHandler ( 'focus' , { } ) ;
2926
2938
draggedIndicator . nativeElement . focus ( ) ;
2927
2939
2928
2940
spyOn ( tree . nativeElement , 'dispatchEvent' ) . and . callThrough ( ) ;
2929
2941
const dropGhostContent = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) [ 1 ] ;
2930
2942
2943
+ //pass 1 down to bottom
2944
+ let keyPress = new KeyboardEvent ( 'keydown' , { code : 'ArrowDown' } ) ;
2931
2945
for ( let i = 0 ; i <= 5 ; i ++ ) {
2932
2946
tree . nativeElement . dispatchEvent ( keyPress ) ;
2933
- await wait ( ) ;
2947
+ wait ( ) ;
2934
2948
fix . detectChanges ( ) ;
2935
2949
2950
+ const dropGhost = QueryBuilderFunctions . getDropGhost ( fix ) ;
2951
+ const prevElement = dropGhost && dropGhost . previousElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . previousElementSibling ) : null ;
2952
+ const nextElement = dropGhost && dropGhost . nextElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . nextElementSibling ) : null ;
2936
2953
const newChipContents = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) ;
2937
2954
2938
2955
switch ( true ) {
2939
2956
case i === 0 :
2957
+ expect ( dropGhost ) . toBeDefined ( ) ;
2958
+ expect ( prevElement ) . toBeNull ( ) ;
2959
+ expect ( nextElement ) . toEqual ( "OrderName Ends With a" ) ;
2940
2960
expect ( newChipContents [ 4 ] ) . toBe ( dropGhostContent ) ;
2941
2961
break ;
2942
2962
case i === 1 :
2963
+ expect ( dropGhost ) . toBeDefined ( ) ;
2964
+ expect ( prevElement ) . toEqual ( "OrderName Ends With a" ) ;
2965
+ expect ( nextElement ) . toBeUndefined ( ) ;
2943
2966
expect ( newChipContents [ 5 ] ) . toBe ( dropGhostContent ) ;
2944
2967
break ;
2945
- case i >= 2 :
2968
+ case i === 2 :
2969
+ expect ( dropGhost ) . toBeDefined ( ) ;
2970
+ expect ( prevElement ) . toEqual ( "OrderDate Today" ) ;
2971
+ expect ( nextElement ) . toBeUndefined ( ) ;
2972
+ expect ( newChipContents [ 6 ] ) . toBe ( dropGhostContent ) ;
2973
+ break ;
2974
+ case i >= 3 :
2975
+ expect ( dropGhost ) . toBeDefined ( ) ;
2976
+ expect ( prevElement ) . toEqual ( "or OrderName Ends With a OrderDate Today" ) ;
2977
+ expect ( nextElement ) . toBeNull ( ) ;
2946
2978
expect ( newChipContents [ 6 ] ) . toBe ( dropGhostContent ) ;
2947
2979
break ;
2948
2980
}
2949
2981
}
2950
2982
2983
+ //pass 2 up to top
2951
2984
keyPress = new KeyboardEvent ( 'keydown' , { code : 'ArrowUp' } ) ;
2952
-
2953
2985
for ( let i = 0 ; i <= 10 ; i ++ ) {
2954
2986
tree . nativeElement . dispatchEvent ( keyPress ) ;
2955
- await wait ( ) ;
2987
+ wait ( ) ;
2956
2988
fix . detectChanges ( ) ;
2957
2989
2990
+ const dropGhost = QueryBuilderFunctions . getDropGhost ( fix ) ;
2991
+ const prevElement = dropGhost && dropGhost . previousElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . previousElementSibling ) : null ;
2992
+ const nextElement = dropGhost && dropGhost . nextElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . nextElementSibling ) : null ;
2958
2993
const newChipContents = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) ;
2959
2994
2960
2995
switch ( true ) {
2961
2996
case i === 0 :
2997
+ expect ( dropGhost ) . toBeDefined ( ) ;
2998
+ expect ( prevElement ) . toEqual ( "OrderDate Today" ) ;
2999
+ expect ( nextElement ) . toBeUndefined ( ) ;
2962
3000
expect ( newChipContents [ 6 ] ) . toBe ( dropGhostContent ) ;
2963
3001
break ;
2964
3002
case i === 1 :
3003
+ expect ( dropGhost ) . toBeDefined ( ) ;
3004
+ expect ( prevElement ) . toBeUndefined ( ) ;
3005
+ expect ( nextElement ) . toEqual ( "OrderDate Today" ) ;
2965
3006
expect ( newChipContents [ 5 ] ) . toBe ( dropGhostContent ) ;
2966
3007
break ;
2967
3008
case i === 2 :
3009
+ expect ( dropGhost ) . toBeDefined ( ) ;
3010
+ expect ( prevElement ) . toBeNull ( ) ;
3011
+ expect ( nextElement ) . toEqual ( "OrderName Ends With a" ) ;
2968
3012
expect ( newChipContents [ 4 ] ) . toBe ( dropGhostContent ) ;
2969
3013
break ;
2970
3014
case i === 3 :
3015
+ expect ( dropGhost ) . toBeDefined ( ) ;
3016
+ expect ( prevElement ) . toBeUndefined ( ) ;
3017
+ expect ( nextElement ) . toEqual ( "or OrderName Ends With a OrderDate Today" ) ;
2971
3018
expect ( newChipContents [ 4 ] ) . toBe ( dropGhostContent ) ;
2972
3019
break ;
2973
- case i === 4 :
3020
+ case i >= 4 :
3021
+ expect ( dropGhost ) . toBeDefined ( ) ;
3022
+ expect ( prevElement ) . toBeNull ( ) ;
3023
+ expect ( nextElement ) . toEqual ( "OrderName Equals foo" ) ;
2974
3024
expect ( newChipContents [ 0 ] ) . toBe ( dropGhostContent ) ;
2975
3025
break ;
2976
- case i >= 5 :
2977
- expect ( newChipContents [ 0 ] ) . toBe ( dropGhostContent ) ;
3026
+ }
3027
+ }
3028
+
3029
+ //pass 3 down to bottom again
3030
+ keyPress = new KeyboardEvent ( 'keydown' , { code : 'ArrowDown' } ) ;
3031
+ for ( let i = 0 ; i <= 10 ; i ++ ) {
3032
+ tree . nativeElement . dispatchEvent ( keyPress ) ;
3033
+ wait ( ) ;
3034
+ fix . detectChanges ( ) ;
3035
+
3036
+ const dropGhost = QueryBuilderFunctions . getDropGhost ( fix ) ;
3037
+ const prevElement = dropGhost && dropGhost . previousElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . previousElementSibling ) : null ;
3038
+ const nextElement = dropGhost && dropGhost . nextElementSibling ? QueryBuilderFunctions . getChipContent ( dropGhost . nextElementSibling ) : null ;
3039
+ const newChipContents = QueryBuilderFunctions . GetChipsContentAsArray ( fix ) ;
3040
+
3041
+ switch ( true ) {
3042
+ case i === 0 :
3043
+ expect ( dropGhost ) . toBeDefined ( ) ;
3044
+ expect ( prevElement ) . toEqual ( "OrderName Equals foo" ) ;
3045
+ expect ( nextElement ) . toBeUndefined ( ) ;
3046
+ expect ( newChipContents [ 1 ] ) . toBe ( dropGhostContent ) ;
3047
+ break ;
3048
+ case i === 1 :
3049
+ expect ( dropGhost ) . toBeDefined ( ) ;
3050
+ expect ( prevElement ) . toBeNull ( ) ;
3051
+ expect ( nextElement ) . toEqual ( "OrderName Ends With a" ) ;
3052
+ expect ( newChipContents [ 4 ] ) . toBe ( dropGhostContent ) ;
3053
+ break ;
3054
+ case i === 2 :
3055
+ expect ( dropGhost ) . toBeDefined ( ) ;
3056
+ expect ( prevElement ) . toEqual ( "OrderName Ends With a" ) ;
3057
+ expect ( nextElement ) . toBeUndefined ( ) ;
3058
+ expect ( newChipContents [ 5 ] ) . toBe ( dropGhostContent ) ;
3059
+ break ;
3060
+ case i === 3 :
3061
+ expect ( dropGhost ) . toBeDefined ( ) ;
3062
+ expect ( prevElement ) . toEqual ( "OrderDate Today" ) ;
3063
+ expect ( nextElement ) . toBeUndefined ( ) ;
3064
+ expect ( newChipContents [ 6 ] ) . toBe ( dropGhostContent ) ;
3065
+ break ;
3066
+ case i >= 4 :
3067
+ expect ( dropGhost ) . toBeDefined ( ) ;
3068
+ expect ( prevElement ) . toEqual ( "or OrderName Ends With a OrderDate Today" ) ;
3069
+ expect ( nextElement ) . toBeNull ( ) ;
3070
+ expect ( newChipContents [ 6 ] ) . toBe ( dropGhostContent ) ;
2978
3071
break ;
2979
3072
}
2980
3073
}
0 commit comments