Skip to content

Commit 109c9db

Browse files
committed
fix test after review
1 parent c8ab439 commit 109c9db

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

e2e/testcafe-devextreme/tests/dataGrid/common/markup/T1163515_alternateRowGroupBorders.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import url from '../../../../helpers/getPageUrl';
66
fixture.disablePageReloads`Grouping Panel - check borders and backgrounds with various options`
77
.page(url(__dirname, '../../../container.html'));
88

9-
const GRID_SELECTOR = '#container';
9+
const SELECTORS = {
10+
gridContainer: 'container',
11+
masterDetailClass: 'dx-master-detail-row',
12+
groupRowClass: 'dx-group-row',
13+
};
1014

1115
const FORBIDDEN_COLORS = ['transparent', 'white', 'black', 'rgb(0, 0, 0)', 'rgb(255, 255, 255)'];
1216

@@ -172,20 +176,37 @@ const verifyGridStyles = async (t, dataGrid, matrixOptions) => {
172176
}
173177

174178
if (matrixOptions.rowAlternationEnabled) {
175-
const rows = dataGrid.getRows();
176-
for (let i = 1; i < rows.length; i += 1) {
177-
const currentRow = rows.nth(i);
178-
const previousRow = rows.nth(i - 1);
179+
const filteredRows = dataGrid.getRows().find(`tr:not(.${SELECTORS.masterDetailClass})`);
180+
const filteredRowsLength = await filteredRows.count;
181+
182+
let i = 1;
183+
while (i < filteredRowsLength) {
184+
const currentRow = filteredRows.nth(i);
185+
const previousRow = filteredRows.nth(i - 1);
179186

180187
const currentClasses = await currentRow.getAttribute('class');
181188
const previousClasses = await previousRow.getAttribute('class');
182189

183-
if (currentClasses === previousClasses) {
190+
if (currentClasses?.includes(SELECTORS.groupRowClass)) {
191+
i += 2;
192+
// eslint-disable-next-line no-continue
193+
continue;
194+
}
195+
196+
if (previousClasses?.includes(SELECTORS.groupRowClass)) {
197+
i += 1;
198+
// eslint-disable-next-line no-continue
199+
continue;
200+
}
201+
202+
if (currentClasses !== previousClasses) {
184203
const currentBg = await currentRow.getStyleProperty('background-color');
185204
const previousBg = await previousRow.getStyleProperty('background-color');
186205

187206
await t.expect(currentBg).notEql(previousBg);
188207
}
208+
209+
i += 1;
189210
}
190211
}
191212

@@ -213,7 +234,7 @@ const verifyGridStyles = async (t, dataGrid, matrixOptions) => {
213234
}
214235

215236
if (matrixOptions.showColumnLines) {
216-
const cells = dataGrid.getCells();
237+
const cells = dataGrid.getCells().find('td:not([class])');
217238
const cellsCount = await cells.count;
218239

219240
for (let i = 0; i < cellsCount; i += 1) {
@@ -230,7 +251,7 @@ const verifyGridStyles = async (t, dataGrid, matrixOptions) => {
230251

231252
const functionalTest = (matrixOptions) => {
232253
test(`Should have correct applied styles with ${getTestParams(matrixOptions)}`, async (t) => {
233-
const dataGrid = new DataGrid(GRID_SELECTOR);
254+
const dataGrid = new DataGrid(`#${SELECTORS.gridContainer}`);
234255
await dataGrid.isReady();
235256

236257
await verifyGridStyles(t, dataGrid, matrixOptions);
@@ -249,8 +270,6 @@ const functionalTest = (matrixOptions) => {
249270
});
250271
};
251272

252-
// visual: generic.light
253-
// visual: material.blue.light
254273
[true, false].forEach((hasFixedColumn) => {
255274
[true, false].forEach((hasMasterDetail) => {
256275
[true, false].forEach((rowAlternationEnabled) => {

packages/testcafe-models/dataGrid/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ export default class DataGrid extends GridCore {
164164
}
165165

166166
getRows(): Selector {
167-
return this.element.find(`.${CLASS.row}`);
167+
return this.getRowsView().find(`.${CLASS.row}`);
168168
}
169169

170170
getCells(): Selector {
171-
return this.getRowsView().find('td:not([class])');
171+
return this.getRowsView().find('td');
172172
}
173173

174174
getDataRow(index: number): DataRow {

0 commit comments

Comments
 (0)