Skip to content

Commit 4394b0f

Browse files
authored
Merge pull request #5656 from IgniteUI/mkirova/fix-5478-8.2.x
test(igxHierarchicalGrid): Splitting tests so that they cover simpler…
2 parents d497969 + f29d95f commit 4394b0f

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.navigation.spec.ts

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -930,49 +930,76 @@ describe('IgxHierarchicalGrid Multi-layout Navigation', () => {
930930
hierarchicalGrid = fixture.componentInstance.hgrid;
931931
setupHierarchicalGridScrollDetection(fixture, hierarchicalGrid);
932932
}));
933-
it('should allow navigating up/down between sibling child grids.', (async () => {
933+
934+
it('should allow navigating up between sibling child grids.', (async () => {
934935
hierarchicalGrid.verticalScrollContainer.scrollTo(2);
935936
await wait(100);
936937
fixture.detectChanges();
937938
const child1 = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
938939
const child2 = hierarchicalGrid.hgridAPI.getChildGrids(false)[4];
939940

940941
const child2Cell = child2.dataRowList.toArray()[0].cells.toArray()[0];
941-
child2Cell.nativeElement.focus();
942-
await wait(100);
943-
fixture.detectChanges();
944-
945-
let keyboardEvent = new KeyboardEvent('keydown', {
942+
const keyboardEvent = new KeyboardEvent('keydown', {
946943
code: 'ArrowUp',
947944
key: 'ArrowUp'
948945
});
949946
child2Cell.dispatchEvent(keyboardEvent);
947+
fixture.detectChanges();
950948
await wait(100);
951949
fixture.detectChanges();
952950
const lastCellPrevRI = child1.dataRowList.toArray()[1].cells.toArray()[0];
953951

954952
expect(lastCellPrevRI.selected).toBe(true);
955-
expect(lastCellPrevRI.focused).toBe(true);
956953
expect(lastCellPrevRI.rowIndex).toBe(9);
954+
}));
955+
it('should allow navigating down between sibling child grids.', (async () => {
956+
hierarchicalGrid.verticalScrollContainer.scrollTo(2);
957+
await wait(100);
958+
fixture.detectChanges();
959+
const child1 = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
960+
const child2 = hierarchicalGrid.hgridAPI.getChildGrids(false)[4];
957961

958-
keyboardEvent = new KeyboardEvent('keydown', {
962+
child1.verticalScrollContainer.scrollTo(child1.verticalScrollContainer.igxForOf.length - 1);
963+
await wait(100);
964+
fixture.detectChanges();
965+
966+
const keyboardEvent = new KeyboardEvent('keydown', {
959967
code: 'ArrowDown',
960968
key: 'ArrowDown'
961969
});
970+
const child2Cell = child2.dataRowList.toArray()[0].cells.toArray()[0];
971+
const lastCellPrevRI = child1.dataRowList.toArray()[1].cells.toArray()[0];
962972
lastCellPrevRI.dispatchEvent(keyboardEvent);
973+
fixture.detectChanges();
963974
await wait(100);
964975
fixture.detectChanges();
965976
expect(child2Cell.selected).toBe(true);
966977
}));
967-
it('should allow navigating with Tab/Shift+Tab between sibling child grids.', (async () => {
978+
979+
it('should allow navigating with Tab between sibling child grids.', (async () => {
968980
const child1 = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
969981
const child2 = hierarchicalGrid.hgridAPI.getChildGrids(false)[4];
970982

971-
const child2Cell = child2.dataRowList.toArray()[0].cells.toArray()[0];
972-
child2Cell.nativeElement.focus();
973-
await wait(240);
983+
child1.verticalScrollContainer.scrollTo(child1.verticalScrollContainer.igxForOf.length - 1);
984+
await wait(100);
974985
fixture.detectChanges();
986+
const rowVirt = child1.dataRowList.toArray()[0].virtDirRow;
987+
rowVirt.scrollTo(rowVirt.igxForOf.length - 1);
988+
await wait(100);
989+
fixture.detectChanges();
990+
const child1Cell = child1.getCellByColumn(9, 'childData');
991+
const child2Cell = child2.dataRowList.toArray()[0].cells.toArray()[0];
992+
// Tab from last cell in 1st child
993+
child1Cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab'}));
994+
await wait(100);
995+
fixture.detectChanges();
996+
expect(child2Cell.selected).toBe(true);
997+
}));
998+
it('should allow navigating with Shift+Tab between sibling child grids.', (async () => {
999+
const child1 = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
1000+
const child2 = hierarchicalGrid.hgridAPI.getChildGrids(false)[4];
9751001

1002+
const child2Cell = child2.dataRowList.toArray()[0].cells.toArray()[0];
9761003
// Shift + Tab from 2nd child
9771004
child2Cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab', shiftKey: true }));
9781005
await wait(240);
@@ -983,13 +1010,6 @@ describe('IgxHierarchicalGrid Multi-layout Navigation', () => {
9831010
expect(child1Cell.selected).toBe(true);
9841011
expect(child1Cell.rowIndex).toBe(9);
9851012
expect(child1Cell.columnIndex).toBe(6);
986-
987-
// Tab from last cell in 1st child
988-
child1Cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab'}));
989-
await wait(100);
990-
fixture.detectChanges();
991-
992-
expect(child2Cell.selected).toBe(true);
9931013
}));
9941014
it('should navigate up from parent row to the correct child sibling.', (async () => {
9951015
const parentCell = hierarchicalGrid.dataRowList.toArray()[1].cells.toArray()[0];

0 commit comments

Comments
 (0)