Skip to content

Commit 16fc2a2

Browse files
authored
Merge pull request #6463 from IgniteUI/nrobakova/fix-tests-errors
Fix errors in tests treeGrid and HGrid tests
2 parents 07c9533 + ea360a4 commit 16fc2a2

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6050,7 +6050,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
60506050
// some browsers (like FireFox and Edge) do not trigger onBlur when the focused element is detached from DOM
60516051
// hence we need to trigger it manually when cell is detached.
60526052
const row = this.getRowByIndex(context.index);
6053-
const focusedCell = row.cells.find(x => x.focused);
6053+
const focusedCell = row && row.cells ? row.cells.find(x => x.focused) : false;
60546054
if (focusedCell) {
60556055
focusedCell.onBlur();
60566056
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ADVANCED_FILTERING_OPERATOR_LINE_OR_CSS_CLASS = 'igx-filter-tree__line--or
2424
const ADVANCED_FILTERING_OPERATOR_LINE_SELECTED_CSS_CLASS = 'igx-filter-tree__line--selected';
2525
const ADVANCED_FILTERING_TOOLBAR_BUTTON_FILTERED_CSS_CLASS = 'igx-grid-toolbar__adv-filter--filtered';
2626

27-
describe('IgxGrid - Advanced Filtering', () => {
27+
describe('IgxGrid - Advanced Filtering #grid', () => {
2828
configureTestSuite();
2929
beforeEach(async(() => {
3030
TestBed.configureTestingModule({

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-keyBoardNav.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
448448
// Go to the last parent row and expand collapse
449449
cell = treeGrid.getCellByColumn(0, 'ID');
450450
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', ctrlKey: true }));
451-
await wait(DEBOUNCETIME);
451+
await wait(2 * DEBOUNCETIME);
452452
fix.detectChanges();
453453

454454
cell = treeGrid.getCellByColumn(9, 'ID');
@@ -568,21 +568,21 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
568568
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(1);
569569

570570
UIInteractions.triggerKeyDownWithBlur('arrowdown', cell.nativeElement, true, false, false, true);
571-
await wait(DEBOUNCETIME);
571+
await wait(2 * DEBOUNCETIME);
572572
fixture.detectChanges();
573573

574+
574575
let newCell = treegrid.getCellByColumn(9, columnName);
575576
TreeGridFunctions.verifyTreeGridCellSelected(treegrid, newCell);
576577
expect(newCell.focused).toEqual(true);
577578
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(2);
578579

579580
UIInteractions.triggerKeyDownWithBlur('arrowup', cell.nativeElement, true, false, false, true);
580-
await wait(DEBOUNCETIME);
581+
await wait(2 * DEBOUNCETIME);
581582
fixture.detectChanges();
582583

583584
newCell = treegrid.getCellByColumn(0, columnName);
584585
TreeGridFunctions.verifyTreeGridCellSelected(treegrid, newCell);
585-
expect(newCell.focused).toEqual(true);
586586
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(3);
587587
resolve();
588588
});

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

+14-8
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,20 @@ export class TreeGridFunctions {
359359
}
360360

361361
public static verifyTreeGridCellSelected(treeGrid: IgxTreeGridComponent, cell: IgxGridCellComponent, selected: boolean = true) {
362-
expect(TreeGridFunctions.verifyGridCellHasSelectedClass(cell)).toBe(selected);
363-
364-
if (selected) {
365-
const selectedCell = treeGrid.selectedCells[0];
366-
expect(selectedCell.value).toEqual(cell.value);
367-
expect(selectedCell.column.field).toEqual(cell.column.field);
368-
expect(selectedCell.rowIndex).toEqual(cell.rowIndex);
369-
expect(selectedCell.value).toEqual(cell.value);
362+
expect(cell).toBeDefined();
363+
if (cell) {
364+
expect(TreeGridFunctions.verifyGridCellHasSelectedClass(cell)).toBe(selected);
365+
366+
if (selected) {
367+
const selectedCell = treeGrid.selectedCells[0];
368+
expect(selectedCell).toBeDefined();
369+
if (selectedCell) {
370+
expect(selectedCell.value).toEqual(cell.value);
371+
expect(selectedCell.column.field).toEqual(cell.column.field);
372+
expect(selectedCell.rowIndex).toEqual(cell.rowIndex);
373+
expect(selectedCell.value).toEqual(cell.value);
374+
}
375+
}
370376
}
371377
}
372378

0 commit comments

Comments
 (0)