Skip to content

Commit e20eed9

Browse files
committed
test(adv-filtering): adv filter icon test #5496
1 parent 56b8835 commit e20eed9

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { resizeObserverIgnoreError } from '../../test-utils/helper-utils.spec';
2020
const ADVANCED_FILTERING_OPERATOR_LINE_AND_CSS_CLASS = 'igx-filter-tree__line--and';
2121
const ADVANCED_FILTERING_OPERATOR_LINE_OR_CSS_CLASS = 'igx-filter-tree__line--or';
2222
const ADVANCED_FILTERING_OPERATOR_LINE_SELECTED_CSS_CLASS = 'igx-filter-tree__line--selected';
23+
const ADVANCED_FILTERING_TOOLBAR_ICON_BUTTON_FILTERED_CSS_CLASS = 'igx-grid-toolbar__adv-filter--filtered';
2324

2425
describe('IgxGrid - Advanced Filtering', () => {
2526
configureTestSuite();
@@ -324,6 +325,58 @@ describe('IgxGrid - Advanced Filtering', () => {
324325
expect(GridFunctions.getCurrentCellFromGrid(grid, 1, 1).value).toBe('Ignite UI for Angular');
325326
}));
326327

328+
it('Should update the Advanced Filtering button icon in toolbar when (filtering)/(clear filtering).',
329+
fakeAsync(() => {
330+
// Verify that the advanced filtering button icon indicates there are no filters.
331+
let advFilterIcon = GridFunctions.getAdvancedFilteringButton(fix).querySelector('igx-icon');
332+
expect(advFilterIcon.classList.contains(ADVANCED_FILTERING_TOOLBAR_ICON_BUTTON_FILTERED_CSS_CLASS))
333+
.toBe(false, 'Button icon indicates there is active filtering.');
334+
335+
// Open Advanced Filtering dialog.
336+
GridFunctions.clickAdvancedFilteringButton(fix);
337+
fix.detectChanges();
338+
339+
// Click the initial 'Add And Group' button.
340+
const addAndGroupButton = GridFunctions.getAdvancedFilteringInitialAddGroupButtons(fix)[0];
341+
addAndGroupButton.click();
342+
tick(100);
343+
fix.detectChanges();
344+
345+
// Populate edit inputs.
346+
selectColumnInEditModeExpression(fix, 1); // Select 'ProductName' column.
347+
selectOperatorInEditModeExpression(fix, 0); // Select 'Contains' operator.
348+
const input = GridFunctions.getAdvancedFilteringValueInput(fix).querySelector('input');
349+
sendInputNativeElement(fix, input, 'angular'); // Type filter value.
350+
// Commit the populated expression.
351+
GridFunctions.clickAdvancedFilteringExpressionCommitButton(fix);
352+
fix.detectChanges();
353+
354+
// Apply the filters.
355+
GridFunctions.clickAdvancedFilteringApplyButton(fix);
356+
357+
// Verify that the advanced filtering button icon indicates there are filters.
358+
advFilterIcon = GridFunctions.getAdvancedFilteringButton(fix).querySelector('igx-icon');
359+
expect(advFilterIcon.classList.contains(ADVANCED_FILTERING_TOOLBAR_ICON_BUTTON_FILTERED_CSS_CLASS))
360+
.toBe(true, 'Button icon indicates there is no active filtering.');
361+
362+
// Open Advanced Filtering dialog.
363+
GridFunctions.clickAdvancedFilteringButton(fix);
364+
fix.detectChanges();
365+
366+
// Clear the filters.
367+
GridFunctions.clickAdvancedFilteringClearFilterButton(fix);
368+
fix.detectChanges();
369+
370+
// Close the dialog.
371+
GridFunctions.clickAdvancedFilteringApplyButton(fix);
372+
fix.detectChanges();
373+
374+
// Verify that the advanced filtering button icon indicates there are no filters.
375+
advFilterIcon = GridFunctions.getAdvancedFilteringButton(fix).querySelector('igx-icon');
376+
expect(advFilterIcon.classList.contains(ADVANCED_FILTERING_TOOLBAR_ICON_BUTTON_FILTERED_CSS_CLASS))
377+
.toBe(false, 'Button icon indicates there is active filtering.');
378+
}));
379+
327380
it('Should correctly filter by a \'string\' column through UI.', fakeAsync(() => {
328381
// Test prerequisites
329382
grid.height = '800px';

0 commit comments

Comments
 (0)