@@ -2471,88 +2471,24 @@ describe('IgxQueryBuilder', () => {
24712471 expect ( chipComponents [ 1 ] . nativeElement . getBoundingClientRect ( ) . height ) . toBe ( 0 ) ;
24722472 } ) ;
24732473
2474- it ( 'Should render drop ghost properly when mouse dragged.' , fakeAsync ( ( ) => {
2474+ it ( 'Should render drop ghost properly when mouse dragged down on the left .' , fakeAsync ( ( ) => {
24752475 const draggedChip = chipComponents [ 1 ] . componentInstance ;
2476- const draggedChipCenter = QueryBuilderFunctions . getElementCenter ( draggedChip . chipArea . nativeElement ) ;
2477- const dragDir = draggedChip . dragDirective ;
2478-
2479- let X = 100 , Y = 75 ;
2480-
2481- //pickup chip
2482- dragDir . onPointerDown ( { pointerId : 1 , pageX : draggedChipCenter . X , pageY : draggedChipCenter . Y } ) ;
2483- fix . detectChanges ( ) ;
2484-
2485- //trigger ghost
2486- QueryBuilderFunctions . dragMove ( dragDir , draggedChipCenter . X + 10 , draggedChipCenter . Y + 10 ) ;
2487- fix . detectChanges ( ) ;
2488-
2489- spyOn ( dragDir . ghostElement , 'dispatchEvent' ) . and . callThrough ( ) ;
2490-
2491- const ghostPositionVisits : boolean [ ] = [ false , false , false , false , false , false , false , false ]
2492-
2493- let i = 0 , pass = 1 , inc = 1 ;
2494-
2495- //Drag ghost up and down four times and check if drop ghost is rendered in the expected positions
2496- while ( pass <= 4 ) {
2497- i += inc ;
2498- Y += inc ;
2499-
2500- QueryBuilderFunctions . dragMove ( dragDir , X , Y ) ;
2501- tick ( ) ;
2502- fix . detectChanges ( ) ;
2503-
2504- const [ dropGhost , prevElement , nextElement ] = QueryBuilderFunctions . getDropGhostAndItsSiblings ( fix ) ;
2505-
2506- if ( i < 40 && ! ghostPositionVisits [ 0 ] ) {
2507- if ( i <= 42 ) tick ( 50 ) ;
2508- if ( ! dropGhost ) ghostPositionVisits [ 0 ] = true ;
2509- }
2510-
2511- if ( i > 35 && i < 122 && ! ghostPositionVisits [ 1 ] ) {
2512- if ( dropGhost && ! prevElement && nextElement == 'OrderName Equals foo' ) ghostPositionVisits [ 1 ] = true ;
2513- }
2514-
2515- if ( i > 120 && i < 165 && ! ghostPositionVisits [ 2 ] ) {
2516- if ( dropGhost && prevElement == 'OrderName Equals foo' && nextElement === 'or OrderName Ends With a OrderDate Today' ) ghostPositionVisits [ 2 ] = true ;
2517- }
2518-
2519- if ( i > 166 && i < 201 && ! ghostPositionVisits [ 3 ] ) {
2520- if ( dropGhost && ! prevElement && nextElement == 'OrderName Ends With a' ) ghostPositionVisits [ 3 ] = true ;
2521- }
2522-
2523- if ( i > 202 && i < 241 && ! ghostPositionVisits [ 4 ] ) {
2524- if ( dropGhost && prevElement == 'OrderName Ends With a' && nextElement === 'OrderDate Today' ) ghostPositionVisits [ 4 ] = true ;
2525- }
2526-
2527- if ( i > 240 && i < 273 && ! ghostPositionVisits [ 5 ] ) {
2528- if ( dropGhost && prevElement == 'OrderDate Today' && ! nextElement ) ghostPositionVisits [ 5 ] = true ;
2529- }
2530-
2531- if ( i > 256 && i < 316 && ! ghostPositionVisits [ 6 ] ) {
2532- if ( pass > 2 || ( dropGhost && prevElement == 'or OrderName Ends With a OrderDate Today' && ! nextElement ) ) ghostPositionVisits [ 6 ] = true ;
2533- }
2534-
2535- if ( i > 320 && ! ghostPositionVisits [ 7 ] ) {
2536- if ( i >= 340 ) tick ( 50 ) ;
2537- if ( ! dropGhost ) ghostPositionVisits [ 7 ] = true ;
2538- }
2539-
2540- //When dragged to the end, check results and reverse direction for next pass
2541- if ( i === 350 || i === 0 ) {
2542- expect ( ghostPositionVisits ) . not . toContain ( false ,
2543- `Ghost was not rendered on position(s) ${ ghostPositionVisits . reduce ( ( arr , e , ix ) => ( ( e == false ) && arr . push ( ix ) , arr ) , [ ] ) . toString ( ) } on pass:${ pass } ` ) ;
2476+ QueryBuilderFunctions . verifyGhostPositionOnMouseDrag ( fix , draggedChip , 100 , 75 , true ) ;
2477+ } ) ) ;
25442478
2545- ghostPositionVisits . fill ( false ) ;
2546- pass ++ ;
2547- inc *= - 1 ;
2548- if ( pass % 2 === 0 ) Y -= ROW_HEIGHT ;
2549- if ( pass % 2 !== 0 ) Y += ROW_HEIGHT ;
2479+ it ( 'Should render drop ghost properly when mouse dragged up on the left.' , fakeAsync ( ( ) => {
2480+ const draggedChip = chipComponents [ 1 ] . componentInstance ;
2481+ QueryBuilderFunctions . verifyGhostPositionOnMouseDrag ( fix , draggedChip , 100 , 75 + 350 , false ) ;
2482+ } ) ) ;
25502483
2551- //go to the left and test the whole chip div as well(blank space to the right)
2552- if ( pass == 3 ) X += 400 ;
2553- }
2554- }
2484+ it ( 'Should render drop ghost properly when mouse dragged down on the right.' , fakeAsync ( ( ) => {
2485+ const draggedChip = chipComponents [ 1 ] . componentInstance ;
2486+ QueryBuilderFunctions . verifyGhostPositionOnMouseDrag ( fix , draggedChip , 500 , 75 , true ) ;
2487+ } ) ) ;
25552488
2489+ it ( 'Should render drop ghost properly when mouse dragged up on the right.' , fakeAsync ( ( ) => {
2490+ const draggedChip = chipComponents [ 1 ] . componentInstance ;
2491+ QueryBuilderFunctions . verifyGhostPositionOnMouseDrag ( fix , draggedChip , 500 , 75 + 350 , false ) ;
25562492 } ) ) ;
25572493
25582494 it ( 'Should position drop ghost below the target condition on dragging down.' , ( ) => {
0 commit comments