@dhis2-ui/organisation-unit-tree 9.4.4 → 9.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__e2e__/common.js +26 -147
- package/build/cjs/__e2e__/get-organisation-unit-data.js +140 -0
- package/build/cjs/__e2e__/namespace.js +8 -0
- package/build/cjs/features/children_as_child_nodes/index.js +4 -4
- package/build/cjs/features/controlled_expanded/index.js +13 -11
- package/build/cjs/features/displaying_loading_error/index.js +8 -8
- package/build/cjs/features/expanded/index.js +11 -11
- package/build/cjs/features/force_reload/index.js +5 -5
- package/build/cjs/features/highlight/index.js +3 -3
- package/build/cjs/features/loading_state/index.js +5 -5
- package/build/cjs/features/multi_selection/index.js +17 -17
- package/build/cjs/features/no_selection/index.js +7 -7
- package/build/cjs/features/path_based_filtering/index.js +15 -15
- package/build/cjs/features/single_selection/index.js +12 -16
- package/build/cjs/features/single_selection.feature +1 -1
- package/build/cjs/features/sub_unit_as_root/index.js +13 -19
- package/build/cjs/features/tree_api/index.js +22 -22
- package/build/es/__e2e__/common.js +11 -141
- package/build/es/__e2e__/get-organisation-unit-data.js +131 -0
- package/build/es/__e2e__/namespace.js +1 -0
- package/build/es/features/children_as_child_nodes/index.js +1 -1
- package/build/es/features/controlled_expanded/index.js +3 -2
- package/build/es/features/displaying_loading_error/index.js +1 -1
- package/build/es/features/expanded/index.js +1 -1
- package/build/es/features/force_reload/index.js +1 -1
- package/build/es/features/highlight/index.js +1 -1
- package/build/es/features/loading_state/index.js +1 -1
- package/build/es/features/multi_selection/index.js +1 -1
- package/build/es/features/no_selection/index.js +1 -1
- package/build/es/features/path_based_filtering/index.js +2 -2
- package/build/es/features/single_selection/index.js +3 -7
- package/build/es/features/single_selection.feature +1 -1
- package/build/es/features/sub_unit_as_root/index.js +1 -7
- package/build/es/features/tree_api/index.js +1 -1
- package/package.json +5 -5
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.delayResponse = exports.dataProviderData = exports.createDecoratorStatefulMultiSelection = exports.createDecoratorCustomDataProvider = exports.StatefulMultiSelectionWrapper = void 0;
|
|
7
|
+
Object.defineProperty(exports, "getOrganisationUnitData", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _getOrganisationUnitData.getOrganisationUnitData;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "namespace", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _namespace.namespace;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
7
19
|
|
|
8
20
|
var _appRuntime = require("@dhis2/app-runtime");
|
|
9
21
|
|
|
@@ -11,6 +23,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
23
|
|
|
12
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
25
|
|
|
26
|
+
var _getOrganisationUnitData = require("./get-organisation-unit-data.js");
|
|
27
|
+
|
|
28
|
+
var _namespace = require("./namespace.js");
|
|
29
|
+
|
|
14
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
31
|
|
|
16
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -18,154 +34,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
18
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
35
|
|
|
20
36
|
/* eslint-disable react/display-name */
|
|
21
|
-
const namespace = 'OrganisationUnitTree';
|
|
22
|
-
exports.namespace = namespace;
|
|
23
|
-
|
|
24
37
|
const delayResponse = (delay, response) => () => new Promise(resolve => setTimeout(() => resolve(response), delay));
|
|
25
38
|
|
|
26
39
|
exports.delayResponse = delayResponse;
|
|
27
|
-
|
|
28
|
-
const createResponse = _ref => {
|
|
29
|
-
let {
|
|
30
|
-
fields,
|
|
31
|
-
id,
|
|
32
|
-
path,
|
|
33
|
-
displayName,
|
|
34
|
-
children
|
|
35
|
-
} = _ref;
|
|
36
|
-
return { ...(fields.includes('id') ? {
|
|
37
|
-
id
|
|
38
|
-
} : {}),
|
|
39
|
-
...(fields.includes('path') ? {
|
|
40
|
-
path
|
|
41
|
-
} : {}),
|
|
42
|
-
...(fields.includes('displayName') ? {
|
|
43
|
-
displayName
|
|
44
|
-
} : {}),
|
|
45
|
-
...(fields.includes('children::size') ? {
|
|
46
|
-
children: children.length
|
|
47
|
-
} : {}),
|
|
48
|
-
...(fields.includes('children[id,path,displayName]') ? {
|
|
49
|
-
children
|
|
50
|
-
} : {})
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const getOrganisationUnitData = (id, _ref2) => {
|
|
55
|
-
let {
|
|
56
|
-
fields
|
|
57
|
-
} = _ref2;
|
|
58
|
-
let data;
|
|
59
|
-
|
|
60
|
-
if (id === 'A0000000000') {
|
|
61
|
-
data = createResponse({
|
|
62
|
-
fields,
|
|
63
|
-
id: 'A0000000000',
|
|
64
|
-
path: '/A0000000000',
|
|
65
|
-
displayName: 'Org Unit 1',
|
|
66
|
-
children: [{
|
|
67
|
-
id: 'A0000000001',
|
|
68
|
-
path: '/A0000000000/A0000000001',
|
|
69
|
-
displayName: 'Org Unit 2'
|
|
70
|
-
}, {
|
|
71
|
-
id: 'A0000000002',
|
|
72
|
-
path: '/A0000000000/A0000000002',
|
|
73
|
-
displayName: 'Org Unit 3'
|
|
74
|
-
}, {
|
|
75
|
-
id: 'A0000000006',
|
|
76
|
-
path: '/A0000000000/A0000000006',
|
|
77
|
-
displayName: 'Org Unit 7'
|
|
78
|
-
}]
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (id === 'A0000000001') {
|
|
83
|
-
data = createResponse({
|
|
84
|
-
fields,
|
|
85
|
-
id: 'A0000000001',
|
|
86
|
-
path: '/A0000000000/A0000000001',
|
|
87
|
-
displayName: 'Org Unit 2',
|
|
88
|
-
children: [{
|
|
89
|
-
id: 'A0000000003',
|
|
90
|
-
path: '/A0000000000/A0000000001/A0000000003',
|
|
91
|
-
children: [],
|
|
92
|
-
displayName: 'Org Unit 4'
|
|
93
|
-
}, {
|
|
94
|
-
id: 'A0000000004',
|
|
95
|
-
path: '/A0000000000/A0000000001/A0000000004',
|
|
96
|
-
children: [],
|
|
97
|
-
displayName: 'Org Unit 5'
|
|
98
|
-
}]
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (id === 'A0000000002') {
|
|
103
|
-
data = createResponse({
|
|
104
|
-
fields,
|
|
105
|
-
displayName: 'Org Unit 3',
|
|
106
|
-
id: 'A0000000002',
|
|
107
|
-
path: '/A0000000000/A0000000002',
|
|
108
|
-
children: []
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (id === 'A0000000003') {
|
|
113
|
-
data = createResponse({
|
|
114
|
-
fields,
|
|
115
|
-
displayName: 'Org Unit 4',
|
|
116
|
-
id: 'A0000000003',
|
|
117
|
-
path: '/A0000000000/A0000000001/A0000000003',
|
|
118
|
-
children: [{
|
|
119
|
-
id: 'A0000000007',
|
|
120
|
-
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
121
|
-
children: [],
|
|
122
|
-
displayName: 'Org Unit 8'
|
|
123
|
-
}]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (id === 'A0000000004') {
|
|
128
|
-
data = createResponse({
|
|
129
|
-
fields,
|
|
130
|
-
displayName: 'Org Unit 5',
|
|
131
|
-
id: 'A0000000004',
|
|
132
|
-
path: '/A0000000000/A0000000001/A0000000004',
|
|
133
|
-
children: []
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (id === 'A0000000006') {
|
|
138
|
-
data = createResponse({
|
|
139
|
-
fields,
|
|
140
|
-
displayName: 'Org Unit 7',
|
|
141
|
-
id: 'A0000000006',
|
|
142
|
-
path: '/A0000000000/A0000000006',
|
|
143
|
-
children: []
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (id === 'A0000000007') {
|
|
148
|
-
data = createResponse({
|
|
149
|
-
fields,
|
|
150
|
-
displayName: 'Org Unit 8',
|
|
151
|
-
id: 'A0000000007',
|
|
152
|
-
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
153
|
-
children: []
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return data;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
exports.getOrganisationUnitData = getOrganisationUnitData;
|
|
161
40
|
const dataProviderData = {
|
|
162
|
-
organisationUnits: (_,
|
|
41
|
+
organisationUnits: (_, _ref) => {
|
|
163
42
|
let {
|
|
164
43
|
id,
|
|
165
44
|
params = {}
|
|
166
|
-
} =
|
|
45
|
+
} = _ref;
|
|
167
46
|
console.log('id, params', id, params);
|
|
168
|
-
const data = getOrganisationUnitData(id, params);
|
|
47
|
+
const data = (0, _getOrganisationUnitData.getOrganisationUnitData)(id, params);
|
|
169
48
|
|
|
170
49
|
if (!data) {
|
|
171
50
|
return Promise.reject(new Error('404 - Org unit not found'));
|
|
@@ -176,18 +55,18 @@ const dataProviderData = {
|
|
|
176
55
|
};
|
|
177
56
|
exports.dataProviderData = dataProviderData;
|
|
178
57
|
|
|
179
|
-
const StatefulMultiSelectionWrapper =
|
|
58
|
+
const StatefulMultiSelectionWrapper = _ref2 => {
|
|
180
59
|
let {
|
|
181
60
|
children,
|
|
182
61
|
onSelectionChange = () => null
|
|
183
|
-
} =
|
|
62
|
+
} = _ref2;
|
|
184
63
|
const [selected, setSelected] = (0, _react.useState)([]);
|
|
185
64
|
return children({
|
|
186
65
|
selected,
|
|
187
|
-
onChange:
|
|
66
|
+
onChange: _ref3 => {
|
|
188
67
|
let {
|
|
189
68
|
selected: newSelected
|
|
190
|
-
} =
|
|
69
|
+
} = _ref3;
|
|
191
70
|
setSelected(newSelected);
|
|
192
71
|
onSelectionChange(newSelected);
|
|
193
72
|
}
|
|
@@ -203,11 +82,11 @@ StatefulMultiSelectionWrapper.propTypes = {
|
|
|
203
82
|
const createDecoratorStatefulMultiSelection = args => {
|
|
204
83
|
return Story => /*#__PURE__*/_react.default.createElement(StatefulMultiSelectionWrapper, {
|
|
205
84
|
onSelectionChange: args === null || args === void 0 ? void 0 : args.onSelectionChange
|
|
206
|
-
},
|
|
85
|
+
}, _ref4 => {
|
|
207
86
|
let {
|
|
208
87
|
selected,
|
|
209
88
|
onChange
|
|
210
|
-
} =
|
|
89
|
+
} = _ref4;
|
|
211
90
|
return /*#__PURE__*/_react.default.createElement(Story, {
|
|
212
91
|
selected: selected,
|
|
213
92
|
onChange: onChange
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getOrganisationUnitData = void 0;
|
|
7
|
+
|
|
8
|
+
const createResponse = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
fields,
|
|
11
|
+
id,
|
|
12
|
+
path,
|
|
13
|
+
displayName,
|
|
14
|
+
children
|
|
15
|
+
} = _ref;
|
|
16
|
+
return { ...(fields.includes('id') ? {
|
|
17
|
+
id
|
|
18
|
+
} : {}),
|
|
19
|
+
...(fields.includes('path') ? {
|
|
20
|
+
path
|
|
21
|
+
} : {}),
|
|
22
|
+
...(fields.includes('displayName') ? {
|
|
23
|
+
displayName
|
|
24
|
+
} : {}),
|
|
25
|
+
...(fields.includes('children::size') ? {
|
|
26
|
+
children: children.length
|
|
27
|
+
} : {}),
|
|
28
|
+
...(fields.includes('children[id,path,displayName]') ? {
|
|
29
|
+
children
|
|
30
|
+
} : {})
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getOrganisationUnitData = (id, _ref2) => {
|
|
35
|
+
let {
|
|
36
|
+
fields
|
|
37
|
+
} = _ref2;
|
|
38
|
+
let data;
|
|
39
|
+
|
|
40
|
+
if (id === 'A0000000000') {
|
|
41
|
+
data = createResponse({
|
|
42
|
+
fields,
|
|
43
|
+
id: 'A0000000000',
|
|
44
|
+
path: '/A0000000000',
|
|
45
|
+
displayName: 'Org Unit 1',
|
|
46
|
+
children: [{
|
|
47
|
+
id: 'A0000000001',
|
|
48
|
+
path: '/A0000000000/A0000000001',
|
|
49
|
+
displayName: 'Org Unit 2'
|
|
50
|
+
}, {
|
|
51
|
+
id: 'A0000000002',
|
|
52
|
+
path: '/A0000000000/A0000000002',
|
|
53
|
+
displayName: 'Org Unit 3'
|
|
54
|
+
}, {
|
|
55
|
+
id: 'A0000000006',
|
|
56
|
+
path: '/A0000000000/A0000000006',
|
|
57
|
+
displayName: 'Org Unit 7'
|
|
58
|
+
}]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (id === 'A0000000001') {
|
|
63
|
+
data = createResponse({
|
|
64
|
+
fields,
|
|
65
|
+
id: 'A0000000001',
|
|
66
|
+
path: '/A0000000000/A0000000001',
|
|
67
|
+
displayName: 'Org Unit 2',
|
|
68
|
+
children: [{
|
|
69
|
+
id: 'A0000000003',
|
|
70
|
+
path: '/A0000000000/A0000000001/A0000000003',
|
|
71
|
+
children: [],
|
|
72
|
+
displayName: 'Org Unit 4'
|
|
73
|
+
}, {
|
|
74
|
+
id: 'A0000000004',
|
|
75
|
+
path: '/A0000000000/A0000000001/A0000000004',
|
|
76
|
+
children: [],
|
|
77
|
+
displayName: 'Org Unit 5'
|
|
78
|
+
}]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (id === 'A0000000002') {
|
|
83
|
+
data = createResponse({
|
|
84
|
+
fields,
|
|
85
|
+
displayName: 'Org Unit 3',
|
|
86
|
+
id: 'A0000000002',
|
|
87
|
+
path: '/A0000000000/A0000000002',
|
|
88
|
+
children: []
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (id === 'A0000000003') {
|
|
93
|
+
data = createResponse({
|
|
94
|
+
fields,
|
|
95
|
+
displayName: 'Org Unit 4',
|
|
96
|
+
id: 'A0000000003',
|
|
97
|
+
path: '/A0000000000/A0000000001/A0000000003',
|
|
98
|
+
children: [{
|
|
99
|
+
id: 'A0000000007',
|
|
100
|
+
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
101
|
+
children: [],
|
|
102
|
+
displayName: 'Org Unit 8'
|
|
103
|
+
}]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (id === 'A0000000004') {
|
|
108
|
+
data = createResponse({
|
|
109
|
+
fields,
|
|
110
|
+
displayName: 'Org Unit 5',
|
|
111
|
+
id: 'A0000000004',
|
|
112
|
+
path: '/A0000000000/A0000000001/A0000000004',
|
|
113
|
+
children: []
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (id === 'A0000000006') {
|
|
118
|
+
data = createResponse({
|
|
119
|
+
fields,
|
|
120
|
+
displayName: 'Org Unit 7',
|
|
121
|
+
id: 'A0000000006',
|
|
122
|
+
path: '/A0000000000/A0000000006',
|
|
123
|
+
children: []
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (id === 'A0000000007') {
|
|
128
|
+
data = createResponse({
|
|
129
|
+
fields,
|
|
130
|
+
displayName: 'Org Unit 8',
|
|
131
|
+
id: 'A0000000007',
|
|
132
|
+
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
133
|
+
children: []
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return data;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.getOrganisationUnitData = getOrganisationUnitData;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Given)('an OrganisationUnitTree with children is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'Closed with children');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('the node is open', () => {
|
|
9
9
|
cy.get('[data-test="dhis2-uiwidgets-orgunittree"] > [data-test="dhis2-uiwidgets-orgunittree-node"]').as('rootUnit');
|
|
10
10
|
cy.get('@rootUnit').openOrgUnitNode();
|
|
11
11
|
});
|
|
12
|
-
(0,
|
|
12
|
+
(0, _cypressCucumberPreprocessor.Then)("its children are nodes inside the unit's node", () => {
|
|
13
13
|
cy.get('@rootUnit').find('> [data-test="dhis2-uiwidgets-orgunittree-node-content"] > [data-test="dhis2-uiwidgets-orgunittree-node-leaves"]').children().should('have.length', 3).and(children => children.each((_, child) => {
|
|
14
14
|
const $child = Cypress.$(child);
|
|
15
15
|
const dataTest = $child.data('test');
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _getOrganisationUnitData = require("../../__e2e__/get-organisation-unit-data.js");
|
|
6
|
+
|
|
7
|
+
var _namespace = require("../../__e2e__/namespace.js");
|
|
6
8
|
|
|
7
9
|
const expectOrgUnitsToBeDisplayed = ids => {
|
|
8
|
-
const expandedLabels = ids.map(id => (0,
|
|
10
|
+
const expandedLabels = ids.map(id => (0, _getOrganisationUnitData.getOrganisationUnitData)(id, {
|
|
9
11
|
fields: ['displayName']
|
|
10
12
|
}).displayName);
|
|
11
13
|
expandedLabels.forEach(label => {
|
|
@@ -15,7 +17,7 @@ const expectOrgUnitsToBeDisplayed = ids => {
|
|
|
15
17
|
|
|
16
18
|
const expectOrgUnitsToNotBeDisplayed = ids => {
|
|
17
19
|
const expandedLabels = ids.map(id => {
|
|
18
|
-
const data = (0,
|
|
20
|
+
const data = (0, _getOrganisationUnitData.getOrganisationUnitData)(id, {
|
|
19
21
|
fields: ['displayName']
|
|
20
22
|
});
|
|
21
23
|
return data.displayName;
|
|
@@ -25,35 +27,35 @@ const expectOrgUnitsToNotBeDisplayed = ids => {
|
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
(0,
|
|
29
|
-
cy.visitStory(
|
|
30
|
+
(0, _cypressCucumberPreprocessor.Given)('the initial state of the controlled expanded prop has some paths', () => {
|
|
31
|
+
cy.visitStory(_namespace.namespace, 'Controlled');
|
|
30
32
|
cy.window().then(win => {
|
|
31
33
|
cy.wrap(win.initiallyExpandedPaths).as('providedPaths');
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
|
-
(0,
|
|
36
|
+
(0, _cypressCucumberPreprocessor.When)('the org unit tree should is done loading the provided paths', () => {
|
|
35
37
|
cy.window().then(win => {
|
|
36
38
|
const expandedIds = win.initiallyExpandedPaths.map(path => path.match(/[^/]+$/)[0]);
|
|
37
39
|
expectOrgUnitsToBeDisplayed(expandedIds);
|
|
38
40
|
});
|
|
39
41
|
});
|
|
40
|
-
(0,
|
|
42
|
+
(0, _cypressCucumberPreprocessor.When)('the user clicks on a button to collapse one of the opened paths', () => {
|
|
41
43
|
cy.window().then(win => {
|
|
42
44
|
cy.wrap([win.orgUnitPathToExpand]).as('providedPaths');
|
|
43
45
|
});
|
|
44
46
|
cy.get('[data-test="org-unit-toggle"]').click();
|
|
45
47
|
});
|
|
46
|
-
(0,
|
|
48
|
+
(0, _cypressCucumberPreprocessor.Then)('the org unit tree should open the provided paths when done loading', () => {
|
|
47
49
|
cy.get('@providedPaths').then(providedPaths => {
|
|
48
50
|
const providedIds = providedPaths.map(path => path.match(/[^/]+$/)[0]);
|
|
49
51
|
expectOrgUnitsToBeDisplayed(providedIds);
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
|
-
(0,
|
|
54
|
+
(0, _cypressCucumberPreprocessor.Then)('the path should close', () => {
|
|
53
55
|
cy.get('@providedPaths').then(providedPaths => {
|
|
54
56
|
const providedIds = providedPaths.map(path => path.match(/[^/]+$/)[0]);
|
|
55
57
|
const hiddenChildrenIds = providedIds.reduce((acc, cur) => {
|
|
56
|
-
const curData = (0,
|
|
58
|
+
const curData = (0, _getOrganisationUnitData.getOrganisationUnitData)(cur, {
|
|
57
59
|
fields: ['children[id,path,displayName]']
|
|
58
60
|
});
|
|
59
61
|
const childrenIds = curData.children.map(_ref => {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Given)("loading errors do not display automatically and loading A0000000001's children will fail", () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'A0000000001 loading error');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)("loading errors display automatically and loading A0000000001's children will fail", () => {
|
|
9
9
|
cy.visitStory('OrganisationUnitTree', 'A0000000001 loading error autoexpand');
|
|
10
10
|
});
|
|
11
|
-
(0,
|
|
11
|
+
(0, _cypressCucumberPreprocessor.Given)('the OrganisationUnitTree is closed', () => {
|
|
12
12
|
cy.get('[data-test="dhis2-uiwidgets-orgunittree"] > [data-test="dhis2-uiwidgets-orgunittree-node"]').as('rootNode').shouldBeAClosedNode();
|
|
13
13
|
});
|
|
14
|
-
(0,
|
|
14
|
+
(0, _cypressCucumberPreprocessor.When)('the A0000000000 path is opened', () => {
|
|
15
15
|
cy.getOrgUnitByLabel('Org Unit 1').openOrgUnitNode();
|
|
16
16
|
});
|
|
17
|
-
(0,
|
|
17
|
+
(0, _cypressCucumberPreprocessor.When)('the A0000000000 -> A0000000001 path is opened', () => {
|
|
18
18
|
cy.getOrgUnitByLabel('Org Unit 2').openOrgUnitNode();
|
|
19
19
|
});
|
|
20
|
-
(0,
|
|
20
|
+
(0, _cypressCucumberPreprocessor.Then)('no error message is shown', () => {
|
|
21
21
|
cy.getOrgUnitByLabel('Org Unit 2').find('[data-test="dhis2-uiwidgets-orgunittree-error"]').should('not.exist');
|
|
22
22
|
});
|
|
23
|
-
(0,
|
|
23
|
+
(0, _cypressCucumberPreprocessor.Then)('an appropriate error message is shown', () => {
|
|
24
24
|
cy.getOrgUnitByLabel('Org Unit 2').find('[data-test="dhis2-uiwidgets-orgunittree-error"]').should('contain', 'Could not load children');
|
|
25
25
|
});
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
5
|
const getRootOrgUnitByLabel = label => {
|
|
6
6
|
const rootOrgUnitLabelSelector = "\n [data-test=\"dhis2-uiwidgets-orgunittree\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-content\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-label\"]\n label\n ";
|
|
7
7
|
return cy.contains(rootOrgUnitLabelSelector, label).parents('[data-test="dhis2-uiwidgets-orgunittree-node"]');
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
(0,
|
|
10
|
+
(0, _cypressCucumberPreprocessor.Given)('a OrganisationUnitTree with children and no paths in the initiallyExpanded prop is rendered', () => {
|
|
11
11
|
cy.visitStory('OrganisationUnitTree/expanded', 'No initially expanded paths');
|
|
12
12
|
});
|
|
13
|
-
(0,
|
|
13
|
+
(0, _cypressCucumberPreprocessor.Given)('a OrganisationUnitTree with children and the path of the first unit on the second level in the initiallyExpanded prop is rendered', () => {
|
|
14
14
|
cy.visitStory('OrganisationUnitTree/expanded', 'Initially expanded paths');
|
|
15
15
|
});
|
|
16
|
-
(0,
|
|
16
|
+
(0, _cypressCucumberPreprocessor.Given)('both a sub org unit with children and a main org unit are root org units', () => {
|
|
17
17
|
cy.visitStory('OrganisationUnitTree/expanded', 'with root main and root sub org unit');
|
|
18
18
|
});
|
|
19
|
-
(0,
|
|
19
|
+
(0, _cypressCucumberPreprocessor.Given)('the root main org unit is expanded', () => {
|
|
20
20
|
getRootOrgUnitByLabel('Org Unit 1').find('> [data-test="dhis2-uiwidgets-orgunittree-node-toggle"]').click();
|
|
21
21
|
});
|
|
22
|
-
(0,
|
|
22
|
+
(0, _cypressCucumberPreprocessor.When)('the user expands the sub org unit within the main org unit tree', () => {
|
|
23
23
|
getRootOrgUnitByLabel('Org Unit 1').contains('[data-test="dhis2-uiwidgets-orgunittree-node"]', 'Org Unit 2').find('> [data-test="dhis2-uiwidgets-orgunittree-node-toggle"]').click().should('have.class', 'open');
|
|
24
24
|
});
|
|
25
|
-
(0,
|
|
25
|
+
(0, _cypressCucumberPreprocessor.When)('the user expands the root sub org unit', () => {
|
|
26
26
|
getRootOrgUnitByLabel('Org Unit 2').find('> [data-test="dhis2-uiwidgets-orgunittree-node-toggle"]').click().should('have.class', 'open');
|
|
27
27
|
});
|
|
28
|
-
(0,
|
|
28
|
+
(0, _cypressCucumberPreprocessor.Then)('the root unit is closed', () => {
|
|
29
29
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeAClosedNode();
|
|
30
30
|
});
|
|
31
|
-
(0,
|
|
31
|
+
(0, _cypressCucumberPreprocessor.Then)('the root unit is opened', () => {
|
|
32
32
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeAnOrgUnitNode();
|
|
33
33
|
});
|
|
34
|
-
(0,
|
|
34
|
+
(0, _cypressCucumberPreprocessor.Then)('the root sub org unit should not expand', () => {
|
|
35
35
|
getRootOrgUnitByLabel('Org Unit 2').find('> [data-test="dhis2-uiwidgets-orgunittree-node-toggle"]').should('not.have.class', 'open');
|
|
36
36
|
});
|
|
37
|
-
(0,
|
|
37
|
+
(0, _cypressCucumberPreprocessor.Then)('the sub org unit within the main org unit tree should not expand', () => {
|
|
38
38
|
getRootOrgUnitByLabel('Org Unit 1').contains('[data-test="dhis2-uiwidgets-orgunittree-node"]', 'Org Unit 2').find('> [data-test="dhis2-uiwidgets-orgunittree-node-toggle"]').should('not.have.class', 'open');
|
|
39
39
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Given)('a OrganisationUnitTree with three levels is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'Force reloading');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('the two parent levels are opened', () => {
|
|
9
9
|
cy.getOrgUnitByLabel('Org Unit 1').as('rootNode').openOrgUnitNode();
|
|
10
10
|
cy.getOrgUnitByLabel('Org Unit 2').openOrgUnitNode();
|
|
11
11
|
cy.get('@rootNode').find('[data-test="dhis2-uiwidgets-orgunittree-node"] [data-test="dhis2-uiwidgets-orgunittree-node"]').should('exist');
|
|
12
12
|
});
|
|
13
|
-
(0,
|
|
13
|
+
(0, _cypressCucumberPreprocessor.When)('the tree is being force reloaded and the loading process has finished', () => {
|
|
14
14
|
cy.get('[data-test="reload-all"]').click();
|
|
15
15
|
});
|
|
16
|
-
(0,
|
|
16
|
+
(0, _cypressCucumberPreprocessor.Then)('all three levels are visible again', () => {
|
|
17
17
|
cy.get('@rootNode').find('[data-test="dhis2-uiwidgets-orgunittree-node"]').should('exist');
|
|
18
18
|
cy.get('@rootNode').find('[data-test="dhis2-uiwidgets-orgunittree-node"] [data-test="dhis2-uiwidgets-orgunittree-node"]').should('exist');
|
|
19
19
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Given)('a OrganisationUnitTree with a highlighted root unit is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'Root highlighted');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Then)('root unit has the highlighted styles', () => {
|
|
9
9
|
cy.getOrgUnitByLabel('Org Unit 1').find('.highlighted').should('exist');
|
|
10
10
|
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Given)('a OrganisationUnitTree with two levels is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'A0000000001 loading');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('the root level is closed', () => {
|
|
9
9
|
cy.getOrgUnitByLabel('Org Unit 1').as('rootUnit').shouldBeAClosedNode();
|
|
10
10
|
});
|
|
11
|
-
(0,
|
|
11
|
+
(0, _cypressCucumberPreprocessor.When)('the root level is opened', () => {
|
|
12
12
|
cy.get('@rootUnit').openOrgUnitNode();
|
|
13
13
|
});
|
|
14
|
-
(0,
|
|
14
|
+
(0, _cypressCucumberPreprocessor.Then)('there is a loading indicator rendered on the first child of the second level', () => {
|
|
15
15
|
cy.getOrgUnitByLabel('Org Unit 2').find('[data-test="dhis2-uicore-circularloader"]').should('exist');
|
|
16
16
|
cy.getOrgUnitByLabel('Org Unit 2').find('[data-test="dhis2-uiwidgets-orgunittree-node-leaves"]:empty').should('exist');
|
|
17
17
|
});
|