Skip to content

Commit 01246a1

Browse files
MKirovaMKirova
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 2af3f55 commit 01246a1

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
@@ -3275,12 +3275,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
32753275

32763276
it('Should not throw error when deleting the last chip', (async () => {
32773277
grid.width = '700px';
3278-
await wait(16);
32793278
fix.detectChanges();
3279+
await wait(16);
32803280

32813281
GridFunctions.clickFilterCellChip(fix, 'ProductName');
32823282
fix.detectChanges();
3283-
await wait(16);
32843283

32853284
// Add first chip.
32863285
GridFunctions.typeValueInFilterRowInput('a', fix);
@@ -3305,7 +3304,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
33053304

33063305
verifyMultipleChipsVisibility(fix, [false, false, false, true]);
33073306
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3308-
let chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3307+
const chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
33093308
expect(chips.length).toBe(4);
33103309

33113310
const leftArrowButton = GridFunctions.getFilterRowLeftArrowButton(fix).nativeElement;
@@ -3315,33 +3314,61 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
33153314
expect(rightArrowButton).toBeTruthy('Right scroll arrow should be visible');
33163315
expect(grid.rowList.length).toBe(2);
33173316

3318-
try {
3319-
GridFunctions.removeFilterChipByIndex(3, filterUIRow);
3320-
fix.detectChanges();
3321-
await wait(400);
3322-
} catch (ex) {
3323-
expect(ex).toBeNull('Error deleting the last chip');
3324-
}
3317+
let chipToRemove = filterUIRow.componentInstance.expressionsList[3];
3318+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3319+
.not.toThrowError(/\'id\' of undefined/);
3320+
fix.detectChanges();
3321+
await wait(500);
3322+
fix.detectChanges();
3323+
3324+
chipToRemove = filterUIRow.componentInstance.expressionsList[2];
3325+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3326+
.not.toThrowError(/\'id\' of undefined/);
33253327
fix.detectChanges();
33263328
await wait(100);
3329+
}));
3330+
3331+
it('should scroll correct chip in view when one is deleted', async() => {
3332+
grid.width = '700px';
3333+
fix.detectChanges();
3334+
3335+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3336+
fix.detectChanges();
3337+
3338+
GridFunctions.applyFilter('a', fix);
3339+
await wait(16);
3340+
GridFunctions.applyFilter('e', fix);
3341+
await wait(16);
3342+
GridFunctions.applyFilter('i', fix);
3343+
await wait(16);
3344+
GridFunctions.applyFilter('o', fix);
3345+
// wait for chip to be scrolled in view
3346+
await wait(200);
3347+
fix.detectChanges();
3348+
await wait(100);
3349+
verifyMultipleChipsVisibility(fix, [false, false, false, true]);
3350+
3351+
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3352+
GridFunctions.removeFilterChipByIndex(3, filterUIRow);
3353+
// wait for chip to be scrolled in view
3354+
fix.detectChanges();
3355+
await wait(200);
3356+
33273357
verifyMultipleChipsVisibility(fix, [false, true, false]);
3328-
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3358+
let chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
33293359
expect(chips.length).toBe(3);
33303360

3331-
try {
3332-
GridFunctions.removeFilterChipByIndex(2, filterUIRow);
3333-
fix.detectChanges();
3334-
await wait(400);
3335-
} catch (ex) {
3336-
expect(ex).toBeNull('Error deleting the last chip');
3337-
}
3361+
GridFunctions.removeFilterChipByIndex(2, filterUIRow);
33383362
fix.detectChanges();
3339-
await wait(100);
3363+
// wait for chip to be scrolled in view
3364+
fix.detectChanges();
3365+
await wait(200);
3366+
33403367
verifyMultipleChipsVisibility(fix, [true, false]);
33413368
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
33423369
expect(chips.length).toBe(2);
33433370
expect(grid.rowList.length).toBe(3);
3344-
}));
3371+
});
33453372

33463373
it('Should close filter row when hide the current column', (async () => {
33473374
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
@@ -537,16 +537,8 @@ export class GridFunctions {
537537
}
538538
}
539539
}
540-
541-
public static filterBy(condition: string, value: string, fix: ComponentFixture<any>) {
540+
public static applyFilter(value: string, fix: ComponentFixture<any>) {
542541
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
543-
// open dropdown
544-
this.openFilterDD(fix.debugElement);
545-
fix.detectChanges();
546-
547-
const ddList = fix.debugElement.query(By.css('div.igx-drop-down__list.igx-toggle'));
548-
this.selectFilteringCondition(condition, ddList);
549-
550542
const input = filterUIRow.query(By.directive(IgxInputDirective));
551543
input.nativeElement.value = value;
552544
input.nativeElement.dispatchEvent(new Event('keydown'));
@@ -559,6 +551,17 @@ export class GridFunctions {
559551
fix.detectChanges();
560552
}
561553

554+
public static filterBy(condition: string, value: string, fix: ComponentFixture<any>) {
555+
// open dropdown
556+
this.openFilterDD(fix.debugElement);
557+
fix.detectChanges();
558+
559+
const ddList = fix.debugElement.query(By.css('div.igx-drop-down__list.igx-toggle'));
560+
this.selectFilteringCondition(condition, ddList);
561+
562+
this.applyFilter(value, fix);
563+
}
564+
562565
public static typeValueInFilterRowInput(value: string, fix) {
563566
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
564567
const input = filterUIRow.query(By.directive(IgxInputDirective));

0 commit comments

Comments
 (0)