Skip to content

Commit 9e4a82c

Browse files
committed
test(mdv): adding cell selection test #5880
1 parent eaaa95c commit 9e4a82c

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

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

+45-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IgxGridModule } from './index';
88
import { IgxGridComponent } from './grid.component';
99
import { IgxGridRowComponent } from './grid-row.component';
1010
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
11-
import { GridFunctions } from '../../test-utils/grid-functions.spec';
11+
import { GridFunctions, GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
1212
import { IgxGridExpandableCellComponent } from './expandable-cell.component';
1313

1414
const COLLAPSED_ICON_NAME = 'chevron_right';
@@ -325,6 +325,7 @@ describe('IgxGrid Master Detail #grid', () => {
325325
fix.detectChanges();
326326
expect(grid.rowList.first.cells.first instanceof IgxGridExpandableCellComponent).toBeTruthy();
327327
});
328+
328329
it('Should keep the expand/collapse icon in the first column, even when moving a column out of first place.', () => {
329330
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
330331
grid = fix.componentInstance.grid;
@@ -334,6 +335,49 @@ describe('IgxGrid Master Detail #grid', () => {
334335
expect(grid.rowList.first.cells.first instanceof IgxGridExpandableCellComponent).toBeTruthy();
335336
});
336337
});
338+
339+
describe('Cell Selection', () => {
340+
it('Should exclude expanded detail views when doing range cell selection', () => {
341+
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
342+
grid = fix.componentInstance.grid;
343+
fix.detectChanges();
344+
grid.expand(fix.componentInstance.data[2].ID);
345+
const selectionChangeSpy = spyOn<any>(grid.onRangeSelection, 'emit').and.callThrough();
346+
const startCell = grid.getCellByColumn(1, 'ContactName');
347+
const endCell = grid.getCellByColumn(6, 'CompanyName');
348+
const range = { rowStart: 1, rowEnd: 6, columnStart: 0, columnEnd: 1 };
349+
350+
UIInteractions.simulatePointerOverCellEvent('pointerdown', startCell.nativeElement);
351+
startCell.nativeElement.dispatchEvent(new Event('focus'));
352+
grid.cdr.detectChanges();
353+
354+
expect(startCell.focused).toBe(true);
355+
356+
const rowDetail = GridFunctions.getMasterRowDetail(grid.rowList.toArray()[2]);
357+
358+
for (let i = 2; i < 6; i++) {
359+
const cell = grid.getCellByColumn(i, 'ContactName');
360+
if (!cell) {
361+
UIInteractions.simulatePointerOverCellEvent('pointerenter',
362+
fix.debugElement.query(By.css('.addressArea')).nativeElement);
363+
continue;
364+
}
365+
UIInteractions.simulatePointerOverCellEvent('pointerenter', cell.nativeElement);
366+
grid.cdr.detectChanges();
367+
}
368+
UIInteractions.simulatePointerOverCellEvent('pointerenter', endCell.nativeElement);
369+
UIInteractions.simulatePointerOverCellEvent('pointerup', endCell.nativeElement);
370+
GridSelectionFunctions.verifyCellsRegionSelected(grid, 1, 2, 0, 1, true);
371+
GridSelectionFunctions.verifyCellsRegionSelected(grid, 4, 5, 0, 1, true);
372+
grid.cdr.detectChanges();
373+
374+
expect(startCell.focused).toBe(true);
375+
376+
expect(selectionChangeSpy).toHaveBeenCalledTimes(1);
377+
expect(selectionChangeSpy).toHaveBeenCalledWith(range);
378+
expect(rowDetail.querySelector('[class*="selected"]')).toBeNull();
379+
});
380+
});
337381
});
338382
});
339383

0 commit comments

Comments
 (0)