Skip to content

Commit 7142de1

Browse files
committed
chore(*): update tests for pinned columns
1 parent 343a03d commit 7142de1

File tree

1 file changed

+58
-25
lines changed

1 file changed

+58
-25
lines changed

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

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,20 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
946946

947947
const columns = ['HireDate', 'ID', 'Name', 'Age', 'OnPTO'];
948948

949-
for (let i = 2; i < columns.length - 1; i++) {
949+
const firstCell = treeGrid.getCellByColumn(5, 'HireDate');
950+
GridFunctions.simulateCellKeydown(firstCell, 'End');
951+
await wait(DEBOUNCETIME);
952+
zone.simulateOnStable();
953+
fix.detectChanges();
954+
await wait(DEBOUNCETIME);
955+
zone.simulateOnStable();
956+
fix.detectChanges();
957+
958+
const lastCell = treeGrid.getCellByColumn(5, columns[4]);
959+
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, lastCell);
960+
expect(treeGrid.headerContainer.getScroll().scrollLeft).toBeGreaterThan(0);
961+
962+
for (let i = 0; i < columns.length - 1; i++) {
950963
let cell = treeGrid.getCellByColumn(5, columns[i]);
951964
GridFunctions.simulateCellKeydown(cell, 'Tab');
952965
await wait(DEBOUNCETIME);
@@ -1004,68 +1017,88 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
10041017
expect(treeGrid.headerContainer.getScroll().scrollLeft).toEqual(0);
10051018
});
10061019

1007-
it('should navigate with arrow Left and Right keys when there is pinned column', async () => {
1020+
it('should navigate with arrow Left key when there is a pinned column', async () => {
10081021
treeGrid.getColumnByName('HireDate').pinned = true;
10091022
fix.detectChanges();
10101023

10111024
const columns = ['HireDate', 'ID', 'Name', 'Age', 'OnPTO'];
10121025

1013-
for (let i = 2; i < columns.length - 1; i++) {
1014-
let cell = treeGrid.getCellByColumn(0, columns[i]);
1015-
GridFunctions.simulateCellKeydown(cell, 'ArrowRight');
1026+
const firstCell = treeGrid.getCellByColumn(3, 'HireDate');
1027+
GridFunctions.simulateCellKeydown(firstCell, 'End');
1028+
await wait(DEBOUNCETIME);
1029+
zone.simulateOnStable();
1030+
fix.detectChanges();
1031+
await wait(DEBOUNCETIME);
1032+
zone.simulateOnStable();
1033+
fix.detectChanges();
1034+
1035+
const lastCell = treeGrid.getCellByColumn(3, columns[4]);
1036+
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, lastCell);
1037+
expect(treeGrid.headerContainer.getScroll().scrollLeft).toBeGreaterThan(0);
1038+
1039+
for (let i = 4; i > 0 ; i--) {
1040+
let cell = treeGrid.getCellByColumn(3, columns[i]);
1041+
GridFunctions.simulateCellKeydown(cell, 'ArrowLeft');
10161042
await wait(DEBOUNCETIME);
10171043
zone.simulateOnStable();
10181044
fix.detectChanges();
10191045
await wait(DEBOUNCETIME);
10201046
zone.simulateOnStable();
10211047
fix.detectChanges();
10221048
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell, false);
1023-
cell = treeGrid.getCellByColumn(0, columns[i + 1]);
1049+
cell = treeGrid.getCellByColumn(3, columns[i - 1]);
10241050
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell);
10251051
}
10261052

1027-
let newCell = treeGrid.getCellByColumn(0, columns[4]);
1028-
GridFunctions.simulateCellKeydown(newCell, 'Home');
1029-
await wait(DEBOUNCETIME);
1030-
zone.simulateOnStable();
1031-
fix.detectChanges();
1032-
await wait(DEBOUNCETIME);
1033-
zone.simulateOnStable();
1053+
expect(treeGrid.headerContainer.getScroll().scrollLeft).toEqual(0);
1054+
});
1055+
1056+
it('should navigate with arrow Right key when there is a pinned column', async () => {
1057+
treeGrid.getColumnByName('HireDate').pinned = true;
10341058
fix.detectChanges();
10351059

1036-
newCell = treeGrid.getCellByColumn(0, columns[0]);
1037-
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, newCell);
1038-
const scrollLeft = treeGrid.headerContainer.getScroll().scrollLeft;
1039-
expect(scrollLeft).toBeGreaterThan(0);
1060+
const columns = ['HireDate', 'ID', 'Name', 'Age', 'OnPTO'];
10401061

1041-
// Test Arrow left
1042-
GridFunctions.simulateCellKeydown(newCell, 'End');
1062+
const firstCell = treeGrid.getCellByColumn(0, 'HireDate');
1063+
GridFunctions.simulateCellKeydown(firstCell, 'End');
10431064
await wait(DEBOUNCETIME);
10441065
zone.simulateOnStable();
10451066
fix.detectChanges();
10461067
await wait(DEBOUNCETIME);
10471068
zone.simulateOnStable();
10481069
fix.detectChanges();
10491070

1050-
newCell = treeGrid.getCellByColumn(0, columns[4]);
1071+
let newCell = treeGrid.getCellByColumn(0, columns[4]);
10511072
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, newCell);
1052-
expect(treeGrid.headerContainer.getScroll().scrollLeft).toEqual(scrollLeft);
1073+
const scrollLeft = treeGrid.headerContainer.getScroll().scrollLeft;
1074+
expect(treeGrid.headerContainer.getScroll().scrollLeft).toBeGreaterThan(0);
10531075

1054-
for (let i = 4; i > 0 ; i--) {
1076+
for (let i = 0; i < columns.length - 1; i++) {
10551077
let cell = treeGrid.getCellByColumn(0, columns[i]);
1056-
GridFunctions.simulateCellKeydown(cell, 'ArrowLeft');
1078+
GridFunctions.simulateCellKeydown(cell, 'ArrowRight');
10571079
await wait(DEBOUNCETIME);
10581080
zone.simulateOnStable();
10591081
fix.detectChanges();
10601082
await wait(DEBOUNCETIME);
10611083
zone.simulateOnStable();
10621084
fix.detectChanges();
10631085
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell, false);
1064-
cell = treeGrid.getCellByColumn(0, columns[i - 1]);
1086+
cell = treeGrid.getCellByColumn(0, columns[i + 1]);
10651087
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell);
10661088
}
10671089

1068-
expect(treeGrid.headerContainer.getScroll().scrollLeft).toEqual(0);
1090+
newCell = treeGrid.getCellByColumn(0, columns[4]);
1091+
GridFunctions.simulateCellKeydown(newCell, 'Home');
1092+
await wait(DEBOUNCETIME);
1093+
zone.simulateOnStable();
1094+
fix.detectChanges();
1095+
await wait(DEBOUNCETIME);
1096+
zone.simulateOnStable();
1097+
fix.detectChanges();
1098+
1099+
newCell = treeGrid.getCellByColumn(0, columns[0]);
1100+
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, newCell);
1101+
expect(treeGrid.headerContainer.getScroll().scrollLeft).toEqual(scrollLeft);
10691102
});
10701103

10711104
it('should select correct cells after expand/collapse row', async () => {

0 commit comments

Comments
 (0)