Skip to content

Commit a8b9d4a

Browse files
update
1 parent fc738c0 commit a8b9d4a

6 files changed

Lines changed: 67 additions & 46 deletions

File tree

e2e/testcafe-devextreme/tests/dataGrid/common/editing/functional.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { createWidget } from '../../../../helpers/createWidget';
88
fixture.disablePageReloads`Editing.Functional`
99
.page(url(__dirname, '../../../container.html'));
1010

11+
const FOCUS_ASSERTION_TIMEOUT = 3000;
12+
1113
const getGridConfig = (config): Record<string, unknown> => {
1214
const defaultConfig = {
1315
errorRowEnabled: true,
@@ -67,8 +69,8 @@ test('DataGrid - The "Cannot read properties of undefined error" occurs when usi
6769
.pressKey('enter tab tab');
6870
await resolveOnSavingDeferred();
6971
await t
70-
.expect(dataGrid.isReady()).ok()
71-
.expect(dataGrid.getDataCell(2, 0).isFocused).ok();
72+
.expect(dataGrid.isReady()).ok({ timeout: FOCUS_ASSERTION_TIMEOUT })
73+
.expect(dataGrid.getDataCell(2, 0).isFocused).ok({ timeout: FOCUS_ASSERTION_TIMEOUT });
7274
}).before(async () => {
7375
await ClientFunction(() => {
7476
(window as any).deferred = $.Deferred();

e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { testScreenshot } from '../../../../helpers/themeUtils';
2121
import { addFocusableElementBefore } from '../../../../helpers/domUtils';
2222

2323
const CLASS = ClassNames;
24+
const FOCUS_ASSERTION_TIMEOUT = 3000;
2425

2526
const getOnKeyDownCallCount = ClientFunction(() => (window as any).onKeyDownCallCount);
2627

@@ -6801,10 +6802,12 @@ test('Focus should be set to the grid to allow keyboard navigation when the focu
68016802
// act
68026803
await t
68036804
.click(searchPanel.input)
6804-
.pressKey('tab tab tab tab tab');
6805+
.expect(searchPanel.isFocused)
6806+
.ok({ timeout: FOCUS_ASSERTION_TIMEOUT })
6807+
.pressKey('tab tab tab tab tab', { speed: 0.5 });
68056808

68066809
// assert
6807-
await t.expect(secondIDCell.isFocused).ok();
6810+
await t.expect(secondIDCell.isFocused).ok({ timeout: FOCUS_ASSERTION_TIMEOUT });
68086811

68096812
// act
68106813
await searchPanel.focus();
@@ -6817,22 +6820,22 @@ test('Focus should be set to the grid to allow keyboard navigation when the focu
68176820
.notOk('focus should be on the search panel');
68186821

68196822
// act
6820-
await t.pressKey('tab tab tab');
6823+
await t.pressKey('tab tab tab', { speed: 0.5 });
68216824

68226825
// assert
6823-
await t.expect(secondIDCell.isFocused).ok();
6826+
await t.expect(secondIDCell.isFocused).ok({ timeout: FOCUS_ASSERTION_TIMEOUT });
68246827

68256828
// act
68266829
await t.pressKey('tab tab');
68276830

68286831
// assert
6829-
await t.expect(button.isFocused).ok();
6832+
await t.expect(button.isFocused).ok({ timeout: FOCUS_ASSERTION_TIMEOUT });
68306833

68316834
// act
68326835
await t.pressKey('shift+tab');
68336836

68346837
// assert
6835-
await t.expect(secondNameCell.isFocused).ok();
6838+
await t.expect(secondNameCell.isFocused).ok({ timeout: FOCUS_ASSERTION_TIMEOUT });
68366839
}).before(async () => {
68376840
await createWidget('dxDataGrid', {
68386841
dataSource: [{ id: 1, name: 'test1' }, { id: 2, name: 'test2' }],

e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.visual.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,14 @@ test('Navigate to first cell in the first row when virtual scrolling and columns
776776
await expectDataCellFocusState(t, dataGrid, 199, 34);
777777
await t
778778
.expect(dataGrid.isReady())
779-
.ok({ timeout: KEYBOARD_NAVIGATION_TIMEOUT })
780-
.expect(isScrollAtEnd('horizontal'))
781779
.ok({ timeout: KEYBOARD_NAVIGATION_TIMEOUT });
780+
781+
if (!useNative) {
782+
await t
783+
.expect(isScrollAtEnd('horizontal'))
784+
.ok({ timeout: KEYBOARD_NAVIGATION_TIMEOUT });
785+
}
786+
782787
await waitForPaint();
783788

784789
await testScreenshot(t, takeScreenshot, `${useNative ? 'native' : 'simulated'}_scrolling_-_navigate_to_last_cell_row_dragging__virtual_scrolling__virtual_columns.png`, { element: dataGrid.element });

packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ const waitForEditingPreviewToHide = async(getEditingPreview) => {
8888
await waitForCondition(() => getEditingPreview().length === 0
8989
|| getEditingPreview().hasClass(CHAT_EDITING_PREVIEW_HIDING_CLASS));
9090

91-
getEditingPreview().get(0)?.dispatchEvent(new Event('animationend'));
91+
const editingPreview = getEditingPreview().get(0);
92+
if(editingPreview) {
93+
editingPreview.dispatchEvent(new Event('animationend'));
94+
}
95+
96+
await waitForCondition(() => getEditingPreview().length === 0);
9297
};
9398

9499
export const MOCK_COMPANION_USER_ID = 'COMPANION_USER_ID';

packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/messageList.tests.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,7 @@ QUnit.module('MessageList', () => {
16471647
});
16481648
});
16491649

1650-
QUnit.test('should not be scroll down after render companion message if scroll position not at the bottom', function(assert) {
1651-
const done = assert.async();
1650+
QUnit.test('should not be scroll down after render companion message if scroll position not at the bottom', async function(assert) {
16521651
const items = generateMessages(52);
16531652

16541653
this.reinit({
@@ -1665,24 +1664,25 @@ QUnit.module('MessageList', () => {
16651664
text: 'NEW MESSAGE',
16661665
};
16671666

1668-
setTimeout(() => {
1669-
this.getScrollView().scrollBy({ top: -100 });
1670-
setTimeout(() => {
1667+
await waitForCondition(() => Math.abs(this.getScrollView().scrollTop() - this.getScrollOffsetMax()) <= 1);
16711668

1672-
const scrollTopBefore = this.getScrollView().scrollTop();
1673-
assert.roughEqual(scrollTopBefore, this.getScrollOffsetMax() - 100, 1, 'scroll position should not be at the bottom before rendering the message');
1669+
const initialScrollTop = this.getScrollOffsetMax() - 100;
1670+
this.getScrollView().scrollTo({ top: initialScrollTop });
16741671

1675-
setTimeout(() => {
1676-
this.instance.option('items', [...items, newMessage]);
1672+
await waitForCondition(() => Math.abs(this.getScrollView().scrollTop() - initialScrollTop) <= 1);
16771673

1678-
const scrollTop = this.getScrollView().scrollTop();
1674+
const scrollTopBefore = this.getScrollView().scrollTop();
1675+
assert.roughEqual(scrollTopBefore, initialScrollTop, 1, 'scroll position should not be at the bottom before rendering the message');
16791676

1680-
assert.notEqual(scrollTop, 0, 'scroll position should not be 0 after a new message is rendered');
1681-
assert.roughEqual(scrollTop, scrollTopBefore, 1, 'scroll position should be at the bottom after rendering the new message');
1682-
done();
1683-
}, this._resizeTimeout);
1684-
}, this._resizeTimeout);
1685-
}, this._resizeTimeout);
1677+
this.instance.option('items', [...items, newMessage]);
1678+
1679+
await waitForCondition(() => this.getBubbles().length === items.length + 1
1680+
&& Math.abs(this.getScrollView().scrollTop() - scrollTopBefore) <= 1);
1681+
1682+
const scrollTop = this.getScrollView().scrollTop();
1683+
1684+
assert.notEqual(scrollTop, 0, 'scroll position should not be 0 after a new message is rendered');
1685+
assert.roughEqual(scrollTop, scrollTopBefore, 1, 'scroll position should remain the same after rendering the new message');
16861686
});
16871687

16881688
QUnit.test('should be scrolled down after showing if was initially rendered inside an invisible element', function(assert) {
@@ -1977,4 +1977,3 @@ QUnit.module('MessageList', () => {
19771977
});
19781978
});
19791979

1980-

packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/azureTests.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const prepareTestingAzureProvider = () => {
3030
atlas.popupOpened = false;
3131
};
3232

33+
const loadAzureMock = () => $.getScript({
34+
url: '../../packages/devextreme/testing/helpers/forMap/azureMock.js',
35+
scriptAttrs: { nonce: 'qunit-test' },
36+
}).done(() => {
37+
prepareTestingAzureProvider();
38+
});
39+
3340
const moduleConfig = {
3441
beforeEach: function() {
3542
const fakeURL = '/fakeAzureUrl';
@@ -43,12 +50,7 @@ const moduleConfig = {
4350
if(!azureMockCreated) {
4451
azureMockCreated = true;
4552

46-
$.getScript({
47-
url: '../../packages/devextreme/testing/helpers/forMap/azureMock.js',
48-
scriptAttrs: { nonce: 'qunit-test' },
49-
}).done(() => {
50-
prepareTestingAzureProvider();
51-
});
53+
loadAzureMock();
5254
}
5355
},
5456
responseText: {
@@ -86,10 +88,7 @@ QUnit.module('map loading', moduleConfig, () => {
8688
QUnit.test('map initialize with loaded map', function(assert) {
8789
const done = assert.async();
8890

89-
$.getScript({
90-
url: '../../packages/devextreme/testing/helpers/forMap/azureMock.js',
91-
scriptAttrs: { nonce: 'qunit-test' }
92-
}).done(function() {
91+
loadAzureMock().done(function() {
9392
window.atlas.Map.customFlag = true;
9493

9594
setTimeout(function() {
@@ -308,15 +307,23 @@ QUnit.module('basic options', moduleConfig, () => {
308307
const done = assert.async();
309308
const center = 'Cedar Park, Texas';
310309

311-
$('#map').dxMap({
312-
provider: 'azure',
313-
center,
314-
onReady: () => {
315-
assert.deepEqual(atlas.cameraOptions.center, this.geocodedCoordinates, 'center coordinates are correct');
310+
const initMap = () => {
311+
$('#map').dxMap({
312+
provider: 'azure',
313+
center,
314+
onReady: () => {
315+
assert.deepEqual(atlas.cameraOptions.center, this.geocodedCoordinates, 'center coordinates are correct');
316316

317-
done();
318-
}
319-
});
317+
done();
318+
}
319+
});
320+
};
321+
322+
if(window.atlas && window.atlas.Map) {
323+
initMap();
324+
} else {
325+
loadAzureMock().done(initMap);
326+
}
320327
});
321328

322329
QUnit.test('Previously geocoded location should be taken from cache instead of geocoding second time', function(assert) {

0 commit comments

Comments
 (0)