Skip to content

Commit

Permalink
DataGrid(T1140411): Add testcafe e2e test cases (#24166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raushen authored Apr 3, 2023
1 parent df06d5d commit a2390de
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 21 deletions.
81 changes: 60 additions & 21 deletions testing/testcafe/tests/dataGrid/editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DataGrid, { CLASS } from '../../model/dataGrid';
import SelectBox from '../../model/selectBox';
import { changeTheme } from '../../helpers/changeTheme';
import { Overlay } from '../../model/dataGrid/overlay';
import { getData } from './helpers/generateDataSourceData';

fixture.disablePageReloads`Editing`
.page(url(__dirname, '../container.html'));
Expand Down Expand Up @@ -2125,24 +2126,62 @@ test('Cells should be focused correctly on click when cell editing mode is used
});

// T1130497
test('The first cell of the last row should be focused when newRowPosition = last and editing.mode = cell', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const dataGrid = new DataGrid('#container');
const headerPanel = dataGrid.getHeaderPanel();

await t
.click(headerPanel.getAddRowButton())
.expect(dataGrid.getDataRow(3).isInserted).ok('row is inserted')
.expect(await takeScreenshot('grid-cell-edit-mode-and-new-row-position-last.png', dataGrid.element))
.ok()
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => createWidget('dxDataGrid', {
dataSource: [{ name: 'AaAaA', value: 1 }, { name: 'aAaAa', value: 2 }, { name: 'BbBb', value: 3 }],
editing: {
mode: 'cell',
allowUpdating: true,
allowAdding: true,
newRowPosition: 'last',
},
}));
([
['first', 0, 'standard', 0],
['last', 20, 'standard', 0],
['pageBottom', 20, 'standard', 0],
['pageTop', 0, 'standard', 0],
['pageBottom', 8, 'virtual', 0],
['pageTop', 0, 'virtual', 0],
['viewportBottom', 8, 'standard', 0],
['viewportBottom', 13, 'standard', 162],
['viewportTop', 0, 'standard', 0],
['viewportTop', 5, 'standard', 162],
['viewportBottom', 8, 'virtual', 0],
['viewportBottom', 13, 'virtual', 162],
['viewportTop', 0, 'virtual', 0],
['viewportTop', 5, 'virtual', 162],
] as [string, number, string, number][])
.forEach(([newRowPosition, insertedRowNumber, scrollMode, scrollTop]) => {
test(`The first cell of the new row should be focused when
newRowPosition = ${newRowPosition}
and editing.mode = cell
and ${scrollMode} scroll mode
and scrollTop is ${scrollTop}`, async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const dataGrid = new DataGrid('#container');
const headerPanel = dataGrid.getHeaderPanel();

const scrollTo = async (y) => {
await dataGrid.scrollTo({ y });
return dataGrid.isReady();
};

const screenshotName = `grid-new-row_position-${newRowPosition}_scroll-mode-${scrollMode}_top-${scrollTop}.png`;

await t
.expect(await scrollTo(scrollTop))
.ok(`scrollTo ${scrollTop}`)
.click(headerPanel.getAddRowButton())
// act
.expect(await takeScreenshot(screenshotName, dataGrid.element))
.ok()
// assert
.expect(dataGrid.getDataRow(insertedRowNumber).isInserted)
.ok('row is inserted')
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => createWidget('dxDataGrid', {
dataSource: getData(20, 3),
height: 400,
editing: {
mode: 'cell',
allowUpdating: true,
allowAdding: true,
newRowPosition,
},
scrolling: {
mode: scrollMode,
},
}));
});
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions testing/testcafe/tests/dataGrid/helpers/generateDataSourceData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const getData = (rowCount: number, colCount: number): Record<string, string>[] => {
const items: Record<string, string>[] = [];
for (let i = 0; i < rowCount; i += 1) {
const item: Record<string, string> = {};
for (let j = 0; j < colCount; j += 1) {
item[`field_${j}`] = `val_${i}_${j}`;
}
items.push(item);
}

return items;
};

0 comments on commit a2390de

Please sign in to comment.