Skip to content

Commit e22ced5

Browse files
committed
test(grid-pinning): Add tests for navigation to/from pinned area #6676
1 parent b36b75e commit e22ced5

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

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

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('IgxGrid - Column Pinning #grid', () => {
2323
const FIXED_HEADER_CSS = 'igx-grid__th--pinned';
2424
const FIXED_CELL_CSS = 'igx-grid__td--pinned';
2525
const FIRST_PINNED_CELL_CSS = 'igx-grid__td--pinned-first';
26+
const DEBOUNCETIME = 30;
2627

2728
describe('To Start', () => {
2829
configureTestSuite();
@@ -417,6 +418,41 @@ describe('IgxGrid - Column Pinning #grid', () => {
417418
expect(grid.pinnedColumns.length).toEqual(1);
418419
expect(grid.unpinnedColumns.length).toEqual(2);
419420
}));
421+
422+
it('should allow navigating to/from pinned area', (async() => {
423+
pending('https://github.com/IgniteUI/igniteui-angular/pull/6910');
424+
const fix = TestBed.createComponent(DefaultGridComponent);
425+
fix.detectChanges();
426+
const grid = fix.componentInstance.instance;
427+
428+
const cellContactName = grid.getCellByColumn(0, 'ContactName');
429+
const range = {
430+
rowStart: cellContactName.rowIndex,
431+
rowEnd: cellContactName.rowIndex,
432+
columnStart: cellContactName.visibleColumnIndex,
433+
columnEnd: cellContactName.visibleColumnIndex
434+
};
435+
grid.selectRange(range);
436+
grid.navigation.activeNode = {row: cellContactName.rowIndex, column: cellContactName.visibleColumnIndex};
437+
fix.detectChanges();
438+
439+
const keydownArrowRightEvent = new KeyboardEvent('keydown', {key: 'ArrowRight'});
440+
grid.navigation.dispatchEvent(keydownArrowRightEvent);
441+
await wait(DEBOUNCETIME);
442+
fix.detectChanges();
443+
444+
const cellID = grid.getCellByColumn(0, 'ID');
445+
expect(cellID.active).toBe(true);
446+
expect(cellContactName.active).toBe(false);
447+
448+
const keydownArrowLeftEvent = new KeyboardEvent('keydown', {key: 'ArrowLeft'});
449+
grid.navigation.dispatchEvent(keydownArrowLeftEvent);
450+
await wait(DEBOUNCETIME);
451+
fix.detectChanges();
452+
453+
expect(cellID.active).toBe(false);
454+
expect(cellContactName.active).toBe(true);
455+
}));
420456
});
421457

422458
describe('To End', () => {
@@ -639,6 +675,65 @@ describe('IgxGrid - Column Pinning #grid', () => {
639675
expect(fistPinnedHeaders.classes['igx-grid__mrl-block']).toBeTruthy();
640676
expect(fistPinnedHeaders.classes['igx-grid__th--pinned-first']).toBeTruthy();
641677
});
678+
679+
it('should allow navigating to/from pinned area', (async() => {
680+
pending('https://github.com/IgniteUI/igniteui-angular/pull/6910');
681+
const fix = TestBed.createComponent(GridRightPinningComponent);
682+
fix.detectChanges();
683+
const grid = fix.componentInstance.instance as any;
684+
685+
const cellCompanyName = grid.getCellByColumn(0, 'CompanyName');
686+
const range = { rowStart: 0, rowEnd: 0, columnStart: 9, columnEnd: 9 };
687+
grid.selectRange(range);
688+
grid.navigation.activeNode = {row: 0, column: 9};
689+
fix.detectChanges();
690+
expect(cellCompanyName.active).toBe(true);
691+
692+
const keydownArrowLeftEvent = new KeyboardEvent('keydown', {key: 'ArrowLeft'});
693+
grid.navigation.dispatchEvent(keydownArrowLeftEvent);
694+
await wait(DEBOUNCETIME);
695+
fix.detectChanges();
696+
const cellFax = grid.getCellByColumn(0, 'Fax');
697+
expect(cellFax.active).toBe(true);
698+
expect(cellCompanyName.active).toBe(false);
699+
700+
const keydownArrowRightEvent = new KeyboardEvent('keydown', {key: 'ArrowRight'});
701+
grid.navigation.dispatchEvent(keydownArrowRightEvent);
702+
await wait(DEBOUNCETIME);
703+
fix.detectChanges();
704+
expect(cellFax.active).toBe(false);
705+
expect(cellCompanyName.active).toBe(true);
706+
}));
707+
708+
it('should allow navigating to/from pinned area using Ctrl+Left/Right', (async() => {
709+
pending('https://github.com/IgniteUI/igniteui-angular/pull/6910');
710+
const fix = TestBed.createComponent(GridRightPinningComponent);
711+
fix.detectChanges();
712+
const grid = fix.componentInstance.instance as any;
713+
714+
const cellCompanyName = grid.getCellByColumn(0, 'CompanyName');
715+
const range = { rowStart: 0, rowEnd: 0, columnStart: 9, columnEnd: 9 };
716+
grid.selectRange(range);
717+
grid.navigation.activeNode = {row: 0, column: 9};
718+
fix.detectChanges();
719+
expect(cellCompanyName.active).toBe(true);
720+
721+
const keydownArrowLeftEvent = new KeyboardEvent('keydown', {key: 'ArrowLeft', ctrlKey: true});
722+
grid.navigation.dispatchEvent(keydownArrowLeftEvent);
723+
await wait(DEBOUNCETIME);
724+
fix.detectChanges();
725+
const cellID = grid.getCellByColumn(0, 'ID');
726+
expect(cellID.active).toBe(true);
727+
expect(cellCompanyName.active).toBe(false);
728+
729+
const keydownArrowRightEvent = new KeyboardEvent('keydown', {key: 'ArrowRight', ctrlKey: true});
730+
grid.navigation.dispatchEvent(keydownArrowRightEvent);
731+
await wait(DEBOUNCETIME);
732+
fix.detectChanges();
733+
const cellContactName = grid.getCellByColumn(0, 'ContactName');
734+
expect(cellID.active).toBe(false);
735+
expect(cellContactName.active).toBe(true);
736+
}));
642737
});
643738
});
644739

0 commit comments

Comments
 (0)