@eox/layercontrol 0.11.4 → 0.13.0
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/dist/eox-layercontrol.js +9410 -8263
- package/dist/eox-layercontrol.umd.cjs +412 -263
- package/package.json +3 -2
- package/test/_mockMap.js +3 -0
- package/test/cases/general/check-layer-size.js +25 -0
- package/test/cases/general/check-pre-open-layer-tools.js +26 -0
- package/test/cases/general/check-pre-open-section.js +26 -0
- package/test/cases/general/disable-drag.js +26 -0
- package/test/cases/general/hide-layers.js +23 -0
- package/test/cases/general/index.js +7 -0
- package/test/cases/general/render-optional-layer.js +31 -0
- package/test/cases/general/show-layer-title.js +23 -0
- package/test/cases/layer-update/add-external-layer.js +68 -0
- package/test/cases/layer-update/add-layer-from-optional.js +51 -0
- package/test/cases/layer-update/check-if-layer-pushed-to-group.js +33 -0
- package/test/cases/layer-update/check-layer-is-pushed-to-root.js +22 -0
- package/test/cases/layer-update/check-layer-removed-from-group.js +33 -0
- package/test/cases/layer-update/check-layer-removed-from-root.js +27 -0
- package/test/cases/layer-update/check-layer-size-after-multiple-calls.js +34 -0
- package/test/cases/layer-update/check-layer-zoom-state.js +54 -0
- package/test/cases/layer-update/index.js +8 -0
- package/test/general.cy.js +34 -118
- package/test/layersUpdate.cy.js +45 -228
package/test/general.cy.js
CHANGED
|
@@ -1,133 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
// Importing test cases and necessary modules
|
|
2
|
+
import "../src/main"; // Importing main module
|
|
2
3
|
import "./_mockMap";
|
|
4
|
+
import {
|
|
5
|
+
checkLayerSize,
|
|
6
|
+
checkPreOpenLayerTools,
|
|
7
|
+
checkPreOpenSection,
|
|
8
|
+
disableDrag,
|
|
9
|
+
hideLayers,
|
|
10
|
+
renderOptionalLayer,
|
|
11
|
+
showCorrectLayerTitle,
|
|
12
|
+
} from "./cases/general";
|
|
3
13
|
|
|
4
14
|
describe("LayerControl", () => {
|
|
15
|
+
// Set up before each test
|
|
5
16
|
beforeEach(() => {
|
|
17
|
+
// Mounting mock map and layer control components for testing
|
|
6
18
|
cy.mount("<mock-map></mock-map>").as("mock-map");
|
|
7
|
-
cy.mount(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
).as("eox-layercontrol");
|
|
19
|
+
cy.mount(`<eox-layercontrol for="mock-map"></eox-layercontrol>`).as(
|
|
20
|
+
"eox-layercontrol"
|
|
21
|
+
);
|
|
11
22
|
});
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
24
|
+
// Test to verify if the layer control is successfully loaded
|
|
25
|
+
it("loads the layer control", () => cy.get("eox-layercontrol").shadow());
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
$el /**MockMap*/[0]
|
|
20
|
-
.setLayers([{ visible: true }, { visible: false }]);
|
|
21
|
-
});
|
|
22
|
-
cy.get("eox-layercontrol")
|
|
23
|
-
.shadow()
|
|
24
|
-
.within(() => {
|
|
25
|
-
cy.get(".layers").find("li").should("have.length", 2);
|
|
26
|
-
cy.get(".layers")
|
|
27
|
-
.find("input[type=checkbox]:checked")
|
|
28
|
-
.should("have.length", 1);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
27
|
+
// Test to ensure that the correct number of layers is displayed
|
|
28
|
+
it("displays the correct amount of layers", () => checkLayerSize());
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
$el /**MockMap*/[0]
|
|
35
|
-
.setLayers([
|
|
36
|
-
{ visible: true },
|
|
37
|
-
{ properties: { layerControlHide: true } },
|
|
38
|
-
]);
|
|
39
|
-
});
|
|
40
|
-
cy.get("eox-layercontrol")
|
|
41
|
-
.shadow()
|
|
42
|
-
.within(() => {
|
|
43
|
-
cy.get("ul").find("li").should("have.length", 1);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
30
|
+
// Test to validate the hiding of layers
|
|
31
|
+
it("hides layers correctly", () => hideLayers());
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
$el /**MockMap*/[0]
|
|
50
|
-
.setLayers([
|
|
51
|
-
{ visible: true },
|
|
52
|
-
{ properties: { layerControlOptional: true } },
|
|
53
|
-
]);
|
|
54
|
-
});
|
|
55
|
-
cy.get("eox-layercontrol")
|
|
56
|
-
.shadow()
|
|
57
|
-
.within(() => {
|
|
58
|
-
cy.get("[data-cy='optionalLayers']").should("exist");
|
|
59
|
-
cy.get("[data-cy='optionalLayers']")
|
|
60
|
-
.find("option:not([disabled])")
|
|
61
|
-
.should("have.length", 1);
|
|
62
|
-
cy.get("[data-cy='optionalLayers']").siblings("button").should("exist");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
33
|
+
// Test to verify the rendering of optional layer selection
|
|
34
|
+
it("renders the optional layer selection", () => renderOptionalLayer());
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
$el /**MockMap*/[0]
|
|
69
|
-
.setLayers([
|
|
70
|
-
{ visible: true },
|
|
71
|
-
{ properties: { layerControlDisable: true } },
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
cy.get("eox-layercontrol")
|
|
75
|
-
.shadow()
|
|
76
|
-
.within(() => {
|
|
77
|
-
cy.get(".tools summary").click({ multiple: true });
|
|
78
|
-
cy.get(".drag-handle:visible").should("have.length", 1);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
36
|
+
// Test to confirm the disabling of drag functionality for a disabled layer
|
|
37
|
+
it("disables the drag handle of the disabled layer", () => disableDrag());
|
|
81
38
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
$el /**MockMap*/[0]
|
|
85
|
-
.setLayers([
|
|
86
|
-
{ properties: { title: "foo" } },
|
|
87
|
-
{ properties: { title: "bar" } },
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
cy.get("eox-layercontrol")
|
|
91
|
-
.shadow()
|
|
92
|
-
.within(() => {
|
|
93
|
-
cy.get(".layer").find(".title").contains("foo");
|
|
94
|
-
cy.get(".layer").find(".title").contains("bar");
|
|
95
|
-
});
|
|
96
|
-
});
|
|
39
|
+
// Test to ensure the display of correct layer titles
|
|
40
|
+
it("shows the correct layer titles", () => showCorrectLayerTitle());
|
|
97
41
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
.setLayers([
|
|
102
|
-
{ visible: true },
|
|
103
|
-
{
|
|
104
|
-
properties: { layerControlExpand: true },
|
|
105
|
-
layers: [{ visible: true }],
|
|
106
|
-
},
|
|
107
|
-
]);
|
|
108
|
-
});
|
|
109
|
-
cy.get("eox-layercontrol")
|
|
110
|
-
.shadow()
|
|
111
|
-
.within(() => {
|
|
112
|
-
cy.get("details[open]").should("exist");
|
|
113
|
-
});
|
|
114
|
-
});
|
|
42
|
+
// Test to check if a section is pre-opened when the layerControlExpand property is present
|
|
43
|
+
it("pre-opens a section if layerControlExpand is present", () =>
|
|
44
|
+
checkPreOpenSection());
|
|
115
45
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.setLayers([
|
|
120
|
-
{ visible: true },
|
|
121
|
-
{
|
|
122
|
-
properties: { layerControlToolsExpand: true },
|
|
123
|
-
layers: [{ visible: true }],
|
|
124
|
-
},
|
|
125
|
-
]);
|
|
126
|
-
});
|
|
127
|
-
cy.get("eox-layercontrol")
|
|
128
|
-
.shadow()
|
|
129
|
-
.within(() => {
|
|
130
|
-
cy.get("details[open].tools").should("be.visible");
|
|
131
|
-
});
|
|
132
|
-
});
|
|
46
|
+
// Test to verify pre-opening of the layer tools section if layerControlToolsExpand is present
|
|
47
|
+
it("pre-opens layer tools section if layerControlToolsExpand is present", () =>
|
|
48
|
+
checkPreOpenLayerTools());
|
|
133
49
|
});
|
package/test/layersUpdate.cy.js
CHANGED
|
@@ -1,250 +1,67 @@
|
|
|
1
1
|
import "../src/main";
|
|
2
2
|
import "./_mockMap";
|
|
3
|
+
import {
|
|
4
|
+
addExternalLayers,
|
|
5
|
+
addLayerFromOptional,
|
|
6
|
+
checkLayerIsPushedToRoot,
|
|
7
|
+
checkLayerPushedToGroup,
|
|
8
|
+
checkLayerRemovedFromGroup,
|
|
9
|
+
checkLayerRemovedFromRoot,
|
|
10
|
+
checkLayerSizeAfterMultipleCalls,
|
|
11
|
+
checkLayerZoomState,
|
|
12
|
+
} from "./cases/layer-update";
|
|
3
13
|
|
|
4
14
|
describe("LayerControl", () => {
|
|
15
|
+
// Before each test case, set up the environment
|
|
5
16
|
beforeEach(() => {
|
|
17
|
+
// Extract test case titles to determine specific test conditions
|
|
6
18
|
const showLayerZoomState = Cypress.mocha
|
|
7
19
|
.getRunner()
|
|
8
20
|
.suite.ctx.currentTest.title.includes("showLayerZoomState");
|
|
9
21
|
|
|
22
|
+
const addExternalLayersTest = Cypress.mocha
|
|
23
|
+
.getRunner()
|
|
24
|
+
.suite.ctx.currentTest.title.includes("addExternalLayers");
|
|
25
|
+
|
|
26
|
+
// Mount the mock map and the LayerControl component
|
|
10
27
|
cy.mount("<mock-map></mock-map>").as("mock-map");
|
|
11
28
|
cy.mount(`<eox-layercontrol for="mock-map"></eox-layercontrol>`, {
|
|
12
|
-
properties: {
|
|
29
|
+
properties: {
|
|
30
|
+
showLayerZoomState,
|
|
31
|
+
addExternalLayers: addExternalLayersTest,
|
|
32
|
+
},
|
|
13
33
|
}).as("eox-layercontrol");
|
|
14
34
|
});
|
|
15
35
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.setLayers([
|
|
20
|
-
{ properties: { title: "1st round - foo" } },
|
|
21
|
-
{ properties: { title: "1st round - bar" } },
|
|
22
|
-
]);
|
|
23
|
-
});
|
|
24
|
-
cy.get("mock-map").and(($el) => {
|
|
25
|
-
$el /**MockMap*/[0]
|
|
26
|
-
.setLayers([]);
|
|
27
|
-
});
|
|
28
|
-
cy.get("mock-map").and(($el) => {
|
|
29
|
-
$el /**MockMap*/[0]
|
|
30
|
-
.setLayers([
|
|
31
|
-
{ properties: { title: "2nd round - baz" } },
|
|
32
|
-
{ properties: { title: "2nd round - qux" } },
|
|
33
|
-
]);
|
|
34
|
-
});
|
|
35
|
-
let numberOfLayers;
|
|
36
|
-
cy.get("mock-map").and(($el) => {
|
|
37
|
-
numberOfLayers = $el /**MockMap*/[0].map
|
|
38
|
-
.getLayers()
|
|
39
|
-
.getArray().length;
|
|
40
|
-
});
|
|
41
|
-
cy.get("eox-layercontrol")
|
|
42
|
-
.shadow()
|
|
43
|
-
.within(() => {
|
|
44
|
-
cy.get(".layers").find("li").should("have.length", numberOfLayers);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("updates if a layer is pushed to the root collection", () => {
|
|
49
|
-
cy.get("mock-map").and(($el) => {
|
|
50
|
-
$el /**MockMap*/[0]
|
|
51
|
-
.setLayers([{ properties: { title: "foo" } }]);
|
|
52
|
-
});
|
|
36
|
+
// Test case: Check if the correct number of layers is displayed after multiple setMap() calls
|
|
37
|
+
it("displays the correct amount of layers after multiple calls of setMap()", () =>
|
|
38
|
+
checkLayerSizeAfterMultipleCalls());
|
|
53
39
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.push({ properties: { title: "bar" } });
|
|
58
|
-
});
|
|
59
|
-
cy.get("eox-layercontrol")
|
|
60
|
-
.shadow()
|
|
61
|
-
.within(() => {
|
|
62
|
-
cy.get(".layer").find(".title").contains("bar");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
40
|
+
// Test case: Check if a layer update occurs when pushed to the root collection
|
|
41
|
+
it("updates if a layer is pushed to the root collection", () =>
|
|
42
|
+
checkLayerIsPushedToRoot());
|
|
65
43
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.setLayers([
|
|
70
|
-
{
|
|
71
|
-
properties: {
|
|
72
|
-
title: "group",
|
|
73
|
-
layerControlExpand: true,
|
|
74
|
-
},
|
|
75
|
-
layers: [{ properties: { title: "foo" } }],
|
|
76
|
-
},
|
|
77
|
-
{ properties: { title: "bar" } },
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
44
|
+
// Test case: Check if a layer update occurs when pushed to a group
|
|
45
|
+
it("updates if a layer is pushed to a group", () =>
|
|
46
|
+
checkLayerPushedToGroup());
|
|
80
47
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.getArray()[0]
|
|
85
|
-
.getLayers()
|
|
86
|
-
.push({ properties: { title: "baz" } });
|
|
87
|
-
});
|
|
88
|
-
cy.get("eox-layercontrol")
|
|
89
|
-
.shadow()
|
|
90
|
-
.within(() => {
|
|
91
|
-
cy.get(".layer").find(".title").contains("baz");
|
|
92
|
-
});
|
|
93
|
-
});
|
|
48
|
+
// Test case: Check if a layer update occurs when removed from the root collection
|
|
49
|
+
it("updates if a layer is removed from the root collection", () =>
|
|
50
|
+
checkLayerRemovedFromRoot());
|
|
94
51
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
.setLayers([
|
|
99
|
-
{ properties: { id: "foo" } },
|
|
100
|
-
{ properties: { id: "bar" } },
|
|
101
|
-
]);
|
|
102
|
-
});
|
|
52
|
+
// Test case: Check if a layer update occurs when removed from a group
|
|
53
|
+
it("updates if a layer is removed from a group", () =>
|
|
54
|
+
checkLayerRemovedFromGroup());
|
|
103
55
|
|
|
104
|
-
|
|
56
|
+
// Test case: Check if a layer is correctly added to a group when originally optional
|
|
57
|
+
it("adds a layer to a correct group when originally optional", () =>
|
|
58
|
+
addLayerFromOptional());
|
|
105
59
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
cy.get(`[data-layer=${layerToDelete}] .tools > summary`).click();
|
|
110
|
-
cy.get("button.remove-icon:visible").last().click();
|
|
111
|
-
cy.get(`[data-layer=${layerToDelete}]`).should("not.exist");
|
|
112
|
-
});
|
|
60
|
+
// Test case: Check layer state based on min and max zoom levels when showLayerZoomState is enabled
|
|
61
|
+
it("Zoom and check layer state based on min and max zoom - showLayerZoomState", () =>
|
|
62
|
+
checkLayerZoomState());
|
|
113
63
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// let layer = $el /**MockMap*/[0].layers
|
|
118
|
-
// .find((l) => l.id === layerToDelete);
|
|
119
|
-
// assert.equal(layer, undefined, "deleted layer should not be found");
|
|
120
|
-
// });
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("updates if a layer is removed from a group", () => {
|
|
124
|
-
cy.get("mock-map").and(($el) => {
|
|
125
|
-
$el /**MockMap*/[0]
|
|
126
|
-
.setLayers([
|
|
127
|
-
{
|
|
128
|
-
properties: {
|
|
129
|
-
title: "group",
|
|
130
|
-
layerControlExpand: true,
|
|
131
|
-
},
|
|
132
|
-
layers: [{ properties: { title: "baz" } }],
|
|
133
|
-
},
|
|
134
|
-
{ title: "bar" },
|
|
135
|
-
]);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
cy.get("mock-map").and(($el) => {
|
|
139
|
-
$el /**MockMap*/[0].map
|
|
140
|
-
.getLayers()
|
|
141
|
-
.getArray()[0]
|
|
142
|
-
.getLayers()
|
|
143
|
-
.pop();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
cy.get("eox-layercontrol")
|
|
147
|
-
.shadow()
|
|
148
|
-
.within(() => {
|
|
149
|
-
cy.get(".layer").find(".title").contains("baz").should("not.exist");
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("adds a layer to a correct group when originally optional", () => {
|
|
154
|
-
cy.get("mock-map").and(($el) => {
|
|
155
|
-
$el /**MockMap*/[0]
|
|
156
|
-
.setLayers([
|
|
157
|
-
{
|
|
158
|
-
properties: {
|
|
159
|
-
title: "group1",
|
|
160
|
-
layerControlExpand: true,
|
|
161
|
-
},
|
|
162
|
-
layers: [{ properties: { title: "title1" } }],
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
properties: {
|
|
166
|
-
title: "group2",
|
|
167
|
-
layerControlExpand: true,
|
|
168
|
-
},
|
|
169
|
-
layers: [
|
|
170
|
-
{ properties: { title: "foo" } },
|
|
171
|
-
{
|
|
172
|
-
properties: {
|
|
173
|
-
id: "title2",
|
|
174
|
-
title: "title2",
|
|
175
|
-
layerControlOptional: true,
|
|
176
|
-
},
|
|
177
|
-
visible: false,
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
]);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
cy.get("eox-layercontrol")
|
|
185
|
-
.shadow()
|
|
186
|
-
.within(() => {
|
|
187
|
-
cy.get("[data-cy='optionalLayers']").select("title2");
|
|
188
|
-
cy.get("[data-cy='optionalLayers']").siblings("button").click();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
cy.get("eox-layercontrol")
|
|
192
|
-
.shadow()
|
|
193
|
-
.within(() => {
|
|
194
|
-
cy.get(".layer")
|
|
195
|
-
.find(".title")
|
|
196
|
-
.contains("title2")
|
|
197
|
-
.should("have.length", 1);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("Zoom and check layer state based on min and max zoom - showLayerZoomState", () => {
|
|
202
|
-
cy.get("mock-map").and(($el) => {
|
|
203
|
-
$el /**MockMap*/[0]
|
|
204
|
-
.setLayers([
|
|
205
|
-
{ properties: { id: "foo" }, minZoom: 2 },
|
|
206
|
-
{ properties: { id: "bar" }, maxZoom: 9 },
|
|
207
|
-
]);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const checkLayerClass = (id, have) => {
|
|
211
|
-
const haveCheck = !have ? "not." : "";
|
|
212
|
-
cy.get(`[data-layer=${id}] .layer`).should(
|
|
213
|
-
`${haveCheck}have.class`,
|
|
214
|
-
"zoom-state-invisible"
|
|
215
|
-
);
|
|
216
|
-
};
|
|
217
|
-
const changeZoom = (zoom) => {
|
|
218
|
-
cy.get("mock-map").and(($el) => {
|
|
219
|
-
$el[0].setZoom(zoom);
|
|
220
|
-
$el[0].map.getEvents()["change:resolution"].map((func) => func());
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// Case 1: Default load with zoom level 1
|
|
225
|
-
cy.get("eox-layercontrol")
|
|
226
|
-
.shadow()
|
|
227
|
-
.within(() => {
|
|
228
|
-
checkLayerClass("foo", true);
|
|
229
|
-
checkLayerClass("bar");
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Case 2: change zoom level to 3
|
|
233
|
-
changeZoom(3);
|
|
234
|
-
cy.get("eox-layercontrol")
|
|
235
|
-
.shadow()
|
|
236
|
-
.within(() => {
|
|
237
|
-
checkLayerClass("foo");
|
|
238
|
-
checkLayerClass("bar");
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Case 3: change zoom level to 10
|
|
242
|
-
changeZoom(10);
|
|
243
|
-
cy.get("eox-layercontrol")
|
|
244
|
-
.shadow()
|
|
245
|
-
.within(() => {
|
|
246
|
-
checkLayerClass("foo");
|
|
247
|
-
checkLayerClass("bar", true);
|
|
248
|
-
});
|
|
249
|
-
});
|
|
64
|
+
// Test case: Add new external layers (WMS/XYZ and JSON)
|
|
65
|
+
it("Add new external WMS/XYZ and JSON Layer - addExternalLayers", () =>
|
|
66
|
+
addExternalLayers());
|
|
250
67
|
});
|