Skip to content

Commit 315d43c

Browse files
authored
Merge pull request #5695 from IgniteUI/nrobakova/hgrid-rowSelection-tests
Implement row selection tests for hGrid
2 parents 18e984b + 54f6405 commit 315d43c

13 files changed

+676
-93
lines changed

projects/igniteui-angular/src/lib/core/grid-selection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export class IgxGridSelectionService {
559559
selectAllRows(event?) {
560560
const allRowIDs = this.getRowIDs(this.allData);
561561
const addedRows = allRowIDs.filter((rID) => !this.isRowSelected(rID));
562-
const newSelection = this.rowSelection.size ? allRowIDs.concat(this.getSelectedRows()) : addedRows;
562+
const newSelection = this.rowSelection.size ? this.getSelectedRows().concat(addedRows) : addedRows;
563563

564564
this.emitRowSelectionEvent(newSelection, addedRows, [], event);
565565
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,12 @@ describe('IgxGrid - Cell selection #grid', () => {
144144
});
145145

146146
it('Should select correct cells with Ctrl key and mouse drag', () => {
147-
pending('Related to the bug 4084');
148147
const range = { rowStart: 3, rowEnd: 2, columnStart: 'Name', columnEnd: 'ParentID' };
149148
const firstCell = grid.getCellByColumn(1, 'ParentID');
150149
const secondCell = grid.getCellByColumn(1, 'ID');
151150
const thirdCell = grid.getCellByColumn(2, 'ParentID');
152151
const expectedData = [
153-
{ ParentID: 147, Name: 'Michael Langdon' },
152+
{ ParentID: 147, Name: 'Monica Reyes' },
154153
{ ParentID: 847, Name: 'Laurence Johnson' },
155154
{ ParentID: 147 }
156155
];

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
136136
displayContainer.dispatchEvent(event);
137137
await wait(300);
138138

139-
expect(firstCell.isSelected).toBeFalsy();
140139
expect(firstCell.selected).toBeFalsy();
141140
expect(firstCell.focused).toBeFalsy();
142141
}));
@@ -163,15 +162,15 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
163162
fix.detectChanges();
164163

165164
expect(cell.selected).toBeTruthy();
166-
expect(secondRow.isSelected).toBeTruthy();
165+
expect(secondRow.selected).toBeTruthy();
167166
expect(secondRowCheckbox.classList.contains('igx-checkbox--checked')).toBeTruthy();
168167

169168
UIInteractions.triggerKeyDownEvtUponElem('space', cell.nativeElement, true);
170169
await wait(DEBOUNCETIME);
171170
fix.detectChanges();
172171

173172
expect(cell.selected).toBeTruthy();
174-
expect(secondRow.isSelected).toBeFalsy();
173+
expect(secondRow.selected).toBeFalsy();
175174
expect(secondRowCheckbox.classList.contains('igx-checkbox--checked')).toBeFalsy();
176175

177176
cell = grid.getCellByColumn(1, 'ID');
@@ -189,15 +188,15 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
189188
await wait(DEBOUNCETIME);
190189
fix.detectChanges();
191190

192-
expect(firstRow.isSelected).toBeTruthy();
191+
expect(firstRow.selected).toBeTruthy();
193192
expect(firstRowCheckbox.classList.contains('igx-checkbox--checked')).toBeTruthy();
194193

195194
UIInteractions.triggerKeyDownEvtUponElem('space', cell.nativeElement, true);
196195
await wait(DEBOUNCETIME);
197196
fix.detectChanges();
198197

199198
expect(cell.selected).toBeTruthy();
200-
expect(firstRow.isSelected).toBeFalsy();
199+
expect(firstRow.selected).toBeFalsy();
201200
expect(firstRowCheckbox.classList.contains('igx-checkbox--checked')).toBeFalsy();
202201

203202
UIInteractions.triggerKeyDownWithBlur('tab', cell.nativeElement, true);

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('IgxGrid - Row Selection #grid', () => {
5555

5656
it('Should have checkbox on each row', (async () => {
5757
HelperUtils.verifyHeaderRowHasCheckbox(fix);
58-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
58+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
5959

6060
for (const row of grid.rowList.toArray()) {
6161
HelperUtils.verifyRowHasCheckbox(row.nativeElement);
@@ -65,7 +65,7 @@ describe('IgxGrid - Row Selection #grid', () => {
6565
await wait(100);
6666
fix.detectChanges();
6767

68-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
68+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
6969

7070
for (const row of grid.rowList.toArray()) {
7171
HelperUtils.verifyRowHasCheckbox(row.nativeElement);
@@ -104,19 +104,19 @@ describe('IgxGrid - Row Selection #grid', () => {
104104
it('Should have correct checkboxes position when scroll left', (async () => {
105105
grid.width = '300px';
106106
fix.detectChanges();
107-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
107+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
108108

109109
GridFunctions.scrollLeft(grid, 1000);
110110
await wait(100);
111111
fix.detectChanges();
112112

113-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
113+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
114114

115115
GridFunctions.scrollLeft(grid, 0);
116116
await wait(100);
117117
fix.detectChanges();
118118

119-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
119+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
120120
}));
121121

122122
it('Header checkbox should select/deselect all rows', () => {
@@ -483,7 +483,7 @@ describe('IgxGrid - Row Selection #grid', () => {
483483
HelperUtils.verifyRowSelected(firstRow, false);
484484
HelperUtils.verifyHeaderRowHasCheckbox(fix, false);
485485
HelperUtils.verifyRowHasCheckbox(firstRow.nativeElement);
486-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
486+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
487487

488488
// Click on a row
489489
UIInteractions.simulateClickEvent(firstRow.nativeElement);
@@ -646,7 +646,7 @@ describe('IgxGrid - Row Selection #grid', () => {
646646
grid = fix.componentInstance.grid;
647647
}));
648648

649-
it('Change RowSelection to multiple ', () => {
649+
it('Change RowSelection to multiple ', () => {
650650
HelperUtils.verifyHeaderRowHasCheckbox(fix, false, false);
651651
HelperUtils.verifyRowHasCheckbox(grid.getRowByIndex(0).nativeElement, false, false);
652652

@@ -658,7 +658,7 @@ describe('IgxGrid - Row Selection #grid', () => {
658658
grid.rowSelection = GridSelectionMode.multiple;
659659
fix.detectChanges();
660660

661-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
661+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
662662
HelperUtils.verifyRowSelected(grid.getRowByIndex(0), false, false);
663663
HelperUtils.verifyHeaderRowCheckboxState(fix);
664664
HelperUtils.verifyHeaderRowHasCheckbox(fix);
@@ -678,7 +678,7 @@ describe('IgxGrid - Row Selection #grid', () => {
678678

679679
it('Should have checkbox on each row nd do not have header checkbox', (async () => {
680680
HelperUtils.verifyHeaderRowHasCheckbox(fix, false);
681-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
681+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
682682

683683
for (const row of grid.rowList.toArray()) {
684684
HelperUtils.verifyRowHasCheckbox(row.nativeElement);
@@ -689,7 +689,7 @@ describe('IgxGrid - Row Selection #grid', () => {
689689
fix.detectChanges();
690690

691691
HelperUtils.verifyHeaderRowHasCheckbox(fix, false);
692-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
692+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
693693

694694
for (const row of grid.rowList.toArray()) {
695695
HelperUtils.verifyRowHasCheckbox(row.nativeElement);
@@ -958,7 +958,7 @@ describe('IgxGrid - Row Selection #grid', () => {
958958
HelperUtils.verifyRowSelected(firstRow, false);
959959
HelperUtils.verifyHeaderRowHasCheckbox(fix);
960960
HelperUtils.verifyRowHasCheckbox(firstRow.nativeElement);
961-
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(fix, grid);
961+
HelperUtils.verifyHeaderAndRowCheckBoxesAlignment(grid);
962962

963963
// Click on a row
964964
UIInteractions.simulateClickEvent(firstRow.nativeElement);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ describe('IgxGrid - search API #grid', () => {
528528
});
529529

530530
it('Highlight should be updated when a column is hidden and there are other hidden columns', () => {
531-
pending('Related to the bug 3691');
532531
grid.columns[1].hidden = true;
533532
fix.detectChanges();
534533

projects/igniteui-angular/src/lib/grids/grid/row-drag.directive.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
593593
const dragIndicatorElement = dragIndicatorElements[2].nativeElement;
594594
const row = dragGridRows[1];
595595
const rowDragDirective = dragRows[1].injector.get(IgxRowDragDirective);
596-
expect(row.isSelected).toBeTruthy();
596+
expect(row.selected).toBeTruthy();
597597

598598
const startPoint: Point = UIInteractions.getPointFromElement(dragIndicatorElement);
599599
const movePoint: Point = UIInteractions.getPointFromElement(dragGridRows[4].nativeElement);
@@ -614,7 +614,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
614614
expect(row.grid.rowDragging).toBeFalsy();
615615
verifyRowDragEndEvent(dragGrid, row, rowDragDirective, false);
616616
expect(dropGrid.rowList.length).toEqual(1);
617-
expect(row.isSelected).toBeTruthy();
617+
expect(row.selected).toBeTruthy();
618618
}));
619619
it('should not apply selection class to ghost element when dragging selected grid row', (async () => {
620620
dragGrid.rowSelection = GridSelectionMode.multiple;
@@ -624,7 +624,7 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
624624

625625
const dragIndicatorElement = dragIndicatorElements[2].nativeElement;
626626
const row = dragGridRows[1];
627-
expect(row.isSelected).toBeTruthy();
627+
expect(row.selected).toBeTruthy();
628628

629629
const startPoint: Point = UIInteractions.getPointFromElement(dragIndicatorElement);
630630
const movePoint: Point = UIInteractions.getPointFromElement(dragGridRows[4].nativeElement);

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-cell.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { GridBaseAPIService } from '../api.service';
33
import { ChangeDetectorRef, ElementRef, ChangeDetectionStrategy, Component,
44
OnInit, HostListener, NgZone } from '@angular/core';
55
import { IgxHierarchicalGridComponent } from './hierarchical-grid.component';
6-
import { IgxHierarchicalSelectionAPIService } from './selection';
76
import { IgxGridSelectionService, IgxGridCRUDService } from '../../core/grid-selection';
87
import { HammerGesturesManager } from '../../core/touch';
98

@@ -23,14 +22,12 @@ export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent imple
2322
protected selectionService: IgxGridSelectionService,
2423
protected crudService: IgxGridCRUDService,
2524
public gridAPI: GridBaseAPIService<IgxHierarchicalGridComponent>,
26-
public selection: IgxHierarchicalSelectionAPIService,
2725
public cdr: ChangeDetectorRef,
2826
private helement: ElementRef,
2927
protected zone: NgZone,
3028
touchManager: HammerGesturesManager
3129
) {
3230
super(selectionService, crudService, gridAPI, cdr, helement, zone, touchManager);
33-
this.hSelection = <IgxHierarchicalSelectionAPIService>selection;
3431
}
3532

3633
ngOnInit() {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IgxGridHierarchicalPipe, IgxGridHierarchicalPagingPipe } from './hierar
99
import { IgxRowIslandComponent } from './row-island.component';
1010
import { IgxChildGridRowComponent } from './child-grid-row.component';
1111
import { IgxHierarchicalGridCellComponent } from './hierarchical-cell.component';
12-
import { IgxHierarchicalSelectionAPIService } from './selection';
1312
import { IgxRowIslandAPIService } from './row-island-api.service';
1413
import { IgxSelectModule } from '../../select/index';
1514
import { IgxGridComponent } from '../grid/grid.component';
@@ -44,7 +43,6 @@ import { IgxGridComponent } from '../grid/grid.component';
4443
],
4544
providers: [
4645
IgxRowIslandAPIService,
47-
IgxHierarchicalSelectionAPIService
4846
],
4947
entryComponents: [
5048
IgxGridComponent

0 commit comments

Comments
 (0)