@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
|
@@ -1,66 +1,66 @@
|
|
|
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 two levels is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'Multiple selection');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('no unit is selected', () => {
|
|
9
9
|
cy.window().should(win => {
|
|
10
10
|
expect(win.selection).to.eql([]);
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
|
-
(0,
|
|
13
|
+
(0, _cypressCucumberPreprocessor.Given)('the root level unit is opened', () => {
|
|
14
14
|
cy.getOrgUnitByLabel('Org Unit 1').openOrgUnitNode(true);
|
|
15
15
|
});
|
|
16
|
-
(0,
|
|
16
|
+
(0, _cypressCucumberPreprocessor.Given)('the first unit on the second level is selected', () => {
|
|
17
17
|
cy.getOrgUnitByLabel('Org Unit 2').toggleOrgUnitNodeSelection(true);
|
|
18
18
|
});
|
|
19
|
-
(0,
|
|
19
|
+
(0, _cypressCucumberPreprocessor.Given)('the first unit on the second level unit is opened', () => {
|
|
20
20
|
cy.getOrgUnitByLabel('Org Unit 2').openOrgUnitNode(true);
|
|
21
21
|
});
|
|
22
|
-
(0,
|
|
22
|
+
(0, _cypressCucumberPreprocessor.Given)('the second level has two units', () => {
|
|
23
23
|
cy.getOrgUnitByLabel('Org Unit 2').find('[data-test="dhis2-uiwidgets-orgunittree-node-leaves"]').first().children().filter((index, child) => Cypress.$(child).is('[data-test="dhis2-uiwidgets-orgunittree-node"]')).should('have.length', 2);
|
|
24
24
|
});
|
|
25
|
-
(0,
|
|
25
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects a unit', () => {
|
|
26
26
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true);
|
|
27
27
|
});
|
|
28
|
-
(0,
|
|
28
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the first unit on the second level', () => {
|
|
29
29
|
cy.getOrgUnitByLabel('Org Unit 2').toggleOrgUnitNodeSelection(true);
|
|
30
30
|
});
|
|
31
|
-
(0,
|
|
31
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the root level', () => {
|
|
32
32
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true);
|
|
33
33
|
});
|
|
34
|
-
(0,
|
|
34
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the second unit on the second level', () => {
|
|
35
35
|
cy.getOrgUnitByLabel('Org Unit 3').toggleOrgUnitNodeSelection(true);
|
|
36
36
|
});
|
|
37
|
-
(0,
|
|
37
|
+
(0, _cypressCucumberPreprocessor.Then)('a unit is selected', () => {
|
|
38
38
|
cy.window().should(win => {
|
|
39
39
|
expect(win.selection).to.eql(['/A0000000000']);
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
-
(0,
|
|
42
|
+
(0, _cypressCucumberPreprocessor.Then)('the unit on the second level is selected', () => {
|
|
43
43
|
cy.window().should(win => {
|
|
44
44
|
expect(win.selection).to.eql(['/A0000000000/A0000000001']);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
-
(0,
|
|
47
|
+
(0, _cypressCucumberPreprocessor.Then)('the unit on the first level is marked as selected intermediately', () => {
|
|
48
48
|
cy.getOrgUnitByLabel('Org Unit 1').find('[data-test="dhis2-uiwidgets-orgunittree-node-label"] [data-test="dhis2-uicore-checkbox"] input').should($input => {
|
|
49
49
|
expect($input[0].indeterminate).to.be.true;
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
(0,
|
|
52
|
+
(0, _cypressCucumberPreprocessor.Then)('the root unit is marked as selected', () => {
|
|
53
53
|
cy.window().should(win => {
|
|
54
54
|
expect(win.selection.includes('/A0000000000')).to.be.true;
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
|
-
(0,
|
|
57
|
+
(0, _cypressCucumberPreprocessor.Then)('the first unit is selected', () => {
|
|
58
58
|
cy.window().should(win => {
|
|
59
59
|
expect(win.selection.includes('/A0000000000/A0000000001')).to.be.true;
|
|
60
60
|
expect(win.selection).to.have.length(2);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
-
(0,
|
|
63
|
+
(0, _cypressCucumberPreprocessor.Then)('the second unit is selected', () => {
|
|
64
64
|
cy.window().should(win => {
|
|
65
65
|
expect(win.selection.includes('/A0000000000/A0000000002')).to.be.true;
|
|
66
66
|
expect(win.selection).to.have.length(2);
|
|
@@ -1,23 +1,23 @@
|
|
|
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 disabled, collapsed OrganisationUnitTree with two levels is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'No selection closed');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('a disabled OrganisationUnitTree with two levels is rendered with the second level is expanded', () => {
|
|
9
9
|
cy.visitStory('OrganisationUnitTree', 'No selection root opened');
|
|
10
10
|
});
|
|
11
|
-
(0,
|
|
11
|
+
(0, _cypressCucumberPreprocessor.When)('the root node is clicked', () => {
|
|
12
12
|
cy.getOrgUnitByLabel('Org Unit 1').find('[data-test="dhis2-uiwidgets-orgunittree-node-label"]').first().trigger('click');
|
|
13
13
|
});
|
|
14
|
-
(0,
|
|
14
|
+
(0, _cypressCucumberPreprocessor.Then)('the root node remains unselected', () => {
|
|
15
15
|
cy.getOrgUnitByLabel('Org Unit 1').find('[data-test="dhis2-uiwidgets-orgunittree-node-label"]').first().as('rootLabel').find('.checked').should('not.exist');
|
|
16
16
|
cy.get('@rootLabel').find('input').should('not.exist');
|
|
17
17
|
});
|
|
18
|
-
(0,
|
|
18
|
+
(0, _cypressCucumberPreprocessor.Then)('the second level is expanded', () => {
|
|
19
19
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeAnOpenNode();
|
|
20
20
|
});
|
|
21
|
-
(0,
|
|
21
|
+
(0, _cypressCucumberPreprocessor.Then)('the second level is collapsed', () => {
|
|
22
22
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeAClosedNode();
|
|
23
23
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
|
-
(0,
|
|
5
|
+
(0, _cypressCucumberPreprocessor.Before)(() => {
|
|
6
6
|
cy.wrap([]).as('displayedUnits');
|
|
7
7
|
});
|
|
8
8
|
|
|
@@ -12,10 +12,10 @@ const addDisplayedUnit = id => {
|
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
(0,
|
|
15
|
+
(0, _cypressCucumberPreprocessor.Given)('a unfiltered OrganisationUnitTree with a depth of 3 levels is rendered', () => {
|
|
16
16
|
cy.visitStory('OrganisationUnitTree', 'Filtered by 3-level-path');
|
|
17
17
|
});
|
|
18
|
-
(0,
|
|
18
|
+
(0, _cypressCucumberPreprocessor.Given)('a filtered OrganisationUnitTree with a depth of 3 levels is rendered', () => {
|
|
19
19
|
cy.visitStory('OrganisationUnitTree', 'Filtered by 3-level-path and 2-level-path');
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
@@ -28,29 +28,29 @@ const addDisplayedUnit = id => {
|
|
|
28
28
|
* which triggers the recursive loading strategy.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
(0,
|
|
32
|
-
(0,
|
|
33
|
-
(0,
|
|
34
|
-
(0,
|
|
35
|
-
(0,
|
|
36
|
-
(0,
|
|
37
|
-
(0,
|
|
31
|
+
(0, _cypressCucumberPreprocessor.Given)('the second level contains two nodes', () => {});
|
|
32
|
+
(0, _cypressCucumberPreprocessor.Given)('all parent levels are open', () => {});
|
|
33
|
+
(0, _cypressCucumberPreprocessor.Given)('a filter containing the first child of the first second level is provided', () => {});
|
|
34
|
+
(0, _cypressCucumberPreprocessor.Given)('the second level nodes each have a child node', () => {});
|
|
35
|
+
(0, _cypressCucumberPreprocessor.Given)('a filter containing the first child of the second level is provided', () => {});
|
|
36
|
+
(0, _cypressCucumberPreprocessor.Given)('a filter containing the second child of the first level is provided', () => {});
|
|
37
|
+
(0, _cypressCucumberPreprocessor.Then)('the root level is visible', () => {
|
|
38
38
|
cy.getOrgUnitByLabel('Org Unit 1').should('exist');
|
|
39
39
|
addDisplayedUnit('A0000000000');
|
|
40
40
|
});
|
|
41
|
-
(0,
|
|
41
|
+
(0, _cypressCucumberPreprocessor.Then)('the first node on the second level is visible', () => {
|
|
42
42
|
cy.getOrgUnitByLabel('Org Unit 2').should('exist');
|
|
43
43
|
addDisplayedUnit('A0000000001');
|
|
44
44
|
});
|
|
45
|
-
(0,
|
|
45
|
+
(0, _cypressCucumberPreprocessor.Then)('the first child node of the first node on the second level is visible', () => {
|
|
46
46
|
cy.getOrgUnitByLabel('Org Unit 4').should('exist');
|
|
47
47
|
addDisplayedUnit('A0000000003');
|
|
48
48
|
});
|
|
49
|
-
(0,
|
|
49
|
+
(0, _cypressCucumberPreprocessor.Then)('the second node on the first level is visible', () => {
|
|
50
50
|
cy.getOrgUnitByLabel('Org Unit 3').should('exist');
|
|
51
51
|
addDisplayedUnit('A0000000002');
|
|
52
52
|
});
|
|
53
|
-
(0,
|
|
53
|
+
(0, _cypressCucumberPreprocessor.Then)('all other nodes are not rendered', () => {
|
|
54
54
|
cy.get('@displayedUnits').then(displayedUnits => {
|
|
55
55
|
cy.window().then(win => {
|
|
56
56
|
const excludedUnitNumbers = win.allUnits.filter(unit => !displayedUnits.includes(unit)).map(id => parseInt(id.replace(/^.*(\d)$/, '$1'), 10) + 1);
|
|
@@ -1,38 +1,34 @@
|
|
|
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 two nodes is rendered', () => {
|
|
6
6
|
cy.visitStory('OrganisationUnitTree', 'Single selection');
|
|
7
7
|
});
|
|
8
|
-
(0,
|
|
8
|
+
(0, _cypressCucumberPreprocessor.Given)('no unit has been selected', () => {
|
|
9
9
|
cy.get('.checked').should('not.exist');
|
|
10
10
|
});
|
|
11
|
-
(0,
|
|
11
|
+
(0, _cypressCucumberPreprocessor.Given)('the first unit has been selected', () => {
|
|
12
12
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true, true);
|
|
13
13
|
});
|
|
14
|
-
(0,
|
|
14
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the first unit', () => {
|
|
15
15
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true, true);
|
|
16
16
|
});
|
|
17
|
-
(0,
|
|
17
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the second unit', () => {
|
|
18
18
|
cy.getOrgUnitByLabel('Org Unit 2').toggleOrgUnitNodeSelection(true, true);
|
|
19
19
|
});
|
|
20
|
-
(0,
|
|
20
|
+
(0, _cypressCucumberPreprocessor.When)('the user deselects the first unit', () => {
|
|
21
21
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(false, true);
|
|
22
22
|
});
|
|
23
|
-
(0,
|
|
23
|
+
(0, _cypressCucumberPreprocessor.Then)('the first unit is selected', () => {
|
|
24
24
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeASelectedOrgUnitNode(true);
|
|
25
25
|
});
|
|
26
|
-
(0,
|
|
26
|
+
(0, _cypressCucumberPreprocessor.Then)('the first unit is not selected', () => {
|
|
27
27
|
cy.getOrgUnitByLabel('Org Unit 1').shouldNotBeASelectedOrgUnitNode(true);
|
|
28
28
|
});
|
|
29
|
-
(0,
|
|
29
|
+
(0, _cypressCucumberPreprocessor.Then)('the second unit is selected', () => {
|
|
30
30
|
cy.getOrgUnitByLabel('Org Unit 2').shouldBeASelectedOrgUnitNode(true);
|
|
31
31
|
});
|
|
32
|
-
(0,
|
|
33
|
-
cy.get('
|
|
34
|
-
$nodes.each((index, node) => {
|
|
35
|
-
cy.wrap(Cypress.$(node)).shouldNotBeASelectedOrgUnitNode();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
32
|
+
(0, _cypressCucumberPreprocessor.Then)('no unit is selected', () => {
|
|
33
|
+
cy.get('.checked').should('not.exist');
|
|
38
34
|
});
|
|
@@ -2,7 +2,7 @@ Feature: When specified only one unit can be selected
|
|
|
2
2
|
|
|
3
3
|
Scenario: The user selects a unit when no other unit is selected
|
|
4
4
|
Given an OrganisationUnitTree with two nodes is rendered
|
|
5
|
-
And no unit
|
|
5
|
+
And no unit has been selected
|
|
6
6
|
When the user selects the first unit
|
|
7
7
|
Then the first unit is selected
|
|
8
8
|
|
|
@@ -1,51 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
5
|
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";
|
|
6
|
-
(0,
|
|
6
|
+
(0, _cypressCucumberPreprocessor.Given)('a sub org unit is a root org unit', () => {
|
|
7
7
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
8
8
|
});
|
|
9
|
-
(0,
|
|
9
|
+
(0, _cypressCucumberPreprocessor.Given)('both a sub org unit and a main org unit are root org units', () => {
|
|
10
10
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
11
11
|
});
|
|
12
|
-
(0,
|
|
12
|
+
(0, _cypressCucumberPreprocessor.Given)('multiple sub org units is a root org unit', () => {
|
|
13
13
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
14
14
|
});
|
|
15
|
-
(0,
|
|
15
|
+
(0, _cypressCucumberPreprocessor.Given)('the root sub org unit is a child of the root main org unit', () => {
|
|
16
16
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
17
17
|
});
|
|
18
|
-
(0,
|
|
19
|
-
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
20
|
-
});
|
|
21
|
-
(0, _steps.Given)('the root sub org unit is a child of the root main org unit', () => {
|
|
22
|
-
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
23
|
-
});
|
|
24
|
-
(0, _steps.Given)('the user provided one root sub org unit to the filter', () => {
|
|
18
|
+
(0, _cypressCucumberPreprocessor.Given)('the user provided one root sub org unit to the filter', () => {
|
|
25
19
|
cy.get('input[type="input"]').clear().type('/A0000000001');
|
|
26
20
|
});
|
|
27
|
-
(0,
|
|
21
|
+
(0, _cypressCucumberPreprocessor.Given)('the user provided one non-root sub org unit to the filter', () => {
|
|
28
22
|
cy.get('input[type="input"]').clear().type('/A0000000000/A0000000006');
|
|
29
23
|
});
|
|
30
|
-
(0,
|
|
24
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects sub org unit in the main org unit tree', () => {
|
|
31
25
|
cy.contains('label', 'Org Unit 1').click();
|
|
32
26
|
cy.get('[data-test="dhis2-uiwidgets-orgunittree-node-content"]').contains('label', 'Org Unit 2').click();
|
|
33
27
|
});
|
|
34
|
-
(0,
|
|
28
|
+
(0, _cypressCucumberPreprocessor.When)('the user selects the root sub org unit', () => {
|
|
35
29
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 2').click();
|
|
36
30
|
});
|
|
37
|
-
(0,
|
|
31
|
+
(0, _cypressCucumberPreprocessor.Then)('all root sub org units but the filtered sub org unit should be hidden', () => {
|
|
38
32
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 2').should('exist');
|
|
39
33
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 1').should('not.exist');
|
|
40
34
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 3').should('not.exist');
|
|
41
35
|
});
|
|
42
|
-
(0,
|
|
36
|
+
(0, _cypressCucumberPreprocessor.Then)('the root main org unit should be marked as indeterminate', () => {
|
|
43
37
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 1').find('> .icon svg').should('have.class', 'indeterminate');
|
|
44
38
|
});
|
|
45
|
-
(0,
|
|
39
|
+
(0, _cypressCucumberPreprocessor.Then)('the root sub org unit should be selected', () => {
|
|
46
40
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 2').find('> .icon svg').should('have.class', 'checked');
|
|
47
41
|
});
|
|
48
|
-
(0,
|
|
42
|
+
(0, _cypressCucumberPreprocessor.Then)('only the root main org units should be visible', () => {
|
|
49
43
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 1').should('exist');
|
|
50
44
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 2').should('not.exist');
|
|
51
45
|
cy.contains(rootOrgUnitLabelSelector, 'Org Unit 3').should('not.exist');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
4
|
|
|
5
5
|
const expectStubPayloadToEqual = (stub, prop, expected) => {
|
|
6
6
|
const calls = stub.getCalls();
|
|
@@ -11,90 +11,90 @@ const expectStubPayloadToEqual = (stub, prop, expected) => {
|
|
|
11
11
|
expect(payload[prop]).to.eql(expected);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
(0,
|
|
14
|
+
(0, _cypressCucumberPreprocessor.Given)('an OrganisationUnitTree is rendered', () => {
|
|
15
15
|
cy.visitStory('OrganisationUnitTree', 'Events');
|
|
16
16
|
cy.getOrgUnitByLabel('Org Unit 1').shouldBeDoneLoading();
|
|
17
17
|
});
|
|
18
|
-
(0,
|
|
18
|
+
(0, _cypressCucumberPreprocessor.Given)('a node has been selected', () => {
|
|
19
19
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true);
|
|
20
20
|
});
|
|
21
|
-
(0,
|
|
21
|
+
(0, _cypressCucumberPreprocessor.Given)('a node with children is rendered', () => {
|
|
22
22
|
cy.visitStory('OrganisationUnitTree', 'Events');
|
|
23
23
|
});
|
|
24
|
-
(0,
|
|
24
|
+
(0, _cypressCucumberPreprocessor.Given)('the node has been expanded', () => {
|
|
25
25
|
cy.getOrgUnitByLabel('Org Unit 1').openOrgUnitNode();
|
|
26
26
|
});
|
|
27
|
-
(0,
|
|
27
|
+
(0, _cypressCucumberPreprocessor.Given)("the children haven't been loaded yet", () => {
|
|
28
28
|
cy.window().should(win => {
|
|
29
29
|
expect(win.onExpand).not.to.be.called;
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
(0,
|
|
32
|
+
(0, _cypressCucumberPreprocessor.When)('a node gets selected', () => {
|
|
33
33
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(true);
|
|
34
34
|
});
|
|
35
|
-
(0,
|
|
35
|
+
(0, _cypressCucumberPreprocessor.When)('a node gets deselected', () => {
|
|
36
36
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNodeSelection(false);
|
|
37
37
|
});
|
|
38
|
-
(0,
|
|
38
|
+
(0, _cypressCucumberPreprocessor.When)('the node is expanded', () => {
|
|
39
39
|
cy.getOrgUnitByLabel('Org Unit 1').openOrgUnitNode();
|
|
40
40
|
});
|
|
41
|
-
(0,
|
|
41
|
+
(0, _cypressCucumberPreprocessor.When)('a node is collapsed', () => {
|
|
42
42
|
cy.getOrgUnitByLabel('Org Unit 1').closeOrgUnitNode();
|
|
43
43
|
});
|
|
44
|
-
(0,
|
|
44
|
+
(0, _cypressCucumberPreprocessor.When)('the children have been loaded', () => {
|
|
45
45
|
cy.getOrgUnitByLabel('Org Unit 1').toggleOrgUnitNode(true);
|
|
46
46
|
});
|
|
47
|
-
(0,
|
|
47
|
+
(0, _cypressCucumberPreprocessor.Then)('the onChange callback gets called', () => {
|
|
48
48
|
cy.window().should(win => {
|
|
49
49
|
expect(win.onChange).to.be.called;
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
(0,
|
|
52
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes the path of the selected node', () => {
|
|
53
53
|
cy.window().should(win => {
|
|
54
54
|
expectStubPayloadToEqual(win.onChange, 'path', '/A0000000000');
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
|
-
(0,
|
|
57
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes checked which is set to "true"', () => {
|
|
58
58
|
cy.window().should(win => {
|
|
59
59
|
expectStubPayloadToEqual(win.onChange, 'checked', true);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
-
(0,
|
|
62
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes all selected nodes', () => {
|
|
63
63
|
cy.window().should(win => {
|
|
64
64
|
expectStubPayloadToEqual(win.onChange, 'selected', ['/A0000000000']);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
-
(0,
|
|
67
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes checked which is set to "false"', () => {
|
|
68
68
|
cy.window().should(win => {
|
|
69
69
|
expectStubPayloadToEqual(win.onChange, 'checked', false);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
(0,
|
|
72
|
+
(0, _cypressCucumberPreprocessor.Then)('the onExpand callback gets called', () => {
|
|
73
73
|
cy.window().should(win => {
|
|
74
74
|
expect(win.onExpand).to.be.called;
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
-
(0,
|
|
77
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes the path of the expanded node', () => {
|
|
78
78
|
cy.window().should(win => {
|
|
79
79
|
expectStubPayloadToEqual(win.onExpand, 'path', '/A0000000000');
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
-
(0,
|
|
82
|
+
(0, _cypressCucumberPreprocessor.Then)('the onCollapse callback gets called', () => {
|
|
83
83
|
cy.window().should(win => {
|
|
84
84
|
expect(win.onCollapse).to.be.called;
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
-
(0,
|
|
87
|
+
(0, _cypressCucumberPreprocessor.Then)('the payload includes the path of the collapsed node', () => {
|
|
88
88
|
cy.window().should(win => {
|
|
89
89
|
expectStubPayloadToEqual(win.onCollapse, 'path', '/A0000000000');
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
|
-
(0,
|
|
92
|
+
(0, _cypressCucumberPreprocessor.Then)('the onChildrenLoaded callback gets called', () => {
|
|
93
93
|
cy.window().should(win => {
|
|
94
94
|
expect(win.onChildrenLoaded).to.be.called;
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
|
-
(0,
|
|
97
|
+
(0, _cypressCucumberPreprocessor.Then)("the payload contains the loaded children's data", () => {
|
|
98
98
|
cy.window().should(win => {
|
|
99
99
|
const calls = win.onChildrenLoaded.getCalls();
|
|
100
100
|
expect(calls).to.have.length(1);
|
|
@@ -2,146 +2,16 @@
|
|
|
2
2
|
import { CustomDataProvider } from '@dhis2/app-runtime';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
|
-
|
|
5
|
+
import { getOrganisationUnitData } from './get-organisation-unit-data.js';
|
|
6
|
+
export { getOrganisationUnitData } from './get-organisation-unit-data.js';
|
|
7
|
+
export { namespace } from './namespace.js';
|
|
6
8
|
export const delayResponse = (delay, response) => () => new Promise(resolve => setTimeout(() => resolve(response), delay));
|
|
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
|
-
export 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
9
|
export const dataProviderData = {
|
|
140
|
-
organisationUnits: (_,
|
|
10
|
+
organisationUnits: (_, _ref) => {
|
|
141
11
|
let {
|
|
142
12
|
id,
|
|
143
13
|
params = {}
|
|
144
|
-
} =
|
|
14
|
+
} = _ref;
|
|
145
15
|
console.log('id, params', id, params);
|
|
146
16
|
const data = getOrganisationUnitData(id, params);
|
|
147
17
|
|
|
@@ -152,18 +22,18 @@ export const dataProviderData = {
|
|
|
152
22
|
return Promise.resolve(data);
|
|
153
23
|
}
|
|
154
24
|
};
|
|
155
|
-
export const StatefulMultiSelectionWrapper =
|
|
25
|
+
export const StatefulMultiSelectionWrapper = _ref2 => {
|
|
156
26
|
let {
|
|
157
27
|
children,
|
|
158
28
|
onSelectionChange = () => null
|
|
159
|
-
} =
|
|
29
|
+
} = _ref2;
|
|
160
30
|
const [selected, setSelected] = useState([]);
|
|
161
31
|
return children({
|
|
162
32
|
selected,
|
|
163
|
-
onChange:
|
|
33
|
+
onChange: _ref3 => {
|
|
164
34
|
let {
|
|
165
35
|
selected: newSelected
|
|
166
|
-
} =
|
|
36
|
+
} = _ref3;
|
|
167
37
|
setSelected(newSelected);
|
|
168
38
|
onSelectionChange(newSelected);
|
|
169
39
|
}
|
|
@@ -176,11 +46,11 @@ StatefulMultiSelectionWrapper.propTypes = {
|
|
|
176
46
|
export const createDecoratorStatefulMultiSelection = args => {
|
|
177
47
|
return Story => /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, {
|
|
178
48
|
onSelectionChange: args === null || args === void 0 ? void 0 : args.onSelectionChange
|
|
179
|
-
},
|
|
49
|
+
}, _ref4 => {
|
|
180
50
|
let {
|
|
181
51
|
selected,
|
|
182
52
|
onChange
|
|
183
|
-
} =
|
|
53
|
+
} = _ref4;
|
|
184
54
|
return /*#__PURE__*/React.createElement(Story, {
|
|
185
55
|
selected: selected,
|
|
186
56
|
onChange: onChange
|