Skip to content

Commit 56073f1

Browse files
authored
Tests: The utilities to help skip tests on unsupported devices were added (#29826)
Signed-off-by: pharret31 <[email protected]>
1 parent 685befd commit 56073f1

File tree

54 files changed

+608
-716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+608
-716
lines changed

packages/devextreme/testing/helpers/chat.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import devices from '__internal/core/m_devices';
2+
3+
export const shouldSkipOnDevices = ({
4+
deviceTypes = [],
5+
assert = null,
6+
message = null
7+
} = {}) => {
8+
if(!Array.isArray(deviceTypes)) {
9+
throw new Error('deviceTypes should be an array');
10+
}
11+
if(deviceTypes.includes(devices.real().deviceType)) {
12+
assert && assert.ok(true, message || `Test skipped on devices: ${deviceTypes.toString()}`);
13+
return true;
14+
}
15+
return false;
16+
};
17+
18+
export const shouldSkipOnDesktop = (assert = null, message = null) => shouldSkipOnDevices({
19+
deviceTypes: ['desktop'],
20+
assert,
21+
message,
22+
});
23+
24+
export const shouldSkipOnPhone = (assert = null, message = null) => shouldSkipOnDevices({
25+
deviceTypes: ['phone'],
26+
assert,
27+
message,
28+
});
29+
30+
export const shouldSkipOnMobile = (assert = null, message = null) => shouldSkipOnDevices({
31+
deviceTypes: ['phone', 'tablet'],
32+
assert,
33+
message,
34+
});

packages/devextreme/testing/helpers/fileManagerHelpers.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export class FileManagerWrapper {
406406
}
407407

408408
getDetailsCellValue(rowIndex, columnIndex) {
409-
columnIndex += isDesktopDevice() ? 1 : 0;
409+
columnIndex += devices.real().deviceType === 'desktop' ? 1 : 0;
410410
return this.getRowInDetailsView(rowIndex)
411411
.find(`td:nth-child(${columnIndex})`)
412412
.text()
@@ -973,10 +973,6 @@ export const stubFileReader = object => {
973973
}
974974
};
975975

976-
export const isDesktopDevice = () => {
977-
return devices.real().deviceType === 'desktop';
978-
};
979-
980976
export const getDropFileEvent = file => $.Event($.Event('drop', { dataTransfer: { files: [file] } }));
981977

982978
export const createEditingEvents = () => {

packages/devextreme/testing/tests/DevExpress.animation/position.tests.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import fixtures from '../../helpers/positionFixtures.js';
66
import devices from 'core/devices.js';
77
import { implementationsMap } from 'core/utils/size';
88
import { getWindow } from 'core/utils/window.js';
9+
import { shouldSkipOnDevices, shouldSkipOnPhone } from '../../helpers/device.js';
910

1011
const setupPosition = positionUtils.setup;
1112
const calculatePosition = positionUtils.calculate;
@@ -964,8 +965,11 @@ const testCollision = (name, fixtureName, params, expectedHorzDist, expectedVert
964965
});
965966

966967
QUnit.test('position should return window.height() if window.outerHeight == window.innerHeight (T939748)', function(assert) {
967-
const isPhone = devices.real().deviceType === 'phone';
968-
if(isPhone || browser.safari) {
968+
if(shouldSkipOnPhone(assert)) {
969+
return;
970+
}
971+
972+
if(browser.safari) {
969973
assert.ok(true, 'actual only for desktop browsers except Safari');
970974
return;
971975
}
@@ -993,8 +997,11 @@ const testCollision = (name, fixtureName, params, expectedHorzDist, expectedVert
993997
});
994998

995999
QUnit.test('position should return window.width() if window.outerWidth == window.innerWidth (T939748)', function(assert) {
996-
const isPhone = devices.real().deviceType === 'phone';
997-
if(isPhone || browser.safari) {
1000+
if(shouldSkipOnPhone(assert)) {
1001+
return;
1002+
}
1003+
1004+
if(browser.safari) {
9981005
assert.ok(true, 'actual only for desktop browsers except Safari');
9991006
return;
10001007
}
@@ -1022,8 +1029,7 @@ const testCollision = (name, fixtureName, params, expectedHorzDist, expectedVert
10221029
});
10231030

10241031
QUnit.test('position should be correct relative to the viewport on mobile devices', function(assert) {
1025-
if(devices.real().deviceType !== 'phone') {
1026-
assert.ok(true, 'only for mobile devices');
1032+
if(shouldSkipOnDevices({ deviceTypes: ['desktop', 'tablet'], assert })) {
10271033
return;
10281034
}
10291035

@@ -1050,8 +1056,7 @@ const testCollision = (name, fixtureName, params, expectedHorzDist, expectedVert
10501056
});
10511057

10521058
QUnit.test('position should be correct relative to the viewport on mobile devices when window is scrolled', function(assert) {
1053-
if(devices.real().deviceType !== 'phone') {
1054-
assert.ok(true, 'only for mobile devices');
1059+
if(shouldSkipOnDevices({ deviceTypes: ['desktop', 'tablet'], assert })) {
10551060
return;
10561061
}
10571062

@@ -1078,9 +1083,12 @@ const testCollision = (name, fixtureName, params, expectedHorzDist, expectedVert
10781083
});
10791084

10801085
QUnit.test('position should be correct relative to the viewport on mobile devices when window is scrolled and window.scrollTop is bigger than visualViewport.offsetTop (T750017)', function(assert) {
1081-
const isPhone = devices.real().deviceType === 'phone';
1086+
if(shouldSkipOnDevices({ deviceTypes: ['desktop', 'tablet'], assert })) {
1087+
return;
1088+
}
1089+
10821090
const isAndroid = devices.real().platform === 'android';
1083-
if(!isPhone || isAndroid) {
1091+
if(isAndroid) {
10841092
// NOTE: scrollTop/Left are always 0 on android devices
10851093
assert.ok(true, 'only for non-android mobiles');
10861094
return;

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/columnsResizingReorderingModule.tests.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import { RowsView } from '__internal/grids/data_grid/module_not_extended/rows';
3030
import { GroupingHeaderPanelExtender } from '__internal/grids/data_grid/grouping/m_grouping';
3131
import { HeaderPanel } from '__internal/grids/data_grid/module_not_extended/header_panel';
3232
import Action from '__internal/core/m_action';
33-
import devices from '__internal/core/m_devices';
3433
import { getHeight } from 'core/utils/size';
3534
import publicComponentUtils from 'core/utils/public_component';
35+
import { shouldSkipOnMobile } from '../../helpers/device.js';
3636

3737
class TestDraggingHeader2 extends columnsResizingReordering.DraggingHeaderView {
3838
callDragCounter = 0;
@@ -2503,8 +2503,7 @@ QUnit.module('Columns resizing', {
25032503
});
25042504

25052505
QUnit.test('The free space row is not displayed when horizontal scrollbar is shown_B253714', function(assert) {
2506-
if(devices.real().deviceType !== 'desktop') {
2507-
assert.ok(true, 'height of scrollbar equal zero on mobile device');
2506+
if(shouldSkipOnMobile(assert, 'height of scrollbar equals zero on mobile devices')) {
25082507
return;
25092508
}
25102509

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { checkDxFontIcon, DX_ICON_XLSX_FILE_CONTENT_CODE, DX_ICON_EXPORT_SELECTE
2222
import { createDataGrid, baseModuleConfig, findShadowHostOrDocument } from '../../helpers/dataGridHelper.js';
2323
import { getOuterWidth } from 'core/utils/size';
2424
import { generateItems } from '../../helpers/dataGridMocks.js';
25+
import { shouldSkipOnMobile } from '../../helpers/device.js';
2526

2627
const DX_STATE_HOVER_CLASS = 'dx-state-hover';
2728
const CELL_UPDATED_CLASS = 'dx-datagrid-cell-updated-animation';
@@ -530,8 +531,7 @@ QUnit.module('Initialization', baseModuleConfig, () => {
530531
});
531532

532533
QUnit.test('Enable rows hover', function(assert) {
533-
if(devices.real().deviceType !== 'desktop') {
534-
assert.ok(true, 'hover is disabled for not desktop devices');
534+
if(shouldSkipOnMobile(assert, 'hover is disabled for non desktop devices')) {
535535
return;
536536
}
537537

@@ -556,8 +556,7 @@ QUnit.module('Initialization', baseModuleConfig, () => {
556556
});
557557

558558
QUnit.test('Enable rows hover and row position', function(assert) {
559-
if(devices.real().deviceType !== 'desktop') {
560-
assert.ok(true, 'hover is disabled for not desktop devices');
559+
if(shouldSkipOnMobile(assert, 'hover is disabled for non desktop devices')) {
561560
return;
562561
}
563562

@@ -613,8 +612,7 @@ QUnit.module('Initialization', baseModuleConfig, () => {
613612
});
614613

615614
QUnit.test('Enable rows hover via option method', function(assert) {
616-
if(devices.real().deviceType !== 'desktop') {
617-
assert.ok(true, 'hover is disabled for not desktop devices');
615+
if(shouldSkipOnMobile(assert, 'hover is disabled for non desktop devices')) {
618616
return;
619617
}
620618

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { generateItems } from '../../helpers/dataGridMocks.js';
1919
import { getOuterHeight } from 'core/utils/size';
2020
import { getEmulatorStyles } from '../../helpers/stylesHelper.js';
2121
import messageLocalization from 'common/core/localization/message';
22+
import { shouldSkipOnDesktop, shouldSkipOnMobile } from '../../helpers/device.js';
2223

2324
const TEXTEDITOR_INPUT_SELECTOR = '.dx-texteditor-input';
2425

@@ -3321,10 +3322,10 @@ QUnit.module('Editing', baseModuleConfig, () => {
33213322

33223323
['Batch', 'Cell'].forEach((editMode) => {
33233324
QUnit.testInActiveWindow(`${editMode} - Cell value should not be reset when a checkbox in a neigboring cell is clicked (T1023809)`, function(assert) {
3324-
if(devices.real().deviceType === 'desktop') {
3325-
assert.ok(true, 'test only for mobile devices');
3325+
if(shouldSkipOnDesktop(assert)) {
33263326
return;
33273327
}
3328+
33283329
const data = [
33293330
{ id: 1, field1: 'test', field2: true }
33303331
];
@@ -5268,8 +5269,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
52685269

52695270
// T553067
52705271
QUnit.testInActiveWindow('Enter key on editor should prevent default behaviour', function(assert) {
5271-
if(devices.real().deviceType !== 'desktop') {
5272-
assert.ok(true, 'keyboard navigation is disabled for not desktop devices');
5272+
if(shouldSkipOnMobile(assert, 'keyboard navigation is disabled for non-desktop devices')) {
52735273
return;
52745274
}
52755275

@@ -5338,8 +5338,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
53385338
});
53395339

53405340
QUnit.testInActiveWindow('Datebox editor\'s enter key handler should be replaced by noop (T819067)', function(assert) {
5341-
if(devices.real().deviceType !== 'desktop') {
5342-
assert.ok(true, 'keyboard navigation is disabled for not desktop devices');
5341+
if(shouldSkipOnMobile(assert, 'keyboard navigation is disabled for non-desktop devices')) {
53435342
return;
53445343
}
53455344

@@ -5369,8 +5368,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
53695368
});
53705369

53715370
QUnit.testInActiveWindow('Datebox changed value should be saved on enter key if useMaskBehaviour is true (T1070850)', function(assert) {
5372-
if(devices.real().deviceType !== 'desktop') {
5373-
assert.ok(true, 'keyboard navigation is disabled for not desktop devices');
5371+
if(shouldSkipOnMobile(assert, 'keyboard navigation is disabled for non-desktop devices')) {
53745372
return;
53755373
}
53765374

@@ -5423,8 +5421,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
54235421
['date', 'datetime'].forEach(dataType => {
54245422
[true, false].forEach(useMaskBehavior => {
54255423
QUnit.testInActiveWindow(`Datebox editor's value should be selected from calendar by keyboard (useMaskBehavior = ${useMaskBehavior}, dataType = ${dataType})`, function(assert) {
5426-
if(devices.real().deviceType !== 'desktop') {
5427-
assert.ok(true, 'keyboard navigation is disabled for not desktop devices');
5424+
if(shouldSkipOnMobile(assert, 'keyboard navigation is disabled for non-desktop devices')) {
54285425
return;
54295426
}
54305427

@@ -5598,8 +5595,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
55985595
});
55995596

56005597
QUnit.testInActiveWindow('Scroll positioned correct with fixed columns and editing', function(assert) {
5601-
if(devices.real().deviceType !== 'desktop') {
5602-
assert.ok(true, 'keyboard navigation is not actual for not desktop devices');
5598+
if(shouldSkipOnMobile(assert, 'keyboard navigation is disabled for non-desktop devices')) {
56035599
return;
56045600
}
56055601

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import pointerMock from '../../helpers/pointerMock.js';
3030
import DataGridWrapper from '../../helpers/wrappers/dataGridWrappers.js';
3131
import { findShadowHostOrDocument } from '../../helpers/dataGridHelper.js';
3232
import { DataSource } from 'common/data/data_source/data_source';
33+
import { shouldSkipOnMobile, shouldSkipOnDesktop } from '../../helpers/device.js';
3334

3435
QUnit.testStart(function() {
3536
const markup =
@@ -1107,8 +1108,7 @@ QUnit.module('Editing', {
11071108

11081109
// T124946
11091110
QUnit.test('Api method editCell with button', function(assert) {
1110-
if(devices.real().deviceType !== 'desktop') {
1111-
assert.ok(true, 'The problem is fixed for desktop only');
1111+
if(shouldSkipOnMobile(assert, 'The problem is fixed for desktop only')) {
11121112
return;
11131113
}
11141114

@@ -1688,10 +1688,10 @@ QUnit.module('Editing', {
16881688

16891689
// T749034
16901690
QUnit.test('Changed value should be saved on click outside dataGrid on mobile devices when cell editing mode', function(assert) {
1691-
if(devices.real().deviceType === 'desktop') {
1692-
assert.ok(true, 'test is not actual for desktop');
1691+
if(shouldSkipOnDesktop(assert)) {
16931692
return;
16941693
}
1694+
16951695
// arrange
16961696
const that = this;
16971697
const rowsView = this.rowsView;
@@ -1767,8 +1767,7 @@ QUnit.module('Editing', {
17671767

17681768
// T727856
17691769
QUnit.test('Not close Editing Cell in batch mode on down in editing cell and up in another cell', function(assert) {
1770-
if(devices.real().deviceType !== 'desktop') {
1771-
assert.ok(true, 'focus is not actual for mobile devices');
1770+
if(shouldSkipOnMobile(assert, 'focus is not actual for mobile devices')) {
17721771
return;
17731772
}
17741773
// arrange
@@ -7542,8 +7541,7 @@ QUnit.module('Editing with real dataController', {
75427541

75437542
// T319885
75447543
QUnit.testInActiveWindow('Focused lookup column with showEditorAlways is enabled', function(assert) {
7545-
if(devices.real().deviceType !== 'desktop') {
7546-
assert.ok(true, 'focus is not actual for mobile devices');
7544+
if(shouldSkipOnMobile(assert, 'focus is not actual for mobile devices')) {
75477545
return;
75487546
}
75497547

@@ -13304,8 +13302,7 @@ QUnit.module('Editing with validation', {
1330413302

1330513303
// T497279
1330613304
QUnit.testInActiveWindow('Insert row using extern button when edit mode cell', function(assert) {
13307-
if(devices.real().deviceType !== 'desktop') {
13308-
assert.ok(true, 'focus is not actual for mobile devices');
13305+
if(shouldSkipOnMobile(assert, 'focus is not actual for mobile devices')) {
1330913306
return;
1331013307
}
1331113308
// arrange

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/editorFactory.tests.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { MockColumnsController, MockDataController, setupDataGridModules } from
4747
import config from 'core/config';
4848
import typeUtils from 'core/utils/type';
4949
import { noop } from 'core/utils/common';
50+
import { shouldSkipOnMobile } from '../../helpers/device.js';
5051

5152
const TEXTEDITOR_INPUT_SELECTOR = '.dx-texteditor-input';
5253

@@ -1511,8 +1512,7 @@ QUnit.module('Focus', {
15111512

15121513
// T454719
15131514
QUnit.testInActiveWindow('Focus on dxLookup editor', function(assert) {
1514-
if(devices.real().deviceType !== 'desktop') {
1515-
assert.ok(true, 'if device is not desktop we do not test the case');
1515+
if(shouldSkipOnMobile(assert)) {
15161516
return;
15171517
}
15181518

@@ -1559,8 +1559,7 @@ QUnit.module('Focus', {
15591559

15601560
// T531176
15611561
QUnit.testInActiveWindow('Focus on dxTextArea editor', function(assert) {
1562-
if(devices.real().deviceType !== 'desktop') {
1563-
assert.ok(true, 'if device is not desktop we do not test the case');
1562+
if(shouldSkipOnMobile(assert)) {
15641563
return;
15651564
}
15661565

0 commit comments

Comments
 (0)