Skip to content

Commit 256f247

Browse files
committed
test(filtering): Adding test #6519
1 parent 64c15e1 commit 256f247

File tree

1 file changed

+60
-38
lines changed

1 file changed

+60
-38
lines changed

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

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,7 +3312,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
33123312
await wait(100);
33133313
}));
33143314

3315-
it('should scroll correct chip in view when one is deleted', async() => {
3315+
it('should scroll correct chip in view when one is deleted', async () => {
33163316
grid.width = '700px';
33173317
fix.detectChanges();
33183318

@@ -3400,11 +3400,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34003400
GridFunctions.verifyColumnIsHidden(prodNameCol, true, 5);
34013401
}));
34023402

3403-
it('Unary conditions should be committable', fakeAsync (() => {
3403+
it('Unary conditions should be committable', fakeAsync(() => {
34043404
grid.height = '700px';
34053405
fix.detectChanges();
34063406

3407-
const prodNameCol = grid.columns.find((col) => col.field === 'ProductName');
34083407
GridFunctions.clickFilterCellChip(fix, 'ProductName');
34093408
fix.detectChanges();
34103409

@@ -3429,36 +3428,57 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34293428
fix.detectChanges();
34303429
tick(100);
34313430
expect(chip.componentInstance.selected).toBeTruthy();
3432-
}));
3431+
}));
34333432

3434-
it('Should close filterRow when changing filterMode from \'quickFilter\' to \'excelStyleFilter\'', (async () => {
3435-
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3436-
fix.detectChanges();
3433+
it('Should close filterRow when changing filterMode from \'quickFilter\' to \'excelStyleFilter\'', (async () => {
3434+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3435+
fix.detectChanges();
34373436

3438-
// Add a condition chip without submitting it.
3439-
GridFunctions.typeValueInFilterRowInput('a', fix);
3440-
await wait(16);
3437+
// Add a condition chip without submitting it.
3438+
GridFunctions.typeValueInFilterRowInput('a', fix);
3439+
await wait(16);
34413440

3442-
// Change filterMode to 'excelStyleFilter`
3443-
grid.filterMode = FilterMode.excelStyleFilter;
3444-
fix.detectChanges();
3441+
// Change filterMode to 'excelStyleFilter`
3442+
grid.filterMode = FilterMode.excelStyleFilter;
3443+
fix.detectChanges();
34453444

3446-
// Verify the the filterRow is closed.
3447-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3448-
expect(filterUIRow).toBeNull('filterRow is visible');
3449-
3450-
// Verify the ESF icons are visible.
3451-
const gridNativeElement = fix.debugElement.query(By.css('igx-grid')).nativeElement;
3452-
const thead = gridNativeElement.querySelector('.igx-grid__thead-wrapper');
3453-
const filterIcons = thead.querySelectorAll('.igx-excel-filter__icon');
3454-
expect(filterIcons.length).toEqual(4, 'incorrect esf filter icons count');
3455-
3456-
// Verify the condition was submitted.
3457-
const header = GridFunctions.getColumnHeader('ProductName', fix);
3458-
const activeFilterIcon = header.nativeElement.querySelector('.igx-excel-filter__icon--filtered');
3459-
expect(activeFilterIcon).toBeDefined('no active filter icon was found');
3460-
}));
3461-
});
3445+
// Verify the the filterRow is closed.
3446+
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3447+
expect(filterUIRow).toBeNull('filterRow is visible');
3448+
3449+
// Verify the ESF icons are visible.
3450+
const gridNativeElement = fix.debugElement.query(By.css('igx-grid')).nativeElement;
3451+
const thead = gridNativeElement.querySelector('.igx-grid__thead-wrapper');
3452+
const filterIcons = thead.querySelectorAll('.igx-excel-filter__icon');
3453+
expect(filterIcons.length).toEqual(4, 'incorrect esf filter icons count');
3454+
3455+
// Verify the condition was submitted.
3456+
const header = GridFunctions.getColumnHeader('ProductName', fix);
3457+
const activeFilterIcon = header.nativeElement.querySelector('.igx-excel-filter__icon--filtered');
3458+
expect(activeFilterIcon).toBeDefined('no active filter icon was found');
3459+
}));
3460+
3461+
it('Should clear non-unary conditions with null searchVal when close', fakeAsync(() => {
3462+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3463+
fix.detectChanges();
3464+
3465+
GridFunctions.openFilterDD(fix.debugElement);
3466+
const dropdownList = fix.debugElement.query(By.css('div.igx-drop-down__list.igx-toggle'));
3467+
GridFunctions.selectFilteringCondition('Empty', dropdownList);
3468+
fix.detectChanges();
3469+
tick(16);
3470+
GridFunctions.openFilterDD(fix.debugElement);
3471+
GridFunctions.selectFilteringCondition('Contains', dropdownList);
3472+
fix.detectChanges();
3473+
tick(16);
3474+
3475+
GridFunctions.closeFilterRow(fix);
3476+
tick(16);
3477+
3478+
const headerChip = GridFunctions.getFilterChipsForColumn('ProductName', fix);
3479+
expect(headerChip.length).toBe(1);
3480+
}));
3481+
});
34623482
describe(null, () => {
34633483
let fix, grid;
34643484
beforeEach(fakeAsync(() => {
@@ -5887,11 +5907,11 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
58875907
}));
58885908

58895909
it('Should be able to set custom filtering strategy', () => {
5890-
expect(grid.filterStrategy).toBeUndefined();
5891-
grid.filterStrategy = fix.componentInstance.strategy;
5892-
fix.detectChanges();
5910+
expect(grid.filterStrategy).toBeUndefined();
5911+
grid.filterStrategy = fix.componentInstance.strategy;
5912+
fix.detectChanges();
58935913

5894-
expect(grid.filterStrategy).toEqual(fix.componentInstance.strategy);
5914+
expect(grid.filterStrategy).toEqual(fix.componentInstance.strategy);
58955915
});
58965916

58975917
it('Should be able to override getFieldValue method', fakeAsync(() => {
@@ -5933,8 +5953,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
59335953
fix.detectChanges();
59345954

59355955
expect(grid.filteredData).toEqual([
5936-
{ ID: 2, Name: { FirstName: 'Gilberto', LastName: 'Todd' } , JobTitle: 'Director', Company: 'Company C' },
5937-
{ ID: 3, Name: { FirstName: 'Tanya', LastName: 'Bennett' } , JobTitle: 'Director', Company: 'Company A' }]);
5956+
{ ID: 2, Name: { FirstName: 'Gilberto', LastName: 'Todd' }, JobTitle: 'Director', Company: 'Company C' },
5957+
{ ID: 3, Name: { FirstName: 'Tanya', LastName: 'Bennett' }, JobTitle: 'Director', Company: 'Company A' }]);
59385958
GridFunctions.resetFilterRow(fix);
59395959
GridFunctions.closeFilterRow(fix);
59405960
fix.detectChanges();
@@ -5961,8 +5981,10 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
59615981
fix.detectChanges();
59625982

59635983
expect(grid.filteredData).toEqual([
5964-
{ ID: 7, Name: { FirstName: 'Debra', LastName: 'Morton' } ,
5965-
JobTitle: 'Associate Software Developer', Company: 'Company B' },
5984+
{
5985+
ID: 7, Name: { FirstName: 'Debra', LastName: 'Morton' },
5986+
JobTitle: 'Associate Software Developer', Company: 'Company B'
5987+
},
59665988
{ ID: 10, Name: { FirstName: 'Eduardo', LastName: 'Ramirez' }, JobTitle: 'Manager', Company: 'Company E' }]);
59675989
}));
59685990
});
@@ -6478,7 +6500,7 @@ function clickElemAndBlur(clickElem, blurElem) {
64786500
UIInteractions.simulatePointerEvent('pointerdown', clickElem.nativeElement, elementRect.left, elementRect.top);
64796501
blurElem.nativeElement.blur();
64806502
(clickElem as DebugElement).nativeElement.focus();
6481-
blurElem.nativeElement.dispatchEvent(new FocusEvent('focusout', {bubbles: true}));
6503+
blurElem.nativeElement.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));
64826504
UIInteractions.simulatePointerEvent('pointerup', clickElem.nativeElement, elementRect.left, elementRect.top);
64836505
UIInteractions.simulateMouseEvent('click', clickElem.nativeElement, 10, 10);
64846506
}

0 commit comments

Comments
 (0)