@eox/layercontrol 0.14.0 → 0.15.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/layercontrol",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
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
- { visible: true },
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("exist");
25
+ cy.get("details[open]").should("have.length", 1);
23
26
  });
24
27
  };
25
28
 
@@ -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";
@@ -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").last().click();
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");
@@ -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