@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/layercontrol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@eox/eslint-config": "^1.0.0",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"dayjs": "^1.11.8",
|
|
35
35
|
"lit": "^3.0.2",
|
|
36
|
-
"lodash.debounce": "^4.0.8"
|
|
36
|
+
"lodash.debounce": "^4.0.8",
|
|
37
|
+
"wms-capabilities": "^0.6.0"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/test/_mockMap.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Function to check the rendered size and visibility of layers in the LayerControl
|
|
2
|
+
const checkLayerSize = () => {
|
|
3
|
+
// Set up the layers in the mock map - visibility: true, visibility: false
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers, one visible and one hidden
|
|
8
|
+
mockMap.setLayers([{ visible: true }, { visible: false }]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// Verifying layer rendering in the LayerControl component
|
|
12
|
+
cy.get("eox-layercontrol")
|
|
13
|
+
.shadow()
|
|
14
|
+
.within(() => {
|
|
15
|
+
// Checking if the correct number of layers are rendered
|
|
16
|
+
cy.get(".layers").find("li").should("have.length", 2);
|
|
17
|
+
|
|
18
|
+
// Verifying the number of checked checkboxes (visible layers)
|
|
19
|
+
cy.get(".layers")
|
|
20
|
+
.find("input[type=checkbox]:checked")
|
|
21
|
+
.should("have.length", 1);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default checkLayerSize;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Function to check if the layer tools section opens when 'layerControlToolsExpand' is true
|
|
2
|
+
const checkPreOpenLayerTools = () => {
|
|
3
|
+
// Set up the layers in the mock map
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers: one visible and another with layerControlToolsExpand: true
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{ visible: true },
|
|
10
|
+
{
|
|
11
|
+
properties: { layerControlToolsExpand: true },
|
|
12
|
+
layers: [{ visible: true }],
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Verify if the tools section opens within the LayerControl component
|
|
18
|
+
cy.get("eox-layercontrol")
|
|
19
|
+
.shadow()
|
|
20
|
+
.within(() => {
|
|
21
|
+
// Checking if the details tag with class 'tools' is visible (open)
|
|
22
|
+
cy.get("details[open].tools").should("be.visible");
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default checkPreOpenLayerTools;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Function to check if a section opens when 'layerControlExpand' is true
|
|
2
|
+
const checkPreOpenSection = () => {
|
|
3
|
+
// Set up the layers in the mock map
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers: one visible and another with layerControlExpand: true
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{ visible: true },
|
|
10
|
+
{
|
|
11
|
+
properties: { layerControlExpand: true },
|
|
12
|
+
layers: [{ visible: true }],
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Verify if the section opens within the LayerControl component
|
|
18
|
+
cy.get("eox-layercontrol")
|
|
19
|
+
.shadow()
|
|
20
|
+
.within(() => {
|
|
21
|
+
// Checking if a details tag (any open section) exists
|
|
22
|
+
cy.get("details[open]").should("exist");
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default checkPreOpenSection;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Function to simulate disabling the drag handle for a layer
|
|
2
|
+
const disableDrag = () => {
|
|
3
|
+
// Set up the layers in the mock map
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers: one visible and another with layerControlDisable: true
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{ visible: true },
|
|
10
|
+
{ properties: { layerControlDisable: true } },
|
|
11
|
+
]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Verify the effect on the LayerControl
|
|
15
|
+
cy.get("eox-layercontrol")
|
|
16
|
+
.shadow()
|
|
17
|
+
.within(() => {
|
|
18
|
+
// Clicking on the summary (representing the disabled layer)
|
|
19
|
+
cy.get(".tools summary").click({ multiple: true });
|
|
20
|
+
|
|
21
|
+
// Verifying the visibility of the drag handle
|
|
22
|
+
cy.get(".drag-handle:visible").should("have.length", 1);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default disableDrag;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Function to simulate hiding layers within the LayerControl
|
|
2
|
+
const hideLayers = () => {
|
|
3
|
+
// Set up the layers in the mock map
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers: one visible and another marked with layerControlHide: true
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{ visible: true },
|
|
10
|
+
{ properties: { layerControlHide: true } },
|
|
11
|
+
]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Verify the effect on the LayerControl
|
|
15
|
+
cy.get("eox-layercontrol")
|
|
16
|
+
.shadow()
|
|
17
|
+
.within(() => {
|
|
18
|
+
// Checking the number of list items in the LayerControl
|
|
19
|
+
cy.get("ul").find("li").should("have.length", 1);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default hideLayers;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as checkLayerSize } from "./check-layer-size";
|
|
2
|
+
export { default as checkPreOpenLayerTools } from "./check-pre-open-layer-tools";
|
|
3
|
+
export { default as checkPreOpenSection } from "./check-pre-open-section";
|
|
4
|
+
export { default as disableDrag } from "./disable-drag";
|
|
5
|
+
export { default as hideLayers } from "./hide-layers";
|
|
6
|
+
export { default as renderOptionalLayer } from "./render-optional-layer";
|
|
7
|
+
export { default as showCorrectLayerTitle } from "./show-layer-title";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Function to simulate rendering an optional layer within the LayerControl
|
|
2
|
+
const renderOptionalLayer = () => {
|
|
3
|
+
// Set up the layers in the mock map
|
|
4
|
+
cy.get("mock-map").then(($el) => {
|
|
5
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
6
|
+
|
|
7
|
+
// Setting layers: one visible and another marked with layerControlOptional: true
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{ visible: true },
|
|
10
|
+
{ properties: { layerControlOptional: true } },
|
|
11
|
+
]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Verify the effect on the LayerControl
|
|
15
|
+
cy.get("eox-layercontrol")
|
|
16
|
+
.shadow()
|
|
17
|
+
.within(() => {
|
|
18
|
+
// Checking for the existence of the optional layers dropdown
|
|
19
|
+
cy.get("[data-cy='optionalLayers']").should("exist");
|
|
20
|
+
|
|
21
|
+
// Verifying the presence of a selectable option in the dropdown
|
|
22
|
+
cy.get("[data-cy='optionalLayers']")
|
|
23
|
+
.find("option:not([disabled])")
|
|
24
|
+
.should("have.length", 1);
|
|
25
|
+
|
|
26
|
+
// Checking for the existence of a button related to the optional layers
|
|
27
|
+
cy.get("[data-cy='optionalLayers']").siblings("button").should("exist");
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default renderOptionalLayer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const showCorrectLayerTitle = () => {
|
|
2
|
+
// Set up the layers in the mock map
|
|
3
|
+
cy.get("mock-map").then(($el) => {
|
|
4
|
+
const mockMap = $el[0]; // Accessing the mock map element
|
|
5
|
+
|
|
6
|
+
// Setting titles for two layers
|
|
7
|
+
mockMap.setLayers([
|
|
8
|
+
{ properties: { title: "foo" } },
|
|
9
|
+
{ properties: { title: "bar" } },
|
|
10
|
+
]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Verify the displayed titles in the LayerControl
|
|
14
|
+
cy.get("eox-layercontrol")
|
|
15
|
+
.shadow()
|
|
16
|
+
.within(() => {
|
|
17
|
+
// Check for the presence of titles within layers
|
|
18
|
+
cy.get(".layer").find(".title").contains("foo");
|
|
19
|
+
cy.get(".layer").find(".title").contains("bar");
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default showCorrectLayerTitle;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const addExternalLayers = () => {
|
|
2
|
+
// Set up a mock map with a layer "foo"
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([{ properties: { id: "foo" } }]);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
let mapTile = "";
|
|
8
|
+
|
|
9
|
+
// Add a new layer via the layer control UI
|
|
10
|
+
cy.get("eox-layercontrol")
|
|
11
|
+
.shadow()
|
|
12
|
+
.find("eox-layercontrol-add-layers")
|
|
13
|
+
.then(($el) => {
|
|
14
|
+
cy.wrap($el).within(() => {
|
|
15
|
+
// Open the add layer dialog
|
|
16
|
+
cy.get(".add-icon").click();
|
|
17
|
+
cy.get(".eox-add").should("have.class", "open");
|
|
18
|
+
|
|
19
|
+
// Input the URL to fetch layers and select the first layer in the list
|
|
20
|
+
cy.get(".add-url").type("https://ows.mundialis.de/services/service");
|
|
21
|
+
cy.get(".search-icon").as("apibtn").click();
|
|
22
|
+
cy.get("@apibtn").should("not.be.disabled");
|
|
23
|
+
|
|
24
|
+
// Select and capture the name of the added layer
|
|
25
|
+
cy.get(".add-layer-icon").first().click();
|
|
26
|
+
cy.get(".search-list")
|
|
27
|
+
.first()
|
|
28
|
+
.invoke("text")
|
|
29
|
+
.then((text) => {
|
|
30
|
+
mapTile = text.trim();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Verify if the added layer is displayed in the layer control list
|
|
36
|
+
cy.get("eox-layercontrol")
|
|
37
|
+
.shadow()
|
|
38
|
+
.find("eox-layercontrol-layer-list")
|
|
39
|
+
.then(($el) => {
|
|
40
|
+
cy.wrap($el).find("li").should("have.attr", "data-layer", mapTile);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Add another layer using a JSON configuration
|
|
44
|
+
cy.get("eox-layercontrol")
|
|
45
|
+
.shadow()
|
|
46
|
+
.find("eox-layercontrol-add-layers")
|
|
47
|
+
.then(($el) => {
|
|
48
|
+
cy.wrap($el).within(() => {
|
|
49
|
+
// Switch to the JSON tab and input the layer configuration
|
|
50
|
+
cy.get(".eox-add-layer-tab li").last().click();
|
|
51
|
+
cy.get("textarea").type(
|
|
52
|
+
`{ type: "Tile", properties: { id: "WIND", title: "WIND", }, source: { type: "TileWMS", url: "//services.sentinel-hub.com/ogc/wms/0635c213-17a1-48ee-aef7-9d1731695a54", params: { LAYERS: "AWS_VIS_WIND_V_10M", }, }, maxZoom: 9, }`,
|
|
53
|
+
{ parseSpecialCharSequences: false }
|
|
54
|
+
);
|
|
55
|
+
cy.get(".json-add-layer").click();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Verify if the second layer is displayed in the layer control list
|
|
60
|
+
cy.get("eox-layercontrol")
|
|
61
|
+
.shadow()
|
|
62
|
+
.find("eox-layercontrol-layer-list")
|
|
63
|
+
.then(($el) => {
|
|
64
|
+
cy.wrap($el).find("li").should("have.attr", "data-layer", "WIND");
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default addExternalLayers;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const addLayerFromOptional = () => {
|
|
2
|
+
// Setting up the mock map with layers and optional layers
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{
|
|
6
|
+
properties: {
|
|
7
|
+
title: "group1",
|
|
8
|
+
layerControlExpand: true,
|
|
9
|
+
},
|
|
10
|
+
layers: [{ properties: { title: "title1" } }],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
properties: {
|
|
14
|
+
title: "group2",
|
|
15
|
+
layerControlExpand: true,
|
|
16
|
+
},
|
|
17
|
+
layers: [
|
|
18
|
+
{ properties: { title: "foo" } },
|
|
19
|
+
{
|
|
20
|
+
properties: {
|
|
21
|
+
id: "title2",
|
|
22
|
+
title: "title2",
|
|
23
|
+
layerControlOptional: true,
|
|
24
|
+
},
|
|
25
|
+
visible: false,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Selecting and adding the optional layer
|
|
33
|
+
cy.get("eox-layercontrol")
|
|
34
|
+
.shadow()
|
|
35
|
+
.within(() => {
|
|
36
|
+
cy.get("[data-cy='optionalLayers']").select("title2"); // Selecting the optional layer
|
|
37
|
+
cy.get("[data-cy='optionalLayers']").siblings("button").click(); // Clicking the add button
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Verifying if the added optional layer is displayed in the layer control
|
|
41
|
+
cy.get("eox-layercontrol")
|
|
42
|
+
.shadow()
|
|
43
|
+
.within(() => {
|
|
44
|
+
cy.get(".layer")
|
|
45
|
+
.find(".title")
|
|
46
|
+
.contains("title2")
|
|
47
|
+
.should("have.length", 1); // Checking if the added optional layer's title is displayed
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default addLayerFromOptional;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const checkLayerPushedToGroup = () => {
|
|
2
|
+
// Setting up the mock map with layers and a group
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{
|
|
6
|
+
properties: {
|
|
7
|
+
title: "group",
|
|
8
|
+
layerControlExpand: true,
|
|
9
|
+
},
|
|
10
|
+
layers: [{ properties: { title: "foo" } }], // Adding a layer to a group
|
|
11
|
+
},
|
|
12
|
+
{ properties: { title: "bar" } }, // Adding a standalone layer
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Pushing a new layer to the group
|
|
17
|
+
cy.get("mock-map").and(($el) => {
|
|
18
|
+
$el[0].map // Accessing the map
|
|
19
|
+
.getLayers() // Getting all layers
|
|
20
|
+
.getArray()[0] // Accessing the first layer (group)
|
|
21
|
+
.getLayers() // Getting layers within the group
|
|
22
|
+
.push({ properties: { title: "baz" } }); // Pushing a new layer
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Verifying if the added layer appears in the layer control
|
|
26
|
+
cy.get("eox-layercontrol")
|
|
27
|
+
.shadow()
|
|
28
|
+
.within(() => {
|
|
29
|
+
cy.get(".layer").find(".title").contains("baz"); // Checking if the title of the added layer is displayed
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default checkLayerPushedToGroup;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const checkLayerIsPushedToRoot = () => {
|
|
2
|
+
// Set up the mock map with an initial layer
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([{ properties: { title: "foo" } }]);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// Pushing a new layer to the root level of the map
|
|
8
|
+
cy.get("mock-map").and(($el) => {
|
|
9
|
+
$el[0].map // Accessing the map
|
|
10
|
+
.getLayers() // Getting all layers
|
|
11
|
+
.push({ properties: { title: "bar" } }); // Pushing a new layer
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Verify if the added layer appears in the layer control
|
|
15
|
+
cy.get("eox-layercontrol")
|
|
16
|
+
.shadow()
|
|
17
|
+
.within(() => {
|
|
18
|
+
cy.get(".layer").find(".title").contains("bar"); // Checking if the title of the added layer is displayed
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default checkLayerIsPushedToRoot;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const checkLayerRemovedFromGroup = () => {
|
|
2
|
+
// Set up the mock map with a group containing a layer
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{
|
|
6
|
+
properties: {
|
|
7
|
+
title: "group",
|
|
8
|
+
layerControlExpand: true,
|
|
9
|
+
},
|
|
10
|
+
layers: [{ properties: { title: "baz" } }], // Initial layer in the group
|
|
11
|
+
},
|
|
12
|
+
{ title: "bar" }, // Another separate layer outside the group
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Remove the last layer from the group
|
|
17
|
+
cy.get("mock-map").and(($el) => {
|
|
18
|
+
$el[0].map
|
|
19
|
+
.getLayers() // Get all layers
|
|
20
|
+
.getArray()[0] // Access the group layer
|
|
21
|
+
.getLayers() // Get layers within the group
|
|
22
|
+
.pop(); // Remove the last layer
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Verify if the removed layer does not exist in the layer control
|
|
26
|
+
cy.get("eox-layercontrol")
|
|
27
|
+
.shadow()
|
|
28
|
+
.within(() => {
|
|
29
|
+
cy.get(".layer").find(".title").contains("baz").should("not.exist"); // Check if the removed layer is not present
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default checkLayerRemovedFromGroup;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const checkLayerRemovedFromRoot = () => {
|
|
2
|
+
// Set up the mock map with two layers
|
|
3
|
+
cy.get("mock-map").and(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{ properties: { id: "foo" } },
|
|
6
|
+
{ properties: { id: "bar" } },
|
|
7
|
+
]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const layerToDelete = "foo"; // Layer to be deleted
|
|
11
|
+
|
|
12
|
+
// Perform the UI interactions to remove the specified layer
|
|
13
|
+
cy.get("eox-layercontrol")
|
|
14
|
+
.shadow()
|
|
15
|
+
.within(() => {
|
|
16
|
+
// Click on the 'tools' button of the layer to show additional options
|
|
17
|
+
cy.get(`[data-layer=${layerToDelete}] .tools > summary`).click();
|
|
18
|
+
|
|
19
|
+
// Click on the 'remove' icon to delete the layer
|
|
20
|
+
cy.get("button.remove-icon:visible").last().click();
|
|
21
|
+
|
|
22
|
+
// Check if the layer UI element is removed from the layer control
|
|
23
|
+
cy.get(`[data-layer=${layerToDelete}]`).should("not.exist");
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default checkLayerRemovedFromRoot;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const checkLayerSizeAfterMultipleCalls = () => {
|
|
2
|
+
// Set layers in three different rounds
|
|
3
|
+
cy.get("mock-map").then(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{ properties: { title: "1st round - foo" } },
|
|
6
|
+
{ properties: { title: "1st round - bar" } },
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
// Clear all layers
|
|
10
|
+
$el[0].setLayers([]);
|
|
11
|
+
|
|
12
|
+
// Set new layers in the second round
|
|
13
|
+
$el[0].setLayers([
|
|
14
|
+
{ properties: { title: "2nd round - baz" } },
|
|
15
|
+
{ properties: { title: "2nd round - qux" } },
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
let numberOfLayers;
|
|
20
|
+
|
|
21
|
+
// Get the number of layers on the map after the operations
|
|
22
|
+
cy.get("mock-map").then(($el) => {
|
|
23
|
+
numberOfLayers = $el[0].map.getLayers().getArray().length;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Verify if the layer control UI reflects the correct number of layers
|
|
27
|
+
cy.get("eox-layercontrol")
|
|
28
|
+
.shadow()
|
|
29
|
+
.within(() => {
|
|
30
|
+
cy.get(".layers").find("li").should("have.length", numberOfLayers);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default checkLayerSizeAfterMultipleCalls;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const checkLayerZoomState = () => {
|
|
2
|
+
// Set layers with defined minZoom and maxZoom
|
|
3
|
+
cy.get("mock-map").then(($el) => {
|
|
4
|
+
$el[0].setLayers([
|
|
5
|
+
{ properties: { id: "foo" }, minZoom: 2 }, // Layer 'foo' visible from zoom level 2
|
|
6
|
+
{ properties: { id: "bar" }, maxZoom: 9 }, // Layer 'bar' visible till zoom level 9
|
|
7
|
+
]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Utility functions to check the class presence based on zoom level
|
|
11
|
+
const checkLayerClass = (id, have) => {
|
|
12
|
+
const haveCheck = !have ? "not." : "";
|
|
13
|
+
cy.get(`[data-layer=${id}] .layer`).should(
|
|
14
|
+
`${haveCheck}have.class`,
|
|
15
|
+
"zoom-state-invisible"
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const changeZoom = (zoom) => {
|
|
20
|
+
// Update the map's zoom level and trigger the change event
|
|
21
|
+
cy.get("mock-map").then(($el) => {
|
|
22
|
+
$el[0].setZoom(zoom);
|
|
23
|
+
$el[0].map.getEvents()["change:resolution"].map((func) => func());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Case 1: Default load with zoom level 1
|
|
28
|
+
cy.get("eox-layercontrol")
|
|
29
|
+
.shadow()
|
|
30
|
+
.within(() => {
|
|
31
|
+
checkLayerClass("foo", true); // Layer 'foo' should be visible at zoom level 1
|
|
32
|
+
checkLayerClass("bar"); // Layer 'bar' should be visible at zoom level 1
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Case 2: Change zoom level to 3
|
|
36
|
+
changeZoom(3);
|
|
37
|
+
cy.get("eox-layercontrol")
|
|
38
|
+
.shadow()
|
|
39
|
+
.within(() => {
|
|
40
|
+
checkLayerClass("foo"); // Layer 'foo' should be invisible at zoom level 3
|
|
41
|
+
checkLayerClass("bar"); // Layer 'bar' should be visible at zoom level 3
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Case 3: Change zoom level to 10
|
|
45
|
+
changeZoom(10);
|
|
46
|
+
cy.get("eox-layercontrol")
|
|
47
|
+
.shadow()
|
|
48
|
+
.within(() => {
|
|
49
|
+
checkLayerClass("foo"); // Layer 'foo' should be visible at zoom level 10
|
|
50
|
+
checkLayerClass("bar", true); // Layer 'bar' should be invisible at zoom level 10
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default checkLayerZoomState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as checkLayerIsPushedToRoot } from "./check-layer-is-pushed-to-root";
|
|
2
|
+
export { default as checkLayerSizeAfterMultipleCalls } from "./check-layer-size-after-multiple-calls";
|
|
3
|
+
export { default as checkLayerPushedToGroup } from "./check-if-layer-pushed-to-group";
|
|
4
|
+
export { default as checkLayerRemovedFromRoot } from "./check-layer-removed-from-root";
|
|
5
|
+
export { default as checkLayerRemovedFromGroup } from "./check-layer-removed-from-group";
|
|
6
|
+
export { default as addLayerFromOptional } from "./add-layer-from-optional";
|
|
7
|
+
export { default as checkLayerZoomState } from "./check-layer-zoom-state";
|
|
8
|
+
export { default as addExternalLayers } from "./add-external-layer";
|