Skip to content

Commit 4b0c2e3

Browse files
committed
test(filtering): Fix two tests for grid filtering #4967
1 parent 368018c commit 4b0c2e3

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,19 +1594,41 @@ describe('IgxGrid - Filtering actions', () => {
15941594
expect(filterChip).toBeTruthy();
15951595
expect(filterChip.componentInstance.selected).toBeTruthy();
15961596

1597-
filterChip.nativeElement.dispatchEvent(new MouseEvent('click'));
1598-
fix.detectChanges();
1597+
// Click on the chip to commit it
1598+
const elementRect = filterChip.nativeElement.getBoundingClientRect();
1599+
UIInteractions.simulatePointerEvent('pointerdown', filterChip.nativeElement, elementRect.left, elementRect.top);
1600+
await wait(16);
1601+
input.nativeElement.blur();
1602+
await wait(16);
1603+
input.nativeElement.dispatchEvent(new FocusEvent('focusout', {bubbles: true}));
15991604
await wait(16);
1605+
(filterChip as DebugElement).nativeElement.focus();
1606+
UIInteractions.simulatePointerEvent('pointerup', filterChip.nativeElement, elementRect.left, elementRect.top);
1607+
UIInteractions.simulateMouseEvent('click', filterChip.nativeElement, 10 , 10);
1608+
1609+
await wait(16);
1610+
fix.detectChanges();
16001611
expect(filterChip.componentInstance.selected).toBeFalsy();
16011612

1602-
filterChip.nativeElement.dispatchEvent(new MouseEvent('click'));
1613+
// Click on the chip to select it
1614+
GridFunctions.clickChip(filterChip);
16031615
fix.detectChanges();
16041616
await wait(16);
16051617
expect(filterChip.componentInstance.selected).toBeTruthy();
16061618

1607-
filterChip.nativeElement.dispatchEvent(new MouseEvent('click'));
1608-
fix.detectChanges();
1619+
// Click on the chip to commit it
1620+
UIInteractions.simulatePointerEvent('pointerdown', filterChip.nativeElement, elementRect.left, elementRect.top);
1621+
await wait(16);
1622+
input.nativeElement.blur();
1623+
await wait(16);
1624+
input.nativeElement.dispatchEvent(new FocusEvent('focusout', {bubbles: true}));
16091625
await wait(16);
1626+
(filterChip as DebugElement).nativeElement.focus();
1627+
UIInteractions.simulatePointerEvent('pointerup', filterChip.nativeElement, elementRect.left, elementRect.top);
1628+
UIInteractions.simulateMouseEvent('click', filterChip.nativeElement, 10 , 10);
1629+
1630+
await wait(16);
1631+
fix.detectChanges();
16101632
expect(filterChip.componentInstance.selected).toBeFalsy();
16111633
});
16121634

@@ -1624,34 +1646,45 @@ describe('IgxGrid - Filtering actions', () => {
16241646
expect(filterChip).toBeTruthy();
16251647
expect(filterChip.componentInstance.selected).toBeTruthy();
16261648

1627-
filterChip.nativeElement.dispatchEvent(new MouseEvent('click'));
1649+
// Click on the chip to commit it
1650+
const elementRect = filterChip.nativeElement.getBoundingClientRect();
1651+
UIInteractions.simulatePointerEvent('pointerdown', filterChip.nativeElement, elementRect.left, elementRect.top);
1652+
await wait(16);
1653+
input.nativeElement.blur();
1654+
await wait(16);
1655+
input.nativeElement.dispatchEvent(new FocusEvent('focusout', {bubbles: true}));
1656+
await wait(16);
1657+
(filterChip as DebugElement).nativeElement.focus();
1658+
UIInteractions.simulatePointerEvent('pointerup', filterChip.nativeElement, elementRect.left, elementRect.top);
1659+
UIInteractions.simulateMouseEvent('click', filterChip.nativeElement, 10 , 10);
1660+
16281661
fix.detectChanges();
1629-
await wait(16);
1662+
await wait(100);
16301663
expect(filterChip.componentInstance.selected).toBeFalsy();
16311664

16321665
filterValue = 'c';
16331666
sendInput(input, filterValue, fix);
16341667
fix.detectChanges();
1635-
await wait(16);
1668+
await wait(100);
16361669

16371670
let filterChips = filterUIRow.queryAll(By.directive(IgxChipComponent));
16381671
expect(filterChips[1]).toBeTruthy();
16391672
expect(filterChips[1].componentInstance.selected).toBeTruthy();
16401673

16411674
GridFunctions.simulateKeyboardEvent(input, 'keydown', 'Enter');
16421675
fix.detectChanges();
1643-
await wait(16);
1676+
await wait(100);
16441677
expect(filterChips[1].componentInstance.selected).toBeFalsy();
16451678

16461679
let selectedColumn = GridFunctions.getColumnHeader('Downloads', fix);
16471680
selectedColumn.nativeElement.dispatchEvent(new MouseEvent('click'));
16481681
fix.detectChanges();
1649-
await wait(16);
1682+
await wait(100);
16501683

16511684
selectedColumn = GridFunctions.getColumnHeader('ProductName', fix);
16521685
selectedColumn.nativeElement.dispatchEvent(new MouseEvent('click'));
16531686
fix.detectChanges();
1654-
await wait(16);
1687+
await wait(100);
16551688

16561689
filterChips = filterUIRow.queryAll(By.directive(IgxChipComponent));
16571690
expect(filterChips[0].componentInstance.selected).toBeFalsy();

0 commit comments

Comments
 (0)