@eox/layercontrol 0.13.1 → 0.15.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 +9876 -16239
- package/dist/eox-layercontrol.umd.cjs +192 -177
- package/package.json +1 -1
- package/test/_mockMap.js +1 -1
- package/test/cases/general/check-pre-open-section.js +5 -2
- package/test/cases/general/disable-drag.js +1 -1
- package/test/cases/general/empty-groups.js +41 -0
- package/test/cases/general/index.js +1 -0
- package/test/cases/layer-update/add-external-layer.js +48 -21
- package/test/cases/layer-update/check-if-layer-pushed-to-group.js +1 -1
- package/test/cases/layer-update/check-layer-removed-from-group.js +1 -1
- package/test/cases/layer-update/check-layer-removed-from-root.js +1 -1
- package/test/general.cy.js +4 -0
package/package.json
CHANGED
package/test/_mockMap.js
CHANGED
|
@@ -148,7 +148,7 @@ export class MockMap extends HTMLElement {
|
|
|
148
148
|
this.setLayers([json]);
|
|
149
149
|
};
|
|
150
150
|
setLayers = (layers) => {
|
|
151
|
-
this.layers = new MockCollection(layers);
|
|
151
|
+
this.layers = new MockCollection(layers.reverse());
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
customElements.define("mock-map", MockMap);
|
|
@@ -6,7 +6,10 @@ const checkPreOpenSection = () => {
|
|
|
6
6
|
|
|
7
7
|
// Setting layers: one visible and another with layerControlExpand: true
|
|
8
8
|
mockMap.setLayers([
|
|
9
|
-
{
|
|
9
|
+
{
|
|
10
|
+
properties: { layerControlExpand: undefined },
|
|
11
|
+
layers: [{ visible: true }],
|
|
12
|
+
},
|
|
10
13
|
{
|
|
11
14
|
properties: { layerControlExpand: true },
|
|
12
15
|
layers: [{ visible: true }],
|
|
@@ -19,7 +22,7 @@ const checkPreOpenSection = () => {
|
|
|
19
22
|
.shadow()
|
|
20
23
|
.within(() => {
|
|
21
24
|
// Checking if a details tag (any open section) exists
|
|
22
|
-
cy.get("details[open]").should("
|
|
25
|
+
cy.get("details[open]").should("have.length", 1);
|
|
23
26
|
});
|
|
24
27
|
};
|
|
25
28
|
|
|
@@ -19,7 +19,7 @@ const disableDrag = () => {
|
|
|
19
19
|
cy.get(".tools summary").click({ multiple: true });
|
|
20
20
|
|
|
21
21
|
// Verifying the visibility of the drag handle
|
|
22
|
-
cy.get(".drag-handle
|
|
22
|
+
cy.get(".drag-handle.disabled").should("have.length", 1);
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Function to simulate "empty" groups within the LayerControl
|
|
2
|
+
const emptyGroup = () => {
|
|
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 layer groups: one with visible layers and another one with hidden layers
|
|
8
|
+
mockMap.setLayers([
|
|
9
|
+
{
|
|
10
|
+
layers: [
|
|
11
|
+
{ properties: { layerControlHide: false } },
|
|
12
|
+
{ properties: { layerControlHide: false } },
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
layers: [
|
|
17
|
+
{ properties: { layerControlHide: true } },
|
|
18
|
+
{ properties: { layerControlHide: true } },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Verify the effect on the LayerControl
|
|
25
|
+
cy.get("eox-layercontrol")
|
|
26
|
+
.shadow()
|
|
27
|
+
.within(() => {
|
|
28
|
+
cy.get("summary").then(($els) => {
|
|
29
|
+
const control = $els[0];
|
|
30
|
+
const test = $els[6];
|
|
31
|
+
const checkDisplay = (el) =>
|
|
32
|
+
el.ownerDocument.defaultView
|
|
33
|
+
.getComputedStyle(el, "before")
|
|
34
|
+
.getPropertyValue("display");
|
|
35
|
+
expect(checkDisplay(control)).to.eq("block");
|
|
36
|
+
expect(checkDisplay(test)).to.eq("none");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default emptyGroup;
|
|
@@ -3,5 +3,6 @@ export { default as checkPreOpenLayerTools } from "./check-pre-open-layer-tools"
|
|
|
3
3
|
export { default as checkPreOpenSection } from "./check-pre-open-section";
|
|
4
4
|
export { default as disableDrag } from "./disable-drag";
|
|
5
5
|
export { default as hideLayers } from "./hide-layers";
|
|
6
|
+
export { default as emptyGroup } from "./empty-groups";
|
|
6
7
|
export { default as renderOptionalLayer } from "./render-optional-layer";
|
|
7
8
|
export { default as showCorrectLayerTitle } from "./show-layer-title";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
const DUMMY_API_RESPONSE = [
|
|
2
|
+
"GET",
|
|
3
|
+
"https://ows.mundialis.de/services/service?SERVICE=WMS&REQUEST=GetCapabilities",
|
|
4
|
+
{
|
|
5
|
+
statusCode: 200,
|
|
6
|
+
headers: { "Content-Type": "application/vnd.ogc.wms_xml" },
|
|
7
|
+
body: `<?xml version="1.0"?> <WMT_MS_Capabilities version="1.1.1"> <Capability> <Layer queryable="1"> <Title>OpenStreetMap WMS</Title> <Layer queryable="1"> <Name>bar</Name> </Layer> </Layer> </Capability> </WMT_MS_Capabilities>`,
|
|
8
|
+
},
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const DUMMY_JSON = `{ type: "Tile", properties: { id: "baz", title: "baz" }}`;
|
|
12
|
+
|
|
1
13
|
const addExternalLayers = () => {
|
|
2
14
|
// Set up a mock map with a layer "foo"
|
|
3
15
|
cy.get("mock-map").and(($el) => {
|
|
@@ -6,6 +18,9 @@ const addExternalLayers = () => {
|
|
|
6
18
|
|
|
7
19
|
let mapTile = "";
|
|
8
20
|
|
|
21
|
+
// Intercept API Response So that API don't fail
|
|
22
|
+
cy.intercept(...DUMMY_API_RESPONSE).as("getDummyXml");
|
|
23
|
+
|
|
9
24
|
// Add a new layer via the layer control UI
|
|
10
25
|
cy.get("eox-layercontrol")
|
|
11
26
|
.shadow()
|
|
@@ -17,7 +32,9 @@ const addExternalLayers = () => {
|
|
|
17
32
|
cy.get(".eox-add").should("have.class", "open");
|
|
18
33
|
|
|
19
34
|
// 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"
|
|
35
|
+
cy.get(".add-url").type("https://ows.mundialis.de/services/service", {
|
|
36
|
+
force: true,
|
|
37
|
+
});
|
|
21
38
|
cy.get(".search-icon").as("apibtn").click();
|
|
22
39
|
cy.get("@apibtn").should("not.be.disabled");
|
|
23
40
|
|
|
@@ -30,14 +47,21 @@ const addExternalLayers = () => {
|
|
|
30
47
|
mapTile = text.trim();
|
|
31
48
|
});
|
|
32
49
|
});
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
})
|
|
51
|
+
.then(() => {
|
|
52
|
+
cy.wait("@getDummyXml")
|
|
53
|
+
.its("response")
|
|
54
|
+
.then(() => {
|
|
55
|
+
// Verify if the added layer is displayed in the layer control list
|
|
56
|
+
cy.get("eox-layercontrol")
|
|
57
|
+
.shadow()
|
|
58
|
+
.find("eox-layercontrol-layer-list")
|
|
59
|
+
.then(($el) => {
|
|
60
|
+
cy.wrap($el).first(() => {
|
|
61
|
+
cy.get("li").should("have.attr", "data-layer", mapTile);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
41
65
|
});
|
|
42
66
|
|
|
43
67
|
// Add another layer using a JSON configuration
|
|
@@ -48,21 +72,24 @@ const addExternalLayers = () => {
|
|
|
48
72
|
cy.wrap($el).within(() => {
|
|
49
73
|
// Switch to the JSON tab and input the layer configuration
|
|
50
74
|
cy.get(".eox-add-layer-tab li").last().click();
|
|
51
|
-
cy.get("textarea").type(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
75
|
+
cy.get("textarea").type(DUMMY_JSON, {
|
|
76
|
+
parseSpecialCharSequences: false,
|
|
77
|
+
force: true,
|
|
78
|
+
});
|
|
55
79
|
cy.get(".json-add-layer").as("jsonbtn").click();
|
|
56
80
|
cy.get("@jsonbtn").should("be.disabled");
|
|
57
81
|
});
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
})
|
|
83
|
+
.then(() => {
|
|
84
|
+
// Verify if the second layer is displayed in the layer control list
|
|
85
|
+
cy.get("eox-layercontrol")
|
|
86
|
+
.shadow()
|
|
87
|
+
.find("eox-layercontrol-layer-list")
|
|
88
|
+
.then(($el) => {
|
|
89
|
+
cy.wrap($el).first(() => {
|
|
90
|
+
cy.get("li").should("have.attr", "data-layer", "baz");
|
|
91
|
+
});
|
|
92
|
+
});
|
|
66
93
|
});
|
|
67
94
|
};
|
|
68
95
|
|
|
@@ -2,6 +2,7 @@ const checkLayerPushedToGroup = () => {
|
|
|
2
2
|
// Setting up the mock map with layers and a group
|
|
3
3
|
cy.get("mock-map").and(($el) => {
|
|
4
4
|
$el[0].setLayers([
|
|
5
|
+
{ properties: { title: "bar" } }, // Adding a standalone layer
|
|
5
6
|
{
|
|
6
7
|
properties: {
|
|
7
8
|
title: "group",
|
|
@@ -9,7 +10,6 @@ const checkLayerPushedToGroup = () => {
|
|
|
9
10
|
},
|
|
10
11
|
layers: [{ properties: { title: "foo" } }], // Adding a layer to a group
|
|
11
12
|
},
|
|
12
|
-
{ properties: { title: "bar" } }, // Adding a standalone layer
|
|
13
13
|
]);
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -2,6 +2,7 @@ const checkLayerRemovedFromGroup = () => {
|
|
|
2
2
|
// Set up the mock map with a group containing a layer
|
|
3
3
|
cy.get("mock-map").and(($el) => {
|
|
4
4
|
$el[0].setLayers([
|
|
5
|
+
{ title: "bar" }, // Another separate layer outside the group
|
|
5
6
|
{
|
|
6
7
|
properties: {
|
|
7
8
|
title: "group",
|
|
@@ -9,7 +10,6 @@ const checkLayerRemovedFromGroup = () => {
|
|
|
9
10
|
},
|
|
10
11
|
layers: [{ properties: { title: "baz" } }], // Initial layer in the group
|
|
11
12
|
},
|
|
12
|
-
{ title: "bar" }, // Another separate layer outside the group
|
|
13
13
|
]);
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ const checkLayerRemovedFromRoot = () => {
|
|
|
17
17
|
cy.get(`[data-layer=${layerToDelete}] .tools > summary`).click();
|
|
18
18
|
|
|
19
19
|
// Click on the 'remove' icon to delete the layer
|
|
20
|
-
cy.get("button.remove-icon:visible").
|
|
20
|
+
cy.get("button.remove-icon:visible").first().click();
|
|
21
21
|
|
|
22
22
|
// Check if the layer UI element is removed from the layer control
|
|
23
23
|
cy.get(`[data-layer=${layerToDelete}]`).should("not.exist");
|
package/test/general.cy.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
checkPreOpenSection,
|
|
8
8
|
disableDrag,
|
|
9
9
|
hideLayers,
|
|
10
|
+
emptyGroup,
|
|
10
11
|
renderOptionalLayer,
|
|
11
12
|
showCorrectLayerTitle,
|
|
12
13
|
} from "./cases/general";
|
|
@@ -30,6 +31,9 @@ describe("LayerControl", () => {
|
|
|
30
31
|
// Test to validate the hiding of layers
|
|
31
32
|
it("hides layers correctly", () => hideLayers());
|
|
32
33
|
|
|
34
|
+
// Test if groups with no layers are shown as not expandable
|
|
35
|
+
it("shows groups with no layers as not expandable", () => emptyGroup());
|
|
36
|
+
|
|
33
37
|
// Test to verify the rendering of optional layer selection
|
|
34
38
|
it("renders the optional layer selection", () => renderOptionalLayer());
|
|
35
39
|
|