Skip to content

Commit bd373d1

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Update pivot tests due to new structure.
1 parent a044c15 commit bd373d1

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid-keyboard-nav.spec.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
66
import { GridFunctions } from '../../test-utils/grid-functions.spec';
77
import { IgxPivotGridMultipleRowComponent } from '../../test-utils/pivot-grid-samples.spec';
88
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
9+
import { IgxPivotRowDimensionHeaderComponent } from './pivot-row-dimension-header.component';
910

1011
const DEBOUNCE_TIME = 250;
1112
const PIVOT_TBODY_CSS_CLASS = '.igx-grid__tbody';
@@ -35,8 +36,10 @@ describe('IgxPivotGrid - Keyboard navigation #pivotGrid', () => {
3536
}));
3637

3738
it('should allow navigating between row headers', () => {
38-
const [firstCell, secondCell] = fixture.debugElement.queryAll(
39-
By.css(`${PIVOT_TBODY_CSS_CLASS} ${PIVOT_ROW_DIMENSION_CONTENT} ${HEADER_CELL_CSS_CLASS}`));
39+
const allGroups = fixture.debugElement.queryAll(
40+
By.directive(IgxPivotRowDimensionHeaderComponent));
41+
const firstCell = allGroups[0];
42+
const secondCell = allGroups.filter(x => x.componentInstance.column.field === 'Country')[0];
4043
UIInteractions.simulateClickAndSelectEvent(firstCell);
4144
fixture.detectChanges();
4245

@@ -52,8 +55,10 @@ describe('IgxPivotGrid - Keyboard navigation #pivotGrid', () => {
5255
});
5356

5457
it('should not go outside of the boundaries of the row dimensions content', () => {
55-
const [firstCell, _, thirdCell] = fixture.debugElement.queryAll(
56-
By.css(`${PIVOT_TBODY_CSS_CLASS} ${PIVOT_ROW_DIMENSION_CONTENT} ${HEADER_CELL_CSS_CLASS}`));
58+
const allGroups = fixture.debugElement.queryAll(
59+
By.directive(IgxPivotRowDimensionHeaderComponent));
60+
const firstCell = allGroups[0];
61+
const thirdCell = allGroups.filter(x => x.componentInstance.column.field === 'Date')[0];
5762
UIInteractions.simulateClickAndSelectEvent(firstCell);
5863
fixture.detectChanges();
5964

@@ -76,8 +81,10 @@ describe('IgxPivotGrid - Keyboard navigation #pivotGrid', () => {
7681
});
7782

7883
it('should allow navigating from first to last row headers in a row(Home/End)', () => {
79-
const [firstCell, _, thirdCell] = fixture.debugElement.queryAll(
80-
By.css(`${PIVOT_TBODY_CSS_CLASS} ${PIVOT_ROW_DIMENSION_CONTENT} ${HEADER_CELL_CSS_CLASS}`));
84+
const allGroups = fixture.debugElement.queryAll(
85+
By.directive(IgxPivotRowDimensionHeaderComponent));
86+
const firstCell = allGroups[0];
87+
const thirdCell = allGroups.filter(x => x.componentInstance.column.field === 'Date')[0];
8188
UIInteractions.simulateClickAndSelectEvent(firstCell);
8289
fixture.detectChanges();
8390

@@ -95,17 +102,18 @@ describe('IgxPivotGrid - Keyboard navigation #pivotGrid', () => {
95102
});
96103

97104
it('should allow navigating from first to last row headers(Ctrl + ArrowDown)', () => {
98-
const [_firstCell, _secondCell, thirdCell] = fixture.debugElement.queryAll(
99-
By.css(`${PIVOT_TBODY_CSS_CLASS} ${PIVOT_ROW_DIMENSION_CONTENT} ${HEADER_CELL_CSS_CLASS}`));
105+
let allGroups = fixture.debugElement.queryAll(
106+
By.directive(IgxPivotRowDimensionHeaderComponent));
107+
const thirdCell = allGroups.filter(x => x.componentInstance.column.field === 'Date')[0];
100108
UIInteractions.simulateClickAndSelectEvent(thirdCell);
101109
fixture.detectChanges();
102110

103111
UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', thirdCell.nativeElement, true, false, false, true);
104112
fixture.detectChanges();
105113

106-
const allCells = fixture.debugElement.queryAll(
107-
By.css(`${PIVOT_TBODY_CSS_CLASS} ${PIVOT_ROW_DIMENSION_CONTENT} ${HEADER_CELL_CSS_CLASS}`));
108-
const lastCell = allCells[allCells.length - 1];
114+
allGroups = fixture.debugElement.queryAll(
115+
By.directive(IgxPivotRowDimensionHeaderComponent));
116+
const lastCell = allGroups[allGroups.length - 1];
109117
GridFunctions.verifyHeaderIsFocused(lastCell.parent);
110118
const activeCells = fixture.debugElement.queryAll(By.css(`${ACTIVE_CELL_CSS_CLASS}`));
111119
expect(activeCells.length).toBe(1);

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IgxPivotGridTestBaseComponent, IgxPivotGridTestComplexHierarchyComponen
99
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
1010
import { PivotDimensionType } from './pivot-grid.interface';
1111
import { IgxPivotHeaderRowComponent } from './pivot-header-row.component';
12+
import { IgxPivotRowDimensionHeaderComponent } from './pivot-row-dimension-header.component';
1213
const CSS_CLASS_DROP_DOWN_BASE = 'igx-drop-down';
1314
const CSS_CLASS_LIST = 'igx-drop-down__list';
1415
const CSS_CLASS_ITEM = 'igx-drop-down__item';
@@ -226,7 +227,9 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
226227
const rows = pivotGrid.rowList.toArray();
227228
expect(rows.length).toBe(3);
228229
const expectedHeaders = ['All', 'Clothing', 'Components'];
229-
const rowDimensionHeaders = rows.map(x => x.rowDimension).flat().map(x => x.header);
230+
const rowHeaders = fixture.debugElement.queryAll(
231+
By.directive(IgxPivotRowDimensionHeaderComponent));
232+
const rowDimensionHeaders = rowHeaders.map(x => x.componentInstance.column.header);
230233
expect(rowDimensionHeaders).toEqual(expectedHeaders);
231234
});
232235

@@ -266,16 +269,18 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
266269
const rowChip = headerRow.querySelector('igx-chip[id="All"]');
267270
rowChip.click();
268271
fixture.detectChanges();
269-
let rows = pivotGrid.rowList.toArray();
272+
let rowHeaders = fixture.debugElement.queryAll(
273+
By.directive(IgxPivotRowDimensionHeaderComponent));
270274
let expectedOrder = ['All', 'Accessories', 'Bikes', 'Clothing', 'Components'];
271-
let rowDimensionHeaders = rows.map(x => x.rowDimension).flat().map(x => x.header);
275+
let rowDimensionHeaders = rowHeaders.map(x => x.componentInstance.column.header);
272276
expect(rowDimensionHeaders).toEqual(expectedOrder);
273277

274278
rowChip.click();
275279
fixture.detectChanges();
276-
rows = pivotGrid.rowList.toArray();
277280
expectedOrder = ['All', 'Components', 'Clothing', 'Bikes', 'Accessories'];
278-
rowDimensionHeaders = rows.map(x => x.rowDimension).flat().map(x => x.header);
281+
rowHeaders = fixture.debugElement.queryAll(
282+
By.directive(IgxPivotRowDimensionHeaderComponent));
283+
rowDimensionHeaders = rowHeaders.map(x => x.componentInstance.column.header);
279284
expect(rowDimensionHeaders).toEqual(expectedOrder);
280285
});
281286

@@ -534,9 +539,6 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
534539
expect(rowChipArea.chipsList.toArray()[1]).toBe(rowChip1);
535540
// check dimension order is updated.
536541
expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['SellerName', 'ProductCategory']);
537-
// check rows reflect new order of dims
538-
expect(pivotGrid.gridAPI.get_row_by_index(0).rowDimensionData.map(x => x.dimension.memberName))
539-
.toEqual(['SellerName', 'ProductCategory']);
540542
});
541543

542544
it('should allow reorder in column chip area.', () => {
@@ -781,8 +783,10 @@ describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {
781783
const pivotGrid = fixture.componentInstance.pivotGrid;
782784
const pivotRows = GridFunctions.getPivotRows(fixture);
783785
const row = pivotRows[2].componentInstance;
784-
const headers = row.nativeElement.querySelectorAll('igx-pivot-row-dimension-header-group');
785-
headers[1].click();
786+
const rowHeaders = fixture.debugElement.queryAll(
787+
By.directive(IgxPivotRowDimensionHeaderComponent));
788+
const secondDimCell = rowHeaders.find(x => x.componentInstance.column.header === 'Clothing');
789+
secondDimCell.nativeElement.click();
786790
fixture.detectChanges();
787791
expect(row.selected).toBeTrue();
788792
expect(pivotGrid.selectedRows).not.toBeNull();
@@ -798,7 +802,7 @@ describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {
798802
expect(pivotGrid.selectedRows[0]).toEqual(expected);
799803

800804
//deselect
801-
headers[1].click();
805+
secondDimCell.nativeElement.click();
802806
fixture.detectChanges();
803807
expect(row.selected).toBeFalse();
804808
expect(pivotGrid.selectedRows.length).toBe(0);
@@ -809,8 +813,10 @@ describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {
809813
const pivotGrid = fixture.componentInstance.pivotGrid;
810814
const pivotRows = GridFunctions.getPivotRows(fixture);
811815
const row = pivotRows[2].componentInstance;
812-
const headers = row.nativeElement.querySelectorAll('igx-pivot-row-dimension-header-group');
813-
headers[0].click();
816+
const rowHeaders = fixture.debugElement.queryAll(
817+
By.directive(IgxPivotRowDimensionHeaderComponent));
818+
const firstDimCell = rowHeaders.find(x => x.componentInstance.column.header === 'All Cities');
819+
firstDimCell.nativeElement.click();
814820
fixture.detectChanges();
815821
for (let i = 0; i < 5; ++i) {
816822
expect(pivotRows[i].componentInstance.selected).toBeTrue();

0 commit comments

Comments
 (0)