Skip to content

Commit ecf7496

Browse files
update test
1 parent 1af6524 commit ecf7496

File tree

1 file changed

+82
-82
lines changed

1 file changed

+82
-82
lines changed

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/focus.integration.tests.js

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,6 +4318,88 @@ QUnit.module('View\'s focus', {
43184318
assert.equal(this.dataGrid.option('focusedRowKey'), 2, 'row key is changed');
43194319
assert.ok($(this.dataGrid.getRowElement(1)).hasClass('dx-row-focused'), 'second row is focused');
43204320
});
4321+
4322+
// T1310557
4323+
QUnit.testInActiveWindow('Browser should not scroll back to the grid when a focused cell is updated or rerendered', function(assert) {
4324+
// arrange
4325+
const dataGrid = createDataGrid({
4326+
dataSource: {
4327+
store: new ArrayStore({
4328+
key: 'id',
4329+
data: [{ id: 1, name: 'test1' }],
4330+
}),
4331+
pushAggregationTimeout: 0,
4332+
},
4333+
});
4334+
$('body').css('height', 2000);
4335+
window.scrollTo(0, 0);
4336+
this.clock.tick(10);
4337+
4338+
const keyboardController = dataGrid.getController('keyboardNavigation');
4339+
const $firstCell = $(dataGrid.getCellElement(0, 0));
4340+
const scrollPosition = 300;
4341+
4342+
// assert
4343+
assert.strictEqual(window.pageYOffset, 0, 'document scroll is at the top');
4344+
4345+
// act
4346+
$firstCell.trigger(CLICK_EVENT);
4347+
this.clock.tick(10);
4348+
4349+
keyboardController.keyDownHandler({
4350+
key: 'Tab',
4351+
keyName: 'tab',
4352+
originalEvent: $.Event('keydown', { target: $firstCell.get(0) }),
4353+
});
4354+
this.clock.tick(10);
4355+
4356+
// assert
4357+
assert.ok($(dataGrid.getCellElement(0, 1)).hasClass('dx-focused'), 'second cell is focused');
4358+
4359+
// act
4360+
window.scrollTo(0, scrollPosition);
4361+
4362+
// assert
4363+
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is changed');
4364+
4365+
// act
4366+
dataGrid.getDataSource().store().push([{ type: 'update', key: 1, data: { name: 'updated' } }]);
4367+
this.clock.tick(10);
4368+
4369+
// assert
4370+
assert.strictEqual($(dataGrid.getCellElement(0, 1)).text(), 'updated', 'second cell text is updated');
4371+
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after push update');
4372+
4373+
// act
4374+
dataGrid.refresh();
4375+
this.clock.tick(10);
4376+
4377+
// assert
4378+
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after refresh');
4379+
4380+
// act
4381+
dataGrid.repaint();
4382+
this.clock.tick(10);
4383+
4384+
// assert
4385+
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after repaint');
4386+
4387+
// act
4388+
keyboardController.keyDownHandler({
4389+
key: 'ArrowLeft',
4390+
keyName: 'leftArrow',
4391+
originalEvent: $.Event('keydown', { target: $(dataGrid.getCellElement(0, 1)).get(0) }),
4392+
});
4393+
this.clock.tick(10);
4394+
4395+
// assert
4396+
assert.ok($(dataGrid.getCellElement(0, 0)).hasClass('dx-focused'), 'first cell is focused');
4397+
assert.strictEqual(window.pageYOffset, 0, 'document scroll is changed after keyboard navigation');
4398+
4399+
// cleanup
4400+
$('body').css('height', '');
4401+
window.scrollTo(0, 0);
4402+
});
43214403
});
43224404

43234405
QUnit.module('API methods', baseModuleConfig, () => {
@@ -4980,86 +5062,4 @@ QUnit.module('Column Resizing', baseModuleConfig, () => {
49805062
// assert
49815063
assert.equal(dataGrid.getScrollable().scrollTop(), 10, 'scroll top is not changed');
49825064
});
4983-
4984-
// T1310557
4985-
QUnit.testInActiveWindow('Browser should not scroll back to the grid when a focused cell is updated or rerendered', function(assert) {
4986-
// arrange
4987-
const dataGrid = createDataGrid({
4988-
dataSource: {
4989-
store: new ArrayStore({
4990-
key: 'id',
4991-
data: [{ id: 1, name: 'test1' }],
4992-
}),
4993-
pushAggregationTimeout: 0,
4994-
},
4995-
});
4996-
$('body').css('height', 2000);
4997-
window.scrollTo(0, 0);
4998-
this.clock.tick(10);
4999-
5000-
const keyboardController = dataGrid.getController('keyboardNavigation');
5001-
const $firstCell = $(dataGrid.getCellElement(0, 0));
5002-
const scrollPosition = 300;
5003-
5004-
// assert
5005-
assert.strictEqual(window.pageYOffset, 0, 'document scroll is at the top');
5006-
5007-
// act
5008-
$firstCell.trigger(CLICK_EVENT);
5009-
this.clock.tick(10);
5010-
5011-
keyboardController.keyDownHandler({
5012-
key: 'Tab',
5013-
keyName: 'tab',
5014-
originalEvent: $.Event('keydown', { target: $firstCell.get(0) }),
5015-
});
5016-
this.clock.tick(10);
5017-
5018-
// assert
5019-
assert.ok($(dataGrid.getCellElement(0, 1)).hasClass('dx-focused'), 'second cell is focused');
5020-
5021-
// act
5022-
window.scrollTo(0, scrollPosition);
5023-
5024-
// assert
5025-
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is changed');
5026-
5027-
// act
5028-
dataGrid.getDataSource().store().push([{ type: 'update', key: 1, data: { name: 'updated' } }]);
5029-
this.clock.tick(10);
5030-
5031-
// assert
5032-
assert.strictEqual($(dataGrid.getCellElement(0, 1)).text(), 'updated', 'second cell text is updated');
5033-
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after push update');
5034-
5035-
// act
5036-
dataGrid.refresh();
5037-
this.clock.tick(10);
5038-
5039-
// assert
5040-
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after refresh');
5041-
5042-
// act
5043-
dataGrid.repaint();
5044-
this.clock.tick(10);
5045-
5046-
// assert
5047-
assert.strictEqual(window.pageYOffset, scrollPosition, 'document scroll is preserved after repaint');
5048-
5049-
// act
5050-
keyboardController.keyDownHandler({
5051-
key: 'ArrowLeft',
5052-
keyName: 'leftArrow',
5053-
originalEvent: $.Event('keydown', { target: $(dataGrid.getCellElement(0, 1)).get(0) }),
5054-
});
5055-
this.clock.tick(10);
5056-
5057-
// assert
5058-
assert.ok($(dataGrid.getCellElement(0, 0)).hasClass('dx-focused'), 'first cell is focused');
5059-
assert.strictEqual(window.pageYOffset, 0, 'document scroll is changed after keyboard navigation');
5060-
5061-
// cleanup
5062-
$('body').css('height', '');
5063-
window.scrollTo(0, 0);
5064-
});
50655065
});

0 commit comments

Comments
 (0)