From 42d57159f2187dc87c3ff66ab4829e8f05fb4877 Mon Sep 17 00:00:00 2001 From: "anna.shakhova" Date: Tue, 14 Jul 2026 11:43:07 +0200 Subject: [PATCH] Grids: fix unstable editing test --- .../editing/editing.functional_matrix.ts | 6 +++ .../dataGrid/common/editing/functional.ts | 54 +++++++++++-------- .../keyboardNavigation.functional.ts | 16 ++++++ .../dataGrid/sticky/common/withEditing.ts | 8 ++- 4 files changed, 61 insertions(+), 23 deletions(-) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/editing/editing.functional_matrix.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/editing/editing.functional_matrix.ts index a666b25b0359..62fc6378bc47 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/editing/editing.functional_matrix.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/editing/editing.functional_matrix.ts @@ -167,6 +167,8 @@ const checkCellFocused = async ( } await t + .expect(editor?.element.exists) + .ok() .expect(editor?.element.focused) .eql(true); }; @@ -443,6 +445,8 @@ editingModes.forEach((mode) => { const cell = dataGrid.getDataCell(0, columnInfo.columnIndex); const editor = form ? new CellEditor(form.getItem(columnInfo.dataField)) : cell.getEditor(); + await t.expect(dataGrid.isReady()).ok(); + await clickCellEditor(t, mode, columnInfo, form, cell, editor); await setEditorValue(t, mode, columnInfo, editor); @@ -581,6 +585,8 @@ editingModes.forEach((mode) => { const form = getEditForm(mode); let modifiedCellCount = mode === 'batch' ? 1 : 0; + await t.expect(dataGrid.isReady()).ok(); + // eslint-disable-next-line no-restricted-syntax for (const columnInfo of textColumnInfos) { const cell = dataGrid.getDataCell(0, columnInfo.columnIndex); diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/editing/functional.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/editing/functional.ts index 4acd172ae7b2..afe21f03422a 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/editing/functional.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/editing/functional.ts @@ -362,6 +362,8 @@ test('Async Validation(Row) - Data is not saved when a dependant cell value beco test('Async Validation(Cell) - Only the last cell should be switched to edit mode', async (t) => { const dataGrid = new DataGrid('#container'); + const resolveValidation = ClientFunction(() => (window as any).deferred.resolve(true)); + await t.expect(dataGrid.isReady()).ok(); const cell0 = dataGrid.getDataCell(0, 0); @@ -374,33 +376,43 @@ test('Async Validation(Cell) - Only the last cell should be switched to edit mod .click(cell1.element) .expect(cell1.isFocused) .notOk('the second cell should not be focused') - .click(cell2.element) + .click(cell2.element); + + await resolveValidation(); + + await t .expect(cell0.isValidationPending) .notOk('validating is completed') .expect(cell2.hasHiddenFocusState) .notOk() .expect(cell2.isFocused) .ok('the third cell should be focused'); -}).before(async () => createWidget('dxDataGrid', getGridConfig({ - editing: { - mode: 'cell', - allowUpdating: true, - allowAdding: true, - }, - columns: [{ - dataField: 'age', - validationRules: [{ - type: 'async', - validationCallback(): JQueryPromise { - const d = $.Deferred(); - setTimeout(() => { - d.resolve(true); - }, 1000); - return d.promise(); - }, - }], - }, 'name', 'lastName'], -}))); +}).before(async () => { + await ClientFunction(() => { + (window as any).deferred = $.Deferred(); + })(); + + return createWidget('dxDataGrid', getGridConfig({ + editing: { + mode: 'cell', + allowUpdating: true, + allowAdding: true, + }, + columns: [{ + dataField: 'age', + validationRules: [{ + type: 'async', + validationCallback(): JQueryPromise { + return (window as any).deferred.promise(); + }, + }], + }, 'name', 'lastName'], + })); +}).after(async () => { + await ClientFunction(() => { + delete (window as any).deferred; + })(); +}); test('Async Validation(Cell) - Only valid data is saved in a new row', async (t) => { const dataGrid = new DataGrid('#container'); diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts index bba4b2bdcdec..8346a6cd5410 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts @@ -1703,6 +1703,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .click(addRowButton) .expect(cell00.isFocused).ok() + .expect(editor00.element.exists) + .ok() .expect(editor00.element.focused) .ok() @@ -1715,6 +1717,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .eql('1') .expect(cell01.isFocused) .ok() + .expect(editor01.element.exists) + .ok() .expect(editor01.element.focused) .ok() @@ -1749,6 +1753,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .click(cell01.element) .expect(cell01.isFocused).ok() + .expect(editor01.element.exists) + .ok() .expect(editor01.element.focused) .ok() @@ -1761,6 +1767,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .eql('2') .expect(cell00.isFocused) .ok() + .expect(editor00.element.exists) + .ok() .expect(editor00.element.focused) .ok() @@ -1793,6 +1801,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .click(cell00.element) .expect(cell00.isFocused).ok() + .expect(editor00.element.exists) + .ok() .expect(editor00.element.focused) .ok() @@ -1805,6 +1815,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .eql('11') .expect(cell01.isFocused) .ok() + .expect(editor01.element.exists) + .ok() .expect(editor01.element.focused) .ok() @@ -1837,6 +1849,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .click(cell01.element) .expect(cell01.isFocused).ok() + .expect(editor01.element.exists) + .ok() .expect(editor01.element.focused) .ok() @@ -1849,6 +1863,8 @@ test('The expand cell should not lose focus on expanding a master row (T892203)' .eql('22') .expect(cell00.isFocused) .ok() + .expect(editor00.element.exists) + .ok() .expect(editor00.element.focused) .ok() diff --git a/e2e/testcafe-devextreme/tests/dataGrid/sticky/common/withEditing.ts b/e2e/testcafe-devextreme/tests/dataGrid/sticky/common/withEditing.ts index 8224ad4294fe..a05230f98020 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/sticky/common/withEditing.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/sticky/common/withEditing.ts @@ -68,13 +68,17 @@ test.meta({ browserSize: [800, 800] })('The form edit mode: Edit row when there }, })); -test.meta({ browserSize: [800, 800] })('The batch edit mode: Edit cell whene there are sticky columns', async (t) => { +test.meta({ browserSize: [800, 800] })('The batch edit mode: Edit cell when there are sticky columns', async (t) => { const { takeScreenshot, compareResults } = createScreenshotsComparer(t); const dataGrid = new DataGrid(DATA_GRID_SELECTOR); await t.expect(dataGrid.isReady()).ok(); - await t.click(dataGrid.getDataCell(0, 2).element); + const editCell = dataGrid.getDataCell(0, 2); + await t.click(editCell.element); + await t + .expect(editCell.isEditCell).ok() + .expect(editCell.getEditor().element.focused).ok(); await testScreenshot(t, takeScreenshot, 'edit_cell_with_sticky_columns_1.png', { element: dataGrid.element });