Skip to content

Commit 5e71eef

Browse files
committed
chore(*): fix unit test + tabindex for clear icon #6594
1 parent ce96517 commit 5e71eef

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering-row.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
[value]="value | igxdate: filteringService.grid.locale"
6868
[readonly]="true"
6969
(keydown)="onInputKeyDown($event)"/>
70-
<igx-suffix *ngIf="value" >
70+
<igx-suffix *ngIf="value">
7171
<igx-icon (keydown)="onCommitKeyDown($event)" (click)="onCommitClick()" tabindex="0">done</igx-icon>
72-
<igx-icon (keydown)="onClearKeyDown($event)" (click)="clearInput()" tabindex="1">clear</igx-icon>
72+
<igx-icon (keydown)="onClearKeyDown($event)" (click)="clearInput()" tabindex="0">clear</igx-icon>
7373
</igx-suffix>
7474
</igx-input-group>
7575
</ng-template>

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,24 +3462,24 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34623462
// Click the today date.
34633463
const outlet = document.getElementsByClassName('igx-grid__outlet')[0];
34643464
let calendar = outlet.getElementsByClassName('igx-calendar')[0];
3465-
const todayDayItem = calendar.querySelector('.igx-calendar__date--current');
3465+
const todayDayItem: HTMLElement = calendar.querySelector('.igx-calendar__date--current');
34663466
clickHtmlElemAndBlur(todayDayItem, inputDebugElement);
34673467
tick(100);
34683468
fix.detectChanges();
34693469

3470-
// Select our newly added chip
3470+
// Verify the newly added chip is selected.
34713471
const chip = GridFunctions.getFilterConditionChip(fix, 0);
34723472
const chipDiv = chip.querySelector('.igx-chip__item');
34733473

3474-
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeTruthy('initial chip is committed');
3474+
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(true, 'initial chip is committed');
34753475

34763476
// Focus out
34773477
clickHtmlElemAndBlur(chip, inputDebugElement);
34783478
tick(200);
34793479
fix.detectChanges();
34803480

3481-
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeFalsy('initial chip is not committed');
3482-
expect(input.value).toBeFalsy('initial input value is present and not committed');
3481+
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(false, 'initial chip is not committed');
3482+
expect(input.value).toBe('', 'initial input value is present and not committed');
34833483

34843484
chip.click();
34853485
tick(200);
@@ -3510,7 +3510,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
35103510
tick(100);
35113511
fix.detectChanges();
35123512

3513-
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeTruthy('chip is committed');
3513+
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(true, 'chip is committed');
35143514

35153515
// Focus out
35163516
clickHtmlElemAndBlur(chip, inputDebugElement);
@@ -3519,12 +3519,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
35193519
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(false, 'chip is selected');
35203520

35213521
// Check if we still have only one committed chip
3522-
const activeFilterChip: IgxChipComponent = filteringRow.query(By.directive(IgxChipComponent)).componentInstance;
35233522
const chipsLength = GridFunctions.getAllFilterConditionChips(fix).length;
35243523

35253524
expect(chipsLength).toBe(1, 'there is more than one chip');
3526-
expect(activeFilterChip.selected).toBe(false, 'chip is not committed');
3527-
expect(input.value).toBeFalsy('input value is present and not committed');
3525+
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(false, 'chip is not committed');
3526+
expect(input.value).toBe('', 'input value is present and not committed');
35283527
}));
35293528
});
35303529
describe(null, () => {
@@ -6543,17 +6542,13 @@ function verifyChipVisibility(fix, index: number, shouldBeFullyVisible: boolean)
65436542
.toBe(shouldBeFullyVisible, 'chip[' + index + '] visibility is incorrect');
65446543
}
65456544

6546-
function clickElemAndBlur(clickElem, blurElem) {
6547-
const elementRect = clickElem.nativeElement.getBoundingClientRect();
6548-
UIInteractions.simulatePointerEvent('pointerdown', clickElem.nativeElement, elementRect.left, elementRect.top);
6549-
blurElem.nativeElement.blur();
6550-
(clickElem as DebugElement).nativeElement.focus();
6551-
blurElem.nativeElement.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));
6552-
UIInteractions.simulatePointerEvent('pointerup', clickElem.nativeElement, elementRect.left, elementRect.top);
6553-
UIInteractions.simulateMouseEvent('click', clickElem.nativeElement, 10, 10);
6545+
function clickElemAndBlur(clickElem: DebugElement, blurElem: DebugElement) {
6546+
const clickHtmlElem = clickElem.nativeElement;
6547+
6548+
this.clickHtmlElemAndBlur(clickHtmlElem, blurElem);
65546549
}
65556550

6556-
function clickHtmlElemAndBlur(clickElem, blurElem) {
6551+
function clickHtmlElemAndBlur(clickElem: HTMLElement, blurElem: DebugElement) {
65576552
const elementRect = clickElem.getBoundingClientRect();
65586553
UIInteractions.simulatePointerEvent('pointerdown', clickElem, elementRect.left, elementRect.top);
65596554
blurElem.nativeElement.blur();

projects/igniteui-angular/src/lib/test-utils/grid-functions.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,8 @@ export class GridFunctions {
912912
}
913913

914914
public static getFilterConditionChip(fix, index) {
915-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
916-
const conditionChips = GridFunctions.sortNativeElementsHorizontally(
917-
filterUIRow.queryAll(By.directive(IgxChipComponent)).map((ch) => ch.nativeElement));
915+
const conditionChips = this.getAllFilterConditionChips(fix);
916+
918917
return conditionChips[index];
919918
}
920919

0 commit comments

Comments
 (0)