Skip to content

Commit

Permalink
rewrite test in testcafe
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucchhaa committed Jan 16, 2025
1 parent c809402 commit 7e9c25a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 37 deletions.
27 changes: 27 additions & 0 deletions e2e/testcafe-devextreme/tests/dataGrid/focus/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,30 @@ test('DataGrid - FilterRow cell loses focus when focusedRowEnabled is true and e
});
});
});

['onFocusedRowChanged', 'onFocusedRowChanging'].forEach((event) => {
test(`Focus should be preserved on datagrid when rowsview repaints in ${event} event (T1224663)`, async (t) => {
const dataGrid = new DataGrid('#container');

await t
.click(dataGrid.getDataCell(0, 0).element)
.expect(dataGrid.getDataRow(0).isFocusedRow)
.ok();

await t
.pressKey('down')
.expect(dataGrid.getDataRow(1).isFocusedRow)
.ok();
}).before(async () => createWidget('dxDataGrid', {
dataSource: [
{ id: 1, name: 'name 1' },
{ id: 2, name: 'name 2' },
{ id: 3, name: 'name 3' },
],
keyExpr: 'id',
focusedRowEnabled: true,
[event]: (e) => {
e.component.repaint();
},
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -4384,43 +4384,6 @@ QUnit.module('View\'s focus', {
assert.equal(this.dataGrid.option('focusedRowKey'), 2, 'row key is changed');
assert.ok($(this.dataGrid.getRowElement(1)).hasClass('dx-row-focused'), 'second row is focused');
});

// T1224663
['onFocusedRowChanged', 'onFocusedRowChanging'].forEach(event => {
QUnit.testInActiveWindow(`Focus should be preserved on datagrid when rowsview repaints in ${event} event`, function(assert) {
// arrange
this.dataGrid.option({
dataSource: [
{ id: 1, name: 'name 1' },
{ id: 2, name: 'name 2' },
{ id: 3, name: 'name 3' }
],
keyExpr: 'id',
focusedRowEnabled: true,
[event]: (e) => {
this.dataGrid.repaint();
}
});
this.clock.tick(300);

// act
$(this.dataGrid.getCellElement(0, 0)).trigger(CLICK_EVENT);
this.clock.tick(300);

// assert
const firstRow = $(this.dataGrid.getRowElement(0));
assert.ok(firstRow.hasClass('dx-row-focused'), 'first row is focused');

// act
const keyboard = keyboardMock(firstRow);
keyboard.keyDown('down');
this.clock.tick(300);

// assert
const secondRow = $(this.dataGrid.getRowElement(1));
assert.ok(secondRow.hasClass('dx-row-focused'), 'second row is focused');
});
});
});

QUnit.module('API methods', baseModuleConfig, () => {
Expand Down

0 comments on commit 7e9c25a

Please sign in to comment.