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