Skip to content

Commit 609e058

Browse files
authored
QUnit tests: reduced treeView tests to avoid stall (#31507) (#31525)
1 parent 6318b7e commit 609e058

21 files changed

+179
-318
lines changed

packages/devextreme/testing/tests/DevExpress.ui.widgets/treeViewParts/accessibility.js renamed to packages/devextreme/testing/tests/DevExpress.ui.widgets/treeView.accessibility.tests.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import $ from 'jquery';
22
import TreeView from 'ui/tree_view';
3-
import ariaAccessibilityTestHelper from '../../../helpers/ariaAccessibilityTestHelper.js';
3+
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';
44
import eventsEngine from 'common/core/events/core/events_engine';
55

66
const { module, test } = QUnit;
77

88
const CHECK_BOX_CLASS = 'dx-checkbox';
99

10+
QUnit.testStart(function() {
11+
const markup = '<div id="treeView"></div>';
12+
13+
$('#qunit-fixture').html(markup);
14+
});
15+
1016
let helper;
1117
[true, false].forEach((searchEnabled) => {
1218
module(`Aria accessibility, searchEnabled: ${searchEnabled}`, {

packages/devextreme/testing/tests/DevExpress.ui.widgets/treeViewParts/searching.js renamed to packages/devextreme/testing/tests/DevExpress.ui.widgets/treeView.searching.tests.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
/* global DATA, initTree */
2-
3-
import TreeViewTestWrapper from '../../../helpers/TreeViewTestHelper.js';
1+
import TreeViewTestWrapper from '../../helpers/TreeViewTestHelper.js';
2+
import { DATA } from './treeViewParts/testData.js';
3+
import { initTree } from './treeViewParts/testUtils.js';
44
import $ from 'jquery';
55
const createInstance = (options) => new TreeViewTestWrapper(options);
6+
import 'ui/tree_view';
67

78
const TREEVIEW_NODE_CONTAINER_CLASS = 'dx-treeview-node-container';
89

10+
QUnit.testStart(function() {
11+
const markup = '<div id="treeView"></div>';
12+
13+
$('#qunit-fixture').html(markup);
14+
});
15+
916
QUnit.module('searching');
1017

1118
['dataSource', 'items'].forEach((optionName) => {
@@ -37,9 +44,7 @@ const configs = [];
3744
[false, true].forEach((expanded) => {
3845
[false, true].forEach(selectNodesRecursive => {
3946
['multiple', 'single'].forEach(selectionMode => {
40-
['none', 'normal', 'selectAll'].forEach(showCheckBoxesMode => {
41-
configs.push({ dataSourceOption, expanded, selectNodesRecursive, selectionMode, showCheckBoxesMode });
42-
});
47+
configs.push({ dataSourceOption, expanded, selectNodesRecursive, selectionMode });
4348
});
4449
});
4550
});
@@ -51,11 +56,11 @@ function isLazyDataSourceMode(wrapper) {
5156
}
5257

5358
configs.forEach(config => {
54-
QUnit.test(`dataSource: ${config.dataSourceOption}, selectionMode:${config.selectionMode}, showCheckBoxesMode: ${config.showCheckBoxesMode}, itemsExpr:"subItems", dataStructure: tree, keyExpr:undefined -> search("2"); (T871605)`, function(assert) {
59+
QUnit.test(`dataSource: ${config.dataSourceOption}, selectionMode:${config.selectionMode}, itemsExpr:"subItems", dataStructure: tree, keyExpr:undefined -> search("2"); (T871605)`, function(assert) {
5560
const options = {
5661
itemsExpr: 'subItems',
5762
selectNodesRecursive: config.selectNodesRecursive,
58-
showCheckBoxesMode: config.showCheckBoxesMode,
63+
showCheckBoxesMode: 'normal',
5964
selectionMode: config.selectionMode,
6065
dataStructure: 'tree'
6166
};
@@ -65,25 +70,25 @@ configs.forEach(config => {
6570
wrapper.instance.option('searchValue', '2');
6671

6772
const $item1 = wrapper.getElement().find('[aria-label="item1"]');
68-
assert.equal($item1.length, 1, 'item1 is exists');
69-
assert.equal(wrapper.hasInvisibleClass($item1), false, 'item1 is visible');
73+
assert.strictEqual($item1.length, 1, 'item1 is exists');
74+
assert.strictEqual(wrapper.hasInvisibleClass($item1), false, 'item1 is visible');
7075

7176
const $item1_1 = wrapper.getElement().find('[aria-label="item1_1"]');
72-
assert.equal($item1_1.length, 0, 'item1_1 doesnt exists');
77+
assert.strictEqual($item1_1.length, 0, 'item1_1 doesnt exists');
7378

7479
const $item1_2 = wrapper.getElement().find('[aria-label="item1_2"]');
75-
assert.equal($item1_2.length, 1, 'item1_2 is exists');
76-
assert.equal(wrapper.hasInvisibleClass($item1_2), false, 'item1_2 is visible');
80+
assert.strictEqual($item1_2.length, 1, 'item1_2 is exists');
81+
assert.strictEqual(wrapper.hasInvisibleClass($item1_2), false, 'item1_2 is visible');
7782
});
7883

7984
[false, true].forEach((virtualModeEnabled) => {
8085
[null, 0, -1, ''].forEach(rootValue => {
81-
QUnit.test(`dataSource: ${config.dataSourceOption}, selectionMode:${config.selectionMode}, showCheckBoxesMode: ${config.showCheckBoxesMode}, virtualModeEnabled: ${config.virtualModeEnabled}, expanded: ${config.expanded}, dataStructure: plain, rootValue: ${rootValue} -> search("1"); (T906787)`, function(assert) {
86+
QUnit.test(`dataSource: ${config.dataSourceOption}, selectionMode:${config.selectionMode}, virtualModeEnabled: ${config.virtualModeEnabled}, expanded: ${config.expanded}, dataStructure: plain, rootValue: ${rootValue} -> search("1"); (T906787)`, function(assert) {
8287
const options = {
8388
rootValue,
8489
virtualModeEnabled,
8590
selectNodesRecursive: config.selectNodesRecursive,
86-
showCheckBoxesMode: config.showCheckBoxesMode,
91+
showCheckBoxesMode: 'normal',
8792
selectionMode: config.selectionMode,
8893
dataStructure: 'plain'
8994
};
@@ -98,17 +103,16 @@ configs.forEach(config => {
98103
const $item1 = wrapper.getElement().find('[aria-label="item1"]');
99104
const $item2 = wrapper.getElement().find('[aria-label="item2"]');
100105
const $item1_1 = wrapper.getElement().find('[aria-label="item1_1"]');
101-
const $item1_2 = wrapper.getElement().find('[aria-label="item1_2"]');
102106

103-
assert.equal($item1.length, 1, 'item1 is exists');
104-
assert.equal(wrapper.hasInvisibleClass($item1), false, 'item1 is visible');
107+
assert.strictEqual($item1.length, 1, 'item1 is exists');
108+
assert.strictEqual(wrapper.hasInvisibleClass($item1), false, 'item1 is visible');
105109

106-
assert.equal($item2.length, 0, 'item2 doesnt exists');
110+
assert.strictEqual($item2.length, 0, 'item2 doesnt exists');
107111
if(isLazyDataSourceMode(wrapper) && !config.expanded) {
108-
assert.equal($item1_1.length, 0, 'item1_1 doesnt exists in virtual mode');
112+
assert.strictEqual($item1_1.length, 0, 'item1_1 doesnt exists in virtual mode');
109113
} else {
110-
assert.equal($item1_1.length, 1, 'item1_2 is exists');
111-
assert.equal(wrapper.hasInvisibleClass($item1_2), false, 'item1_1 is visible');
114+
assert.strictEqual($item1_1.length, 1, 'item1_1 exists');
115+
assert.strictEqual(wrapper.hasInvisibleClass($item1_1), false, 'item1_1 is visible');
112116
}
113117
});
114118
});

packages/devextreme/testing/tests/DevExpress.ui.widgets/treeViewParts/selection.js renamed to packages/devextreme/testing/tests/DevExpress.ui.widgets/treeView.selection.tests.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import $ from 'jquery';
2-
import keyboardMock from '../../../helpers/keyboardMock.js';
2+
import keyboardMock from '../../helpers/keyboardMock.js';
33
import eventsEngine from 'common/core/events/core/events_engine';
4-
import TreeViewTestWrapper from '../../../helpers/TreeViewTestHelper.js';
4+
import TreeViewTestWrapper from '../../helpers/TreeViewTestHelper.js';
5+
import 'ui/tree_view';
56

67
const { module, test } = QUnit;
78

89
const createInstance = (options) => new TreeViewTestWrapper(options);
910

11+
QUnit.testStart(function() {
12+
const markup = '<div id="treeView"></div>';
13+
14+
$('#qunit-fixture').html(markup);
15+
});
16+
1017
module('selection common', () => {
1118
test('selection should work without checkboxes on init', function() {
1219
const items = [{ text: 'item 1', selected: true }, { text: 'item 2' }];
Lines changed: 1 addition & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,12 @@
1-
/* global stripFunctions */
2-
31
import $ from 'jquery';
4-
import { CustomStore } from 'common/data/custom_store';
5-
import ArrayStore from 'common/data/array_store';
6-
import { isFunction } from 'core/utils/type';
7-
82
import 'ui/tree_view';
93

10-
const { testStart } = QUnit;
11-
12-
testStart(function() {
4+
QUnit.testStart(function() {
135
const markup = '<div id="treeView"></div>';
146

157
$('#qunit-fixture').html(markup);
168
});
179

18-
window.internals = {
19-
NODE_CONTAINER_CLASS: 'dx-treeview-node-container',
20-
OPENED_NODE_CONTAINER_CLASS: 'dx-treeview-node-container-opened',
21-
NODE_CLASS: 'dx-treeview-node',
22-
ITEM_CLASS: 'dx-treeview-item',
23-
TOGGLE_ITEM_VISIBILITY_CLASS: 'dx-treeview-toggle-item-visibility',
24-
TOGGLE_ITEM_VISIBILITY_OPENED_CLASS: 'dx-treeview-toggle-item-visibility-opened',
25-
};
26-
27-
window.DATA = (function() {
28-
return [
29-
// 0
30-
[
31-
{ key: 1, text: 'Item 1' },
32-
{ key: 2, text: 'Item 2' },
33-
{ key: 3, text: 'Item 3' }
34-
],
35-
// 1
36-
[
37-
{
38-
key: 1, text: 'Item 1', items: [
39-
{ key: 12, text: 'Nested item 1' },
40-
{
41-
key: 13, text: 'Nested item 2', items: [
42-
{ key: 131, text: 'Last item' }
43-
]
44-
}
45-
]
46-
},
47-
{ key: 2, text: 'Item 2' }
48-
],
49-
// 2
50-
[
51-
{
52-
key: 1, text: 'Item 1', items: [
53-
{ key: 12, text: 'Nested item 1' },
54-
{ key: 13, text: 'Nested item 2' }
55-
]
56-
},
57-
{ key: 2, text: 'Item 2' }
58-
],
59-
// 3
60-
[
61-
{
62-
itemId: 1,
63-
itemName: 'Item 1',
64-
children: [
65-
{ itemId: 11, itemName: 'Nested Item 1' }
66-
]
67-
},
68-
{ itemId: 2, itemName: 'Item 2' }
69-
],
70-
// 4
71-
[
72-
{ 'Id': 1, 'ParentId': 0, 'Name': 'Animals' },
73-
{ 'Id': 2, 'ParentId': 1, 'Name': 'Cat' },
74-
{ 'Id': 3, 'ParentId': 1, 'Name': 'Dog' },
75-
{ 'Id': 5, 'ParentId': 2, 'Name': 'Abyssinian' },
76-
{ 'Id': 8, 'ParentId': 3, 'Name': 'Affenpinscher' },
77-
{ 'Id': 9, 'ParentId': 3, 'Name': 'Afghan Hound' },
78-
{ 'Id': 12, 'ParentId': 0, 'Name': 'Birds' },
79-
{ 'Id': 13, 'ParentId': 12, 'Name': 'Akekee' }
80-
],
81-
// 5
82-
[
83-
{
84-
// id: "!/#$%&'()*+,./:;<=>?@[\]^`{|}~",
85-
id: 1,
86-
text: 'Item 1',
87-
items: [
88-
{ id: 11, text: 'Nested Item 1' },
89-
{
90-
id: 12, text: 'Nested Item 2', items: [
91-
{ id: 121, text: 'Third level item 1' },
92-
{ id: 122, text: 'Third level item 2' }
93-
]
94-
}
95-
]
96-
},
97-
{ id: 2, text: 'Item 2' }
98-
],
99-
[
100-
{
101-
id: 1,
102-
text: 'Item 1',
103-
items: [
104-
{
105-
id: 12, text: 'Nested Item 2', items: [
106-
{ id: 121, text: 'Third level item 1' },
107-
{ id: 122, text: 'Third level item 2' }
108-
]
109-
}
110-
]
111-
},
112-
{
113-
id: 2,
114-
text: 'Item 2',
115-
items: [
116-
{
117-
id: 22, text: 'Nested Item 2', items: [
118-
{ id: 221, text: 'Third level item 1' },
119-
{ id: 222, text: 'Third level item 2' }
120-
]
121-
}
122-
]
123-
}
124-
]
125-
];
126-
})();
127-
128-
window.data2 = [
129-
{ id: 1, parentId: 0, text: 'Animals' },
130-
{ id: 2, parentId: 1, text: 'Cat' },
131-
{ id: 3, parentId: 1, text: 'Dog' },
132-
{ id: 4, parentId: 1, text: 'Cow' },
133-
{ id: 5, parentId: 2, text: 'Abyssinian' },
134-
{ id: 6, parentId: 2, text: 'Aegean cat' },
135-
{ id: 7, parentId: 2, text: 'Australian Mist' },
136-
{ id: 8, parentId: 3, text: 'Affenpinscher' },
137-
{ id: 9, parentId: 3, text: 'Afghan Hound' },
138-
{ id: 10, parentId: 3, text: 'Airedale Terrier' },
139-
{ id: 11, parentId: 3, text: 'Akita Inu' },
140-
{ id: 12, parentId: 0, text: 'Birds' },
141-
{ id: 13, parentId: 12, text: 'Akekee' },
142-
{ id: 14, parentId: 12, text: 'Arizona Woodpecker' },
143-
{ id: 15, parentId: 12, text: 'Black-chinned Sparrow' },
144-
{ id: 16, parentId: 0, text: 'Others' }
145-
];
146-
147-
window.dataID = [
148-
{ id: 1, 'elternId': 0, text: 'Animals' },
149-
{ id: 2, 'elternId': 1, text: 'Cat' },
150-
{ id: 3, 'elternId': 2, text: 'Abyssinian' },
151-
{ id: 4, 'elternId': 0, text: 'Birds' },
152-
{ id: 5, 'elternId': 4, text: 'Akekee' }
153-
];
154-
155-
window.initTree = function(options) {
156-
return $('#treeView').dxTreeView(options);
157-
};
158-
159-
window.stripFunctions = function(obj) {
160-
const result = $.extend(true, {}, obj);
161-
$.each(result, function(field, value) {
162-
if(isFunction(value)) {
163-
delete result[field];
164-
}
165-
166-
if(field === 'parent' && result.parent) {
167-
result.parent = stripFunctions(result.parent);
168-
}
169-
170-
});
171-
172-
return result;
173-
};
174-
175-
window.makeSlowDataSource = function(data) {
176-
return {
177-
store: new CustomStore({
178-
load: function(loadOptions) {
179-
return $.Deferred(function(d) {
180-
setTimeout(function() {
181-
new ArrayStore(data).load(loadOptions).done(function() {
182-
d.resolve.apply(d, arguments);
183-
});
184-
}, 300);
185-
}).promise();
186-
}
187-
})
188-
};
189-
};
190-
191-
import 'generic_light.css!';
192-
193-
import './treeViewParts/accessibility.js';
19410
import './treeViewParts/animation.js';
19511
import './treeViewParts/events.js';
19612
import './treeViewParts/expresions.js';
@@ -201,11 +17,8 @@ import './treeViewParts/lazyRendering.js';
20117
import './treeViewParts/optionChanged.js';
20218
import './treeViewParts/regression.js';
20319
import './treeViewParts/rendering.js';
204-
import './treeViewParts/selection.js';
205-
import './treeViewParts/searching.js';
20620
import './treeViewParts/selectAllMode.js';
20721
import './treeViewParts/selectAllWithSelectNodesRecursiveFalse.js';
20822
import './treeViewParts/selectNodesRecursiveTrue.js';
20923
import './treeViewParts/treeview.size.tests.js';
21024
import './treeViewParts/usageWithoutKeys.js';
211-
import './treeViewParts/virtualMode.js';

packages/devextreme/testing/tests/DevExpress.ui.widgets/treeViewParts/virtualMode.js renamed to packages/devextreme/testing/tests/DevExpress.ui.widgets/treeView.virtualMode.tests.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global data2, dataID, internals, makeSlowDataSource */
2-
31
import $ from 'jquery';
42
import { noop } from 'core/utils/common';
53
import fx from 'common/core/animation/fx';
@@ -9,14 +7,22 @@ import { CustomStore } from 'common/data/custom_store';
97
import dblclickEvent from 'common/core/events/dblclick';
108
import TreeView from 'ui/tree_view';
119
import eventsEngine from 'common/core/events/core/events_engine';
12-
import TreeViewTestWrapper from '../../../helpers/TreeViewTestHelper.js';
10+
import TreeViewTestWrapper from '../../helpers/TreeViewTestHelper.js';
1311
import LoadIndicator from 'ui/load_indicator';
12+
import { internals, data2, dataID } from './treeViewParts/testData.js';
13+
import { makeSlowDataSource } from './treeViewParts/testUtils.js';
1414

1515
const { module, test, assert } = QUnit;
1616
const createInstance = (options) => new TreeViewTestWrapper(options);
1717

1818
import 'generic_light.css!';
1919

20+
QUnit.testStart(function() {
21+
const markup = '<div id="treeView"></div>';
22+
23+
$('#qunit-fixture').html(markup);
24+
});
25+
2026
const NODE_LOAD_INDICATOR_CLASS = 'dx-treeview-node-loadindicator';
2127
const TREEVIEW_ITEM_CLASS = 'dx-treeview-item';
2228
const TREEVIEW_NODE_CLASS = 'dx-treeview-node';

packages/devextreme/testing/tests/DevExpress.ui.widgets/treeViewParts/animation.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* global internals */
2-
31
import $ from 'jquery';
42
import fx from 'common/core/animation/fx';
53
import keyboardMock from '../../../helpers/keyboardMock.js';
4+
import { internals } from './testData.js';
65

76
QUnit.module('Animation', {
87
beforeEach: function() {

0 commit comments

Comments
 (0)