Skip to content

Commit 95aa799

Browse files
authored
DataGrid: fix height when a row is marked deleted (T1286265) (DevExpress#29801)
1 parent e55105d commit 95aa799

File tree

29 files changed

+274
-5
lines changed

29 files changed

+274
-5
lines changed
-134 Bytes
Loading
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
2+
import DataGrid from 'devextreme-testcafe-models/dataGrid';
3+
import { createWidget } from '../../../../helpers/createWidget';
4+
import url from '../../../../helpers/getPageUrl';
5+
import { changeTheme } from '../../../../helpers/changeTheme';
6+
import { Themes } from '../../../../helpers/themes';
7+
8+
fixture.disablePageReloads`DataGrid deleted row height consistency T1286265`
9+
.page(url(__dirname, '../../../container.html'));
10+
11+
const DATA_GRID_SELECTOR = '#container';
12+
const ROW_INDEX = 1;
13+
14+
[
15+
Themes.fluentBlue,
16+
Themes.fluentBlueCompact,
17+
Themes.materialBlue,
18+
Themes.materialBlueCompact,
19+
Themes.genericLight,
20+
Themes.genericLightCompact,
21+
].forEach((theme) => {
22+
test(`When DataGrid has fixed column row height should not change when marked as deleted - ${theme}`, async (t) => {
23+
// Arrange
24+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
25+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
26+
27+
// Get the initial height of the row at index
28+
const initialRow = dataGrid.getDataRow(ROW_INDEX);
29+
const initialRowHeight = await initialRow.element.clientHeight;
30+
31+
// Act - mark the row as deleted
32+
await dataGrid.apiDeleteRow(ROW_INDEX);
33+
34+
// Assert - check if the row is marked as deleted
35+
await t
36+
.expect(dataGrid.getDataRow(ROW_INDEX).isRemoved)
37+
.ok('Row should be marked as deleted');
38+
39+
// Get the height of the deleted row
40+
const deletedRow = dataGrid.getDataRow(ROW_INDEX);
41+
const deletedRowHeight = await deletedRow.element.clientHeight;
42+
43+
// Assert - check if the height remains consistent
44+
await t
45+
.expect(deletedRowHeight)
46+
.eql(initialRowHeight, 'Row height should not change when marked as deleted');
47+
48+
// Take a screenshot for visual verification
49+
await takeScreenshot(`datagrid-deleted-row-height-row-lines-and-fixed-column (${theme}).png`, dataGrid.element);
50+
await t
51+
.expect(compareResults.isValid())
52+
.ok(compareResults.errorMessages());
53+
}).before(async () => {
54+
await changeTheme(theme);
55+
56+
await createWidget('dxDataGrid', {
57+
dataSource: [
58+
{ id: 1, name: 'John Smith' },
59+
{ id: 2, name: 'Jane Johnson' },
60+
{ id: 3, name: 'Mike Wilson' },
61+
],
62+
keyExpr: 'id',
63+
height: 300,
64+
showBorders: true,
65+
showRowLines: true,
66+
columns: [
67+
{ dataField: 'id', width: 50, fixed: true },
68+
{ dataField: 'name', width: 150 },
69+
],
70+
editing: {
71+
mode: 'batch',
72+
allowDeleting: true,
73+
},
74+
});
75+
}).after(async () => {
76+
await changeTheme(Themes.genericLight);
77+
});
78+
79+
test(`When DataGrid doesn't have fixed column row height should not change when marked as deleted - ${theme}`, async (t) => {
80+
// Arrange
81+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
82+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
83+
84+
// Get the initial height of the row at index
85+
const initialRow = dataGrid.getDataRow(ROW_INDEX);
86+
const initialRowHeight = await initialRow.element.clientHeight;
87+
88+
// Act - mark the row as deleted
89+
await dataGrid.apiDeleteRow(ROW_INDEX);
90+
91+
// Assert - check if the row is marked as deleted
92+
await t
93+
.expect(dataGrid.getDataRow(ROW_INDEX).isRemoved)
94+
.ok('Row should be marked as deleted');
95+
96+
// Get the height of the deleted row
97+
const deletedRow = dataGrid.getDataRow(ROW_INDEX);
98+
const deletedRowHeight = await deletedRow.element.clientHeight;
99+
100+
// Assert - check if the height remains consistent
101+
await t
102+
.expect(deletedRowHeight)
103+
.eql(initialRowHeight, 'Row height should not change when marked as deleted');
104+
105+
// Take a screenshot for visual verification
106+
await takeScreenshot(`datagrid-deleted-row-height-row-lines-and-no-fixed-column (${theme}).png`, dataGrid.element);
107+
await t
108+
.expect(compareResults.isValid())
109+
.ok(compareResults.errorMessages());
110+
}).before(async () => {
111+
await changeTheme(theme);
112+
113+
await createWidget('dxDataGrid', {
114+
dataSource: [
115+
{ id: 1, name: 'John Smith' },
116+
{ id: 2, name: 'Jane Johnson' },
117+
{ id: 3, name: 'Mike Wilson' },
118+
],
119+
keyExpr: 'id',
120+
height: 300,
121+
showBorders: true,
122+
showRowLines: true,
123+
columns: [
124+
{ dataField: 'id', width: 50 },
125+
{ dataField: 'name', width: 150 },
126+
],
127+
editing: {
128+
mode: 'batch',
129+
allowDeleting: true,
130+
},
131+
});
132+
}).after(async () => {
133+
await changeTheme(Themes.genericLight);
134+
});
135+
136+
test(`When not showing row lines and not fixed any column row height should not change when marked as deleted - ${theme}`, async (t) => {
137+
// Arrange
138+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
139+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
140+
141+
// Get the initial height of the row at index
142+
const initialRow = dataGrid.getDataRow(ROW_INDEX);
143+
const initialRowHeight = await initialRow.element.clientHeight;
144+
145+
// Act - mark the row as deleted
146+
await dataGrid.apiDeleteRow(ROW_INDEX);
147+
148+
// Assert - check if the row is marked as deleted
149+
await t
150+
.expect(dataGrid.getDataRow(ROW_INDEX).isRemoved)
151+
.ok('Row should be marked as deleted');
152+
153+
// Get the height of the deleted row
154+
const deletedRow = dataGrid.getDataRow(ROW_INDEX);
155+
const deletedRowHeight = await deletedRow.element.clientHeight;
156+
157+
// Assert - check if the height remains consistent
158+
await t
159+
.expect(deletedRowHeight)
160+
.eql(initialRowHeight, 'Row height should not change when marked as deleted');
161+
162+
// Take a screenshot for visual verification
163+
await takeScreenshot(`datagrid-deleted-row-height-no-row-lines-and-no-fixed-column (${theme}).png`, dataGrid.element);
164+
await t
165+
.expect(compareResults.isValid())
166+
.ok(compareResults.errorMessages());
167+
}).before(async () => {
168+
await changeTheme(theme);
169+
170+
await createWidget('dxDataGrid', {
171+
dataSource: [
172+
{ id: 1, name: 'John Smith' },
173+
{ id: 2, name: 'Jane Johnson' },
174+
{ id: 3, name: 'Mike Wilson' },
175+
],
176+
keyExpr: 'id',
177+
height: 300,
178+
showBorders: true,
179+
showRowLines: false,
180+
columns: [
181+
{ dataField: 'id', width: 50 },
182+
{ dataField: 'name', width: 150 },
183+
],
184+
editing: {
185+
mode: 'batch',
186+
allowDeleting: true,
187+
},
188+
});
189+
}).after(async () => {
190+
await changeTheme(Themes.genericLight);
191+
});
192+
test(`When not showing row lines and DataGrid has any column row height should not change when marked as deleted - ${theme}`, async (t) => {
193+
// Arrange
194+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
195+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
196+
197+
// Get the initial height of the row at index
198+
const initialRow = dataGrid.getDataRow(ROW_INDEX);
199+
const initialRowHeight = await initialRow.element.clientHeight;
200+
201+
// Act - mark the row as deleted
202+
await dataGrid.apiDeleteRow(ROW_INDEX);
203+
204+
// Assert - check if the row is marked as deleted
205+
await t
206+
.expect(dataGrid.getDataRow(ROW_INDEX).isRemoved)
207+
.ok('Row should be marked as deleted');
208+
209+
// Get the height of the deleted row
210+
const deletedRow = dataGrid.getDataRow(ROW_INDEX);
211+
const deletedRowHeight = await deletedRow.element.clientHeight;
212+
213+
// Assert - check if the height remains consistent
214+
await t
215+
.expect(deletedRowHeight)
216+
.eql(initialRowHeight, 'Row height should not change when marked as deleted');
217+
218+
// Take a screenshot for visual verification
219+
await takeScreenshot(`datagrid-deleted-row-height-no-row-lines-and-fixed-column (${theme}).png`, dataGrid.element);
220+
await t
221+
.expect(compareResults.isValid())
222+
.ok(compareResults.errorMessages());
223+
}).before(async () => {
224+
await changeTheme(theme);
225+
226+
await createWidget('dxDataGrid', {
227+
dataSource: [
228+
{ id: 1, name: 'John Smith' },
229+
{ id: 2, name: 'Jane Johnson' },
230+
{ id: 3, name: 'Mike Wilson' },
231+
],
232+
keyExpr: 'id',
233+
height: 300,
234+
showBorders: true,
235+
showRowLines: false,
236+
columns: [
237+
{ dataField: 'id', width: 50, fixed: true },
238+
{ dataField: 'name', width: 150 },
239+
],
240+
editing: {
241+
mode: 'batch',
242+
allowDeleting: true,
243+
},
244+
});
245+
}).after(async () => {
246+
await changeTheme(Themes.genericLight);
247+
});
248+
});
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)