Skip to content

Commit b641658

Browse files
committed
fix(query-builder): test mouse drag test
1 parent 7d5f618 commit b641658

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

projects/igniteui-angular/src/lib/query-builder/query-builder.component.spec.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@ describe('IgxQueryBuilder', () => {
24662466
const draggedChipCenter = QueryBuilderFunctions.getElementCenter(draggedChip.chipArea.nativeElement);
24672467
const dragDir = draggedChip.dragDirective;
24682468

2469-
let X = 100, Y = 95;
2469+
let X = 100, Y = 75;
24702470

24712471
//pickup chip
24722472
dragDir.onPointerDown({ pointerId: 1, pageX: draggedChipCenter.X, pageY: draggedChipCenter.Y });
@@ -2485,52 +2485,50 @@ describe('IgxQueryBuilder', () => {
24852485
//Drag ghost up and down four times and check if drop ghost is rendered in the expected positions
24862486
while (pass <= 4) {
24872487
i += inc;
2488-
Y += 5 * inc;
2488+
Y += inc;
24892489

24902490
QueryBuilderFunctions.dragMove(dragDir, X, Y);
2491-
tick(10);
2491+
tick();
24922492
fix.detectChanges();
24932493

2494-
const dropGhost = QueryBuilderFunctions.getDropGhost(fix);
2495-
const prevElement = dropGhost && dropGhost.previousElementSibling ? QueryBuilderFunctions.getChipContent(dropGhost.previousElementSibling) : null;
2496-
const nextElement = dropGhost && dropGhost.nextElementSibling ? QueryBuilderFunctions.getChipContent(dropGhost.nextElementSibling) : null;
2494+
const [dropGhost, prevElement, nextElement] = QueryBuilderFunctions.getDropGhostAndItsSiblings(fix);
24972495

2498-
if (i < 8 && !ghostPositionVisits[0]) {
2499-
tick(50);
2496+
if (i < 40 && !ghostPositionVisits[0]) {
2497+
if (i <= 42) tick(50);
25002498
if (!dropGhost) ghostPositionVisits[0] = true;
25012499
}
25022500

2503-
if (i > 6 && i < 23 && !ghostPositionVisits[1]) {
2504-
if (dropGhost && !prevElement && nextElement == "OrderName Equals foo") ghostPositionVisits[1] = true;
2501+
if (i > 35 && i < 122 && !ghostPositionVisits[1]) {
2502+
if (dropGhost && !prevElement && nextElement == 'OrderName Equals foo') ghostPositionVisits[1] = true;
25052503
}
25062504

2507-
if (i > 20 && i < 35 && !ghostPositionVisits[2]) {
2508-
if (dropGhost && prevElement == "OrderName Equals foo" && !nextElement) ghostPositionVisits[2] = true;
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;
25092507
}
25102508

2511-
if (i > 31 && i < 40 && !ghostPositionVisits[3]) {
2512-
if (dropGhost && !prevElement && nextElement == "OrderName Ends With a") ghostPositionVisits[3] = true;
2509+
if (i > 166 && i < 201 && !ghostPositionVisits[3]) {
2510+
if (dropGhost && !prevElement && nextElement == 'OrderName Ends With a') ghostPositionVisits[3] = true;
25132511
}
25142512

2515-
if (i > 36 && i < 47 && !ghostPositionVisits[4]) {
2516-
if (dropGhost && prevElement == "OrderName Ends With a" && !nextElement) ghostPositionVisits[4] = true;
2513+
if (i > 202 && i < 241 && !ghostPositionVisits[4]) {
2514+
if (dropGhost && prevElement == 'OrderName Ends With a' && nextElement === 'OrderDate Today') ghostPositionVisits[4] = true;
25172515
}
25182516

2519-
if (i > 44 && i < 57 && !ghostPositionVisits[5]) {
2520-
if (dropGhost && prevElement == "OrderDate Today" && !nextElement) ghostPositionVisits[5] = true;
2517+
if (i > 240 && i < 273 && !ghostPositionVisits[5]) {
2518+
if (dropGhost && prevElement == 'OrderDate Today' && !nextElement) ghostPositionVisits[5] = true;
25212519
}
25222520

2523-
if (i > 54 && i < 64 && !ghostPositionVisits[6]) {
2524-
if (pass > 2 || (dropGhost && prevElement == "or OrderName Ends With a OrderDate Today" && !nextElement)) ghostPositionVisits[6] = true;
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;
25252523
}
25262524

2527-
if (i > 62 && !ghostPositionVisits[7]) {
2528-
tick(50);
2525+
if (i > 300 && !ghostPositionVisits[7]) {
2526+
if (i >= 318) tick(50);
25292527
if (!dropGhost) ghostPositionVisits[7] = true;
25302528
}
25312529

25322530
//When dragged to the end, check results and reverse direction for next pass
2533-
if (i === 65 || i === 0) {
2531+
if (i === 320 || i === 0) {
25342532
expect(ghostPositionVisits).not.toContain(false,
25352533
`Ghost was not rendered on position(s) ${ghostPositionVisits.reduce((arr, e, ix) => ((e == false) && arr.push(ix), arr), []).toString()} on pass:${pass}`);
25362534

0 commit comments

Comments
 (0)