Skip to content

Commit 082347f

Browse files
MKirovadamyanpetev
authored andcommitted
chore(*): Split complex test in 2
One that tests for errors and another that tests the visible chips in scroll area.
1 parent e04910b commit 082347f

File tree

2 files changed

+59
-29
lines changed

2 files changed

+59
-29
lines changed

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

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,12 +3257,11 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32573257

32583258
it('Should not throw error when deleting the last chip', (async () => {
32593259
grid.width = '700px';
3260-
await wait(16);
32613260
fix.detectChanges();
3261+
await wait(16);
32623262

32633263
GridFunctions.clickFilterCellChip(fix, 'ProductName');
32643264
fix.detectChanges();
3265-
await wait(16);
32663265

32673266
// Add first chip.
32683267
GridFunctions.typeValueInFilterRowInput('a', fix);
@@ -3287,7 +3286,7 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32873286

32883287
verifyMultipleChipsVisibility(fix, [false, false, false, true]);
32893288
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3290-
let chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3289+
const chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
32913290
expect(chips.length).toBe(4);
32923291

32933292
const leftArrowButton = GridFunctions.getFilterRowLeftArrowButton(fix).nativeElement;
@@ -3297,33 +3296,61 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32973296
expect(rightArrowButton).toBeTruthy('Right scroll arrow should be visible');
32983297
expect(grid.rowList.length).toBe(2);
32993298

3300-
try {
3301-
GridFunctions.removeFilterChipByIndex(3, filterUIRow);
3302-
fix.detectChanges();
3303-
await wait(400);
3304-
} catch (ex) {
3305-
expect(ex).toBeNull('Error deleting the last chip');
3306-
}
3299+
let chipToRemove = filterUIRow.componentInstance.expressionsList[3];
3300+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3301+
.not.toThrowError(/\'id\' of undefined/);
3302+
fix.detectChanges();
3303+
await wait(500);
3304+
fix.detectChanges();
3305+
3306+
chipToRemove = filterUIRow.componentInstance.expressionsList[2];
3307+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3308+
.not.toThrowError(/\'id\' of undefined/);
33073309
fix.detectChanges();
33083310
await wait(100);
3311+
}));
3312+
3313+
it('should scroll correct chip in view when one is deleted', async() => {
3314+
grid.width = '700px';
3315+
fix.detectChanges();
3316+
3317+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3318+
fix.detectChanges();
3319+
3320+
GridFunctions.applyFilter('a', fix);
3321+
await wait(16);
3322+
GridFunctions.applyFilter('e', fix);
3323+
await wait(16);
3324+
GridFunctions.applyFilter('i', fix);
3325+
await wait(16);
3326+
GridFunctions.applyFilter('o', fix);
3327+
// wait for chip to be scrolled in view
3328+
await wait(200);
3329+
fix.detectChanges();
3330+
await wait(100);
3331+
verifyMultipleChipsVisibility(fix, [false, false, false, true]);
3332+
3333+
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3334+
GridFunctions.removeFilterChipByIndex(3, filterUIRow);
3335+
// wait for chip to be scrolled in view
3336+
fix.detectChanges();
3337+
await wait(200);
3338+
33093339
verifyMultipleChipsVisibility(fix, [false, true, false]);
3310-
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3340+
let chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
33113341
expect(chips.length).toBe(3);
33123342

3313-
try {
3314-
GridFunctions.removeFilterChipByIndex(2, filterUIRow);
3315-
fix.detectChanges();
3316-
await wait(400);
3317-
} catch (ex) {
3318-
expect(ex).toBeNull('Error deleting the last chip');
3319-
}
3343+
GridFunctions.removeFilterChipByIndex(2, filterUIRow);
33203344
fix.detectChanges();
3321-
await wait(100);
3345+
// wait for chip to be scrolled in view
3346+
fix.detectChanges();
3347+
await wait(200);
3348+
33223349
verifyMultipleChipsVisibility(fix, [true, false]);
33233350
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
33243351
expect(chips.length).toBe(2);
33253352
expect(grid.rowList.length).toBe(3);
3326-
}));
3353+
});
33273354

33283355
it('Should close filter row when hide the current column', (async () => {
33293356
grid.height = '700px';

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,8 @@ export class GridFunctions {
402402
}
403403
}
404404
}
405-
406-
public static filterBy(condition: string, value: string, fix: ComponentFixture<any>) {
405+
public static applyFilter(value: string, fix: ComponentFixture<any>) {
407406
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
408-
// open dropdown
409-
this.openFilterDD(fix.debugElement);
410-
fix.detectChanges();
411-
412-
const ddList = fix.debugElement.query(By.css('div.igx-drop-down__list.igx-toggle'));
413-
this.selectFilteringCondition(condition, ddList);
414-
415407
const input = filterUIRow.query(By.directive(IgxInputDirective));
416408
input.nativeElement.value = value;
417409
input.nativeElement.dispatchEvent(new Event('keydown'));
@@ -424,6 +416,17 @@ export class GridFunctions {
424416
fix.detectChanges();
425417
}
426418

419+
public static filterBy(condition: string, value: string, fix: ComponentFixture<any>) {
420+
// open dropdown
421+
this.openFilterDD(fix.debugElement);
422+
fix.detectChanges();
423+
424+
const ddList = fix.debugElement.query(By.css('div.igx-drop-down__list.igx-toggle'));
425+
this.selectFilteringCondition(condition, ddList);
426+
427+
this.applyFilter(value, fix);
428+
}
429+
427430
public static typeValueInFilterRowInput(value: string, fix) {
428431
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
429432
const input = filterUIRow.query(By.directive(IgxInputDirective));

0 commit comments

Comments
 (0)