Skip to content

Commit 839f8f2

Browse files
nrobakovarkaraivanov
authored andcommitted
Refactor filtering row ui tests (#6509)
* chore(*): update filtering tests
1 parent a6a8e06 commit 839f8f2

File tree

9 files changed

+1413
-2558
lines changed

9 files changed

+1413
-2558
lines changed

projects/igniteui-angular/src/lib/chips/chip.spec.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IgxSuffixDirective } from './../directives/suffix/suffix.directive';
1515
import { DisplayDensity } from '../core/displayDensity';
1616
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
1717
import { configureTestSuite } from '../test-utils/configure-suite';
18+
import { ControlsFunction } from '../test-utils/controls-functions.spec';
1819

1920
@Component({
2021
template: `
@@ -129,7 +130,7 @@ describe('IgxChip', () => {
129130

130131
it('should render remove button when enabled after the content inside the chip', () => {
131132
const chipElems = fix.debugElement.queryAll(By.directive(IgxChipComponent));
132-
const chipRemoveButton = HelperTestFunctions.getDeleteButton(fix);
133+
const chipRemoveButton = ControlsFunction.getChipRemoveButton(chipElems[1].nativeElement);
133134

134135
// For this second chip there are 3 elements. The prefix, content span and the remove button icon .
135136
expect(chipElems[1].nativeElement.children[0].children.length).toEqual(4);
@@ -241,10 +242,10 @@ describe('IgxChip', () => {
241242

242243
it('should delete chip when space button is pressed on delete button', () => {
243244
HelperTestFunctions.verifyChipsCount(fix, 4);
244-
245-
const deleteButtonElement = HelperTestFunctions.getDeleteButton(fix);
245+
const chipElems = fix.debugElement.queryAll(By.directive(IgxChipComponent));
246+
const deleteButtonElement = ControlsFunction.getChipRemoveButton(chipElems[1].nativeElement);
246247
// Removes chip with id City, because country chip is unremovable
247-
UIInteractions.triggerKeyDownEvtUponElem(' ', deleteButtonElement.nativeElement, true);
248+
UIInteractions.triggerKeyDownEvtUponElem(' ', deleteButtonElement, true);
248249
fix.detectChanges();
249250

250251
HelperTestFunctions.verifyChipsCount(fix, 3);
@@ -257,9 +258,10 @@ describe('IgxChip', () => {
257258
it('should delete chip when enter button is pressed on delete button', () => {
258259
HelperTestFunctions.verifyChipsCount(fix, 4);
259260

260-
const deleteButtonElement = HelperTestFunctions.getDeleteButton(fix);
261+
const chipElems = fix.debugElement.queryAll(By.directive(IgxChipComponent));
262+
const deleteButtonElement = ControlsFunction.getChipRemoveButton(chipElems[1].nativeElement);
261263
// Removes chip with id City, because country chip is unremovable
262-
UIInteractions.triggerKeyDownEvtUponElem('Enter', deleteButtonElement.nativeElement, true);
264+
UIInteractions.triggerKeyDownEvtUponElem('Enter', deleteButtonElement, true);
263265
fix.detectChanges();
264266

265267
HelperTestFunctions.verifyChipsCount(fix, 3);
@@ -360,7 +362,8 @@ describe('IgxChip', () => {
360362
spyOn(secondChipComp.onSelection, 'emit');
361363
spyOn(secondChipComp.onSelectionDone, 'emit');
362364

363-
const chipRemoveButton = HelperTestFunctions.getDeleteButton(fix).nativeElement;
365+
const chipRemoveButton = ControlsFunction.getChipRemoveButton(secondChipComp.chipArea.nativeElement);
366+
364367
const removeBtnTop = chipRemoveButton.getBoundingClientRect().top;
365368
const removeBtnLeft = chipRemoveButton.getBoundingClientRect().left;
366369

@@ -400,12 +403,6 @@ describe('IgxChip', () => {
400403
});
401404

402405
class HelperTestFunctions {
403-
public static CHIP_REMOVE_BUTTON = '.igx-chip__remove';
404-
405-
public static getDeleteButton(fix, index = 0) {
406-
return fix.debugElement.queryAll(By.css(HelperTestFunctions.CHIP_REMOVE_BUTTON))[index];
407-
}
408-
409406
public static verifyChipsCount(fix, count) {
410407
const chipComponents = fix.debugElement.queryAll(By.directive(IgxChipComponent));
411408
expect(chipComponents.length).toEqual(count);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
IgxGridExternalAdvancedFilteringComponent,
1919
IgxGridAdvancedFilteringBindingComponent
2020
} from '../../test-utils/grid-samples.spec';
21+
import { ControlsFunction } from '../../test-utils/controls-functions.spec';
2122

2223
const ADVANCED_FILTERING_OPERATOR_LINE_AND_CSS_CLASS = 'igx-filter-tree__line--and';
2324
const ADVANCED_FILTERING_OPERATOR_LINE_OR_CSS_CLASS = 'igx-filter-tree__line--or';
@@ -2441,7 +2442,7 @@ describe('IgxGrid - Advanced Filtering #grid', () => {
24412442

24422443
// Press 'Enter' on the remove icon of the second chip.
24432444
const chip = GridFunctions.getAdvancedFilteringTreeExpressionChip(fix, [1]);
2444-
const removeIcon = chip.querySelector('.igx-chip__remove');
2445+
const removeIcon = ControlsFunction.getChipRemoveButton(chip);
24452446
UIInteractions.simulateKeyDownEvent(removeIcon, 'Enter');
24462447
tick(200);
24472448
fix.detectChanges();

0 commit comments

Comments
 (0)