Skip to content

Commit 533fbbf

Browse files
committed
chore(*): fix esf unit tests
1 parent c275b57 commit 533fbbf

File tree

1 file changed

+88
-57
lines changed

1 file changed

+88
-57
lines changed

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

+88-57
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
16411641
expect(conditionChips.length).toBe(0);
16421642
}));
16431643

1644-
it('Should open/close filterRow for respective column when pressing \'ctrl + shift + l\' on its filterCell chip.',
1644+
it('Should open filterRow for respective column when pressing \'ctrl + shift + l\' on its filterCell chip.',
16451645
fakeAsync(() => {
16461646
// Verify filterRow is not opened.
16471647
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).toBeNull();
@@ -1661,12 +1661,6 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
16611661
(hg) => hg.nativeElement.classList.contains('igx-grid__th--filtering'));
16621662
expect(headerGroupsFiltering.length).toBe(1);
16631663
expect(headerGroupsFiltering[0].componentInstance.column.field).toBe('ReleaseDate');
1664-
1665-
UIInteractions.triggerKeyDownEvtUponElem('l', releaseDateColumn.nativeElement, true, false, true, true);
1666-
tick(200);
1667-
fix.detectChanges();
1668-
1669-
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).not.toBeNull();
16701664
}));
16711665

16721666
it('Should navigate to first cell of grid when pressing \'Tab\' on the last filterCell chip.', fakeAsync(() => {
@@ -4323,6 +4317,33 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43234317
expect(excelMenu).toBeNull();
43244318
}));
43254319

4320+
it('Should open/close filterRow for respective column when pressing \'ctrl + shift + l\' on its filterCell chip.',
4321+
fakeAsync(() => {
4322+
let excelMenu = GridFunctions.getExcelStyleFilteringComponent(fix);
4323+
// Verify ESF is not visible.
4324+
expect(excelMenu).toBeNull();
4325+
4326+
const downloadsColumn = GridFunctions.getColumnHeader('Downloads', fix);
4327+
UIInteractions.simulateClickAndSelectEvent(downloadsColumn);
4328+
fix.detectChanges();
4329+
4330+
UIInteractions.triggerKeyDownEvtUponElem('l', downloadsColumn.nativeElement, true, false, true, true);
4331+
tick(200);
4332+
fix.detectChanges();
4333+
4334+
// Verify ESF menu is opened for the 'Downloads' column.
4335+
excelMenu = GridFunctions.getExcelStyleFilteringComponent(fix);
4336+
expect(excelMenu).not.toBeNull();
4337+
4338+
// Press the combination again.
4339+
UIInteractions.triggerKeyDownEvtUponElem('l', excelMenu, true, false, true, true);
4340+
tick(200);
4341+
fix.detectChanges();
4342+
4343+
excelMenu = GridFunctions.getExcelStyleFilteringComponent(fix);
4344+
expect(excelMenu).toBeNull();
4345+
}));
4346+
43264347
it('Should filter date by input string', fakeAsync(() => {
43274348
GridFunctions.clickExcelFilterIcon(fix, 'ReleaseDate');
43284349
tick(100);
@@ -4444,71 +4465,81 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
44444465
}));
44454466

44464467
it('Should add list items to current filtered items when "Add to current filter selection" is selected.', fakeAsync(() => {
4447-
const totalListItems = [];
4468+
const totalListItems = [];
44484469

4449-
// Open excel style custom filtering dialog.
4450-
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
4470+
// Open excel style custom filtering dialog.
4471+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
44514472

4452-
// Type string in search box.
4453-
let searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4454-
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);
4455-
UIInteractions.clickAndSendInputElementValue(inputNativeElement, '5', fix);
4456-
tick(100);
4457-
fix.detectChanges();
4473+
// Type string in search box.
4474+
let searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4475+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);
4476+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, '5', fix);
4477+
tick(100);
4478+
fix.detectChanges();
4479+
4480+
let listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent)
4481+
.splice(2)
4482+
.map(c => c.innerText);
44584483

4459-
let listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent)
4460-
.splice(2)
4461-
.map(c => c.innerText);
4484+
listItems.forEach(c => totalListItems.push(c));
44624485

4463-
listItems.forEach(c => totalListItems.push(c));
4486+
// Click 'apply' button to apply filter.
4487+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4488+
tick(100);
4489+
fix.detectChanges();
44644490

4465-
// Click 'apply' button to apply filter.
4466-
GridFunctions.clickApplyExcelStyleFiltering(fix);
4467-
tick(100);
4468-
fix.detectChanges();
4491+
// Get the results and verify that they match the list items.
4492+
let gridCellValues = GridFunctions.getColumnCells(fix, 'Downloads')
4493+
.map(c => c.nativeElement.innerText);
44694494

4470-
// Get the results and verify that they match the list items.
4471-
let gridCellValues = GridFunctions.getColumnCells(fix, 'Downloads')
4472-
.map(c => c.nativeElement.innerText);
4495+
expect(gridCellValues.length).toEqual(1);
4496+
expect(gridCellValues).toEqual(totalListItems);
44734497

4474-
expect(gridCellValues.length).toEqual(1);
4475-
expect(gridCellValues).toEqual(totalListItems);
4498+
// Open excel style custom filtering dialog again.
4499+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
44764500

4477-
// Open excel style custom filtering dialog again.
4478-
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
4501+
// Type string in search box.
4502+
searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4503+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);
4504+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, '7', fix);
4505+
tick(100);
4506+
fix.detectChanges();
44794507

4480-
// Type string in search box.
4481-
searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4482-
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);
4483-
UIInteractions.clickAndSendInputElementValue(inputNativeElement, '7', fix);
4484-
tick(100);
4485-
fix.detectChanges();
4508+
listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent)
4509+
.splice(2)
4510+
.map(c => c.innerText);
44864511

4487-
listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent)
4488-
.splice(2)
4489-
.map(c => c.innerText);
4512+
listItems.forEach(c => totalListItems.push(c));
4513+
totalListItems.sort();
44904514

4491-
listItems.forEach(c => totalListItems.push(c));
4492-
totalListItems.sort();
4515+
// Select 'Add to current filter selection'.
4516+
const checkbox = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4517+
checkbox[1].click();
4518+
tick();
4519+
fix.detectChanges();
44934520

4494-
// Select 'Add to current filter selection'.
4495-
const checkbox = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4496-
checkbox[1].click();
4497-
tick();
4498-
fix.detectChanges();
4521+
// Click 'apply' button to apply filter.
4522+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4523+
tick(100);
4524+
fix.detectChanges();
44994525

4500-
// Click 'apply' button to apply filter.
4501-
GridFunctions.clickApplyExcelStyleFiltering(fix);
4502-
tick(100);
4503-
fix.detectChanges();
4526+
// Get the results and verify that they match the list items.
4527+
gridCellValues = GridFunctions.getColumnCells(fix, 'Downloads')
4528+
.map(c => c.nativeElement.innerText)
4529+
.sort();
45044530

4505-
// Get the results and verify that they match the list items.
4506-
gridCellValues = GridFunctions.getColumnCells(fix, 'Downloads')
4507-
.map(c => c.nativeElement.innerText)
4508-
.sort();
4531+
expect(gridCellValues.length).toEqual(3);
4532+
expect(gridCellValues).toEqual(totalListItems);
4533+
4534+
// Open excel style custom filtering dialog again.
4535+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
4536+
4537+
// Get checkboxes and verify 'Select All' is indeterminate.
4538+
const excelMenu = GridFunctions.getExcelStyleFilteringComponent(fix);
4539+
const checkboxes: any[] = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix, excelMenu));
4540+
fix.detectChanges();
45094541

4510-
expect(gridCellValues.length).toEqual(3);
4511-
expect(gridCellValues).toEqual(totalListItems);
4542+
expect(checkboxes[0].indeterminate).toBeTrue();
45124543
}));
45134544

45144545
it('Should commit and close ESF on pressing \'Enter\'', fakeAsync(() => {

0 commit comments

Comments
 (0)