Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update treeGrid Keyboard navigation tests - 6.2.x #2973

Merged
merged 2 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ describe('IgxTreeGrid - Key Board Navigation', () => {

UIInteractions.triggerKeyDownEvtUponElem('Enter', cell.nativeElement, true);
await wait(DEBOUNCETIME);
expect(cell.inEditMode).toBe(true);
fix.detectChanges();

cell = treeGrid.getCellByColumn(5, 'OnPTO');
expect(cell.inEditMode).toBe(true);
// Press tab key and verify the correct cell is opened
await TreeGridFunctions.moveEditableCellWithTab(fix, treeGrid, 5, 4, treeColumns);
});
Expand All @@ -310,7 +312,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
await testNavigationTab(fix, treeGrid, ['HireDate', 'ID', 'Name', 'Age', 'OnPTO']);
});

it('should change correct selected cell when there are pinned columns and press tab', async () => {
it('should change correct selected cell when there are pinned columns and press shift + tab', async () => {
treeGrid.getColumnByName('HireDate').pinned = true;
fix.detectChanges();

Expand Down Expand Up @@ -338,7 +340,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell);

UIInteractions.triggerKeyDownEvtUponElem('Space', cell.nativeElement, true);
await wait(30);
await wait(DEBOUNCETIME);
fix.detectChanges();

TreeGridFunctions.verifyDataRowsSelection(fix, [0], true);
Expand Down Expand Up @@ -620,7 +622,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(1);

cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'End', ctrlKey: true }));
await wait(DEBOUNCETIME);
await wait(100);
fixture.detectChanges();

cell = treegrid.getCellByColumn(9, columns[columns.length - 1]);
Expand All @@ -629,7 +631,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(2);

cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Home', ctrlKey: true }));
await wait(DEBOUNCETIME);
await wait(100);
fixture.detectChanges();

cell = treegrid.getCellByColumn(0, columns[0]);
Expand All @@ -638,7 +640,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
expect(treegrid.onSelection.emit).toHaveBeenCalledTimes(3);

cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'End', ctrlKey: true }));
await wait(DEBOUNCETIME);
await wait(100);
fixture.detectChanges();

cell = treegrid.getCellByColumn(9, columns[columns.length - 1]);
Expand Down Expand Up @@ -735,7 +737,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
(fixture, treegrid: IgxTreeGridComponent, cellRowIndex, cellColumn, rowsCount, rowsCountAfterCollapse) =>
new Promise(async (resolve, reject) => {
spyOn(treegrid.onRowToggle, 'emit').and.callThrough();
const cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
let cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
let rows = TreeGridFunctions.getAllRows(fixture);
expect(rows.length).toBe(rowsCount);

Expand All @@ -750,6 +752,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
await wait(DEBOUNCETIME);
fixture.detectChanges();

cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
rows = TreeGridFunctions.getAllRows(fixture);
expect(rows.length).toBe(rowsCountAfterCollapse);
TreeGridFunctions.verifyTreeRowHasCollapsedIcon(rows[cellRowIndex]);
Expand All @@ -761,6 +764,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
await wait(DEBOUNCETIME);
fixture.detectChanges();

cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
rows = TreeGridFunctions.getAllRows(fixture);
expect(rows.length).toBe(rowsCountAfterCollapse);
TreeGridFunctions.verifyTreeRowHasCollapsedIcon(rows[cellRowIndex]);
Expand All @@ -772,6 +776,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
await wait(DEBOUNCETIME);
fixture.detectChanges();

cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
rows = TreeGridFunctions.getAllRows(fixture);
expect(rows.length).toBe(rowsCount);
TreeGridFunctions.verifyTreeRowHasExpandedIcon(rows[cellRowIndex]);
Expand All @@ -783,6 +788,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
await wait(DEBOUNCETIME);
fixture.detectChanges();

cell = treegrid.getCellByColumn(cellRowIndex, cellColumn);
rows = TreeGridFunctions.getAllRows(fixture);
expect(rows.length).toBe(rowsCount);
TreeGridFunctions.verifyTreeRowHasExpandedIcon(rows[cellRowIndex]);
Expand All @@ -794,7 +800,7 @@ describe('IgxTreeGrid - Key Board Navigation', () => {

const testEditingNavigationTab =
(fixture, treegrid: IgxTreeGridComponent, columns) => new Promise(async (resolve, reject) => {
const cell = treegrid.getCellByColumn(2, columns[2]);
let cell = treegrid.getCellByColumn(2, columns[2]);

cell.nativeElement.dispatchEvent(new Event('focus'));
await wait(DEBOUNCETIME);
Expand All @@ -805,6 +811,8 @@ describe('IgxTreeGrid - Key Board Navigation', () => {
UIInteractions.triggerKeyDownEvtUponElem('Enter', cell.nativeElement, true);
await wait(DEBOUNCETIME);
fixture.detectChanges();

cell = treeGrid.getCellByColumn(2, columns[2]);
expect(cell.inEditMode).toBe(true);

// Test tab on child row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,18 @@ export class TreeGridFunctions {
firstColumnName: string,
nextColumnName: string,
moveRight: boolean = true) => new Promise(async (resolve, reject) => {
const cell = treeGrid.getCellByColumn(rowIndex, firstColumnName);
let cell = treeGrid.getCellByColumn(rowIndex, firstColumnName);
const keyboardEventKey = moveRight ? 'ArrowRight' : 'ArrowLeft';

UIInteractions.triggerKeyDownEvtUponElem(keyboardEventKey, cell.nativeElement, true);
await wait(DEBOUNCETIME);
fix.detectChanges();

const newCell = treeGrid.getCellByColumn(rowIndex, nextColumnName);
cell = treeGrid.getCellByColumn(rowIndex, firstColumnName);
if (cell !== undefined && cell !== null) {
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell, false);
}
const newCell = treeGrid.getCellByColumn(rowIndex, nextColumnName);
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, newCell);
expect(newCell.focused).toEqual(true);

Expand All @@ -361,14 +362,16 @@ export class TreeGridFunctions {
fix.detectChanges();

cell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex]);
if (cell !== undefined && cell !== null) {
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell, false);
}

if (columnIndex === columns.length - 1) {
newCell = treeGrid.getCellByColumn(rowIndex + 1, columns[0]);
} else {
newCell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex + 1]);
}
if (cell !== undefined && cell !== null) {
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell, false);
}

TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, newCell);
expect(newCell.focused).toEqual(true);

Expand Down Expand Up @@ -415,15 +418,15 @@ export class TreeGridFunctions {
fix.detectChanges();

cell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex]);
if (cell !== undefined && cell !== null) {
expect(cell.inEditMode).toBe(false);
}
if (columnIndex === columns.length - 1) {
newCell = treeGrid.getCellByColumn(rowIndex + 1, columns[0]);
} else {
newCell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex + 1]);
}

if (cell !== undefined && cell !== null) {
expect(cell.inEditMode).toBe(false);
}
expect(newCell.inEditMode).toBe(true);
resolve();
})
Expand All @@ -441,15 +444,15 @@ export class TreeGridFunctions {
fix.detectChanges();

cell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex]);
if (cell !== undefined && cell !== null) {
expect(cell.inEditMode).toBe(false);
}
if (columnIndex === 0) {
newCell = treeGrid.getCellByColumn(rowIndex - 1, columns[columns.length - 1]);
} else {
newCell = treeGrid.getCellByColumn(rowIndex, columns[columnIndex - 1]);
}

if (cell !== undefined && cell !== null) {
expect(cell.inEditMode).toBe(false);
}
expect(newCell.inEditMode).toBe(true);
resolve();
})
Expand Down