@eox/layercontrol 0.21.1 → 0.23.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/README.md +4 -0
- package/dist/eox-layercontrol.js +1360 -1216
- package/dist/eox-layercontrol.umd.cjs +220 -147
- package/package.json +10 -13
- package/src/components/add-layers.js +416 -0
- package/src/components/layer-config.js +212 -0
- package/src/components/layer-datetime.js +128 -0
- package/src/components/layer-group.js +193 -0
- package/src/components/layer-legend.js +135 -0
- package/src/components/layer-list.js +209 -0
- package/src/components/layer-tools.js +353 -0
- package/src/components/layer.js +244 -0
- package/src/components/optional-list.js +124 -0
- package/src/components/tab-sliders.js +0 -0
- package/src/components/tools-items.js +199 -0
- package/src/enums/index.js +16 -0
- package/src/enums/stories/assets/cropomhusc-feature-collection.json +5274 -0
- package/src/enums/stories/index.js +536 -0
- package/src/helpers/check-properties.js +41 -0
- package/src/helpers/clean-json-input.js +29 -0
- package/src/helpers/create-sortable.js +104 -0
- package/src/helpers/detect-map-url-type.js +20 -0
- package/src/helpers/fetch-capabilities.js +32 -0
- package/src/helpers/filter-layers.js +45 -0
- package/src/helpers/get-layer-type.js +35 -0
- package/src/helpers/get-legend-config.js +25 -0
- package/src/helpers/get-start-vals.js +73 -0
- package/src/helpers/hide-layers-based-on-property.js +11 -0
- package/src/helpers/index.js +22 -0
- package/src/helpers/is-layer-json-valid.js +19 -0
- package/src/helpers/is-layer-visible-based-on-zoom-state.js +31 -0
- package/src/helpers/is-layer-zoom-state-req.js +17 -0
- package/src/helpers/is-map-url-valid.js +22 -0
- package/src/helpers/layer-tools.js +82 -0
- package/src/helpers/update-url.js +32 -0
- package/src/main.js +269 -0
- package/src/methods/add-layer/add-layer.js +33 -0
- package/src/methods/add-layer/index.js +8 -0
- package/src/methods/add-layer/json-input-change.js +15 -0
- package/src/methods/add-layer/open-close-tab.js +21 -0
- package/src/methods/add-layer/url-input-change.js +17 -0
- package/src/methods/add-layer/url-layer.js +37 -0
- package/src/methods/add-layer/wms-search-url.js +44 -0
- package/src/methods/layer/first-updated.js +65 -0
- package/src/methods/layer/index.js +4 -0
- package/src/methods/layer/input-click.js +43 -0
- package/src/methods/layer-config/apply-updated-styles.js +98 -0
- package/src/methods/layer-config/data-change.js +44 -0
- package/src/methods/layer-config/index.js +7 -0
- package/src/methods/layer-list/first-updated.js +55 -0
- package/src/methods/layer-list/index.js +3 -0
- package/src/methods/layercontrol/first-update.js +22 -0
- package/src/methods/layercontrol/index.js +4 -0
- package/src/methods/layercontrol/layer-list-change.js +23 -0
- package/src/methods/optional-list/add-to-list.js +44 -0
- package/src/methods/optional-list/index.js +3 -0
- package/test/_mockMap.js +0 -154
- package/test/cases/general/check-layer-size.js +0 -25
- package/test/cases/general/check-pre-open-layer-tools.js +0 -26
- package/test/cases/general/check-pre-open-section.js +0 -29
- package/test/cases/general/disable-drag.js +0 -26
- package/test/cases/general/empty-groups.js +0 -41
- package/test/cases/general/exclusive-layers.js +0 -35
- package/test/cases/general/hide-layers.js +0 -23
- package/test/cases/general/index.js +0 -9
- package/test/cases/general/render-optional-layer.js +0 -31
- package/test/cases/general/show-layer-title.js +0 -23
- package/test/cases/layer-update/add-external-layer.js +0 -96
- package/test/cases/layer-update/add-layer-from-optional.js +0 -51
- package/test/cases/layer-update/check-if-layer-pushed-to-group.js +0 -33
- package/test/cases/layer-update/check-layer-changed-event.js +0 -29
- package/test/cases/layer-update/check-layer-is-pushed-to-root.js +0 -22
- package/test/cases/layer-update/check-layer-removed-from-group.js +0 -33
- package/test/cases/layer-update/check-layer-removed-from-root.js +0 -27
- package/test/cases/layer-update/check-layer-size-after-multiple-calls.js +0 -34
- package/test/cases/layer-update/check-layer-zoom-state.js +0 -54
- package/test/cases/layer-update/index.js +0 -9
- package/test/general.cy.js +0 -57
- package/test/layersUpdate.cy.js +0 -72
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { updateUrl } from "../../helpers";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This function 'dataChange' is designed to handle changes in data within a layer configuration.
|
|
5
|
+
* And creates a new a tileUrlFunction
|
|
6
|
+
*
|
|
7
|
+
* @param {{[key: string]: any}} data - The updated data to be applied to the layer.
|
|
8
|
+
* @param {Function} tileUrlFunc - The function generating the tile URL for the layer.
|
|
9
|
+
* @param {import("../../components/layer-config").EOxLayerControlLayerConfig} EOxLayerControlLayerConfig - Instance of EOxLayerControlLayer.
|
|
10
|
+
* @return {Function} - New function generating the tile URL for the layer.
|
|
11
|
+
*/
|
|
12
|
+
const dataChangeMethod = (data, tileUrlFunc, EOxLayerControlLayerConfig) => {
|
|
13
|
+
let newTileUrlFunc = tileUrlFunc; // Placeholder for the updated tile URL function.
|
|
14
|
+
|
|
15
|
+
// Checking if the layer's tile URL function exists.
|
|
16
|
+
// If it does, set 'newTileUrlFunc' to the layer's tile URL function.
|
|
17
|
+
// This step ensures the original tile URL function is preserved if 'tileUrlFunc' is not provided.
|
|
18
|
+
// @ts-expect-error TODO
|
|
19
|
+
if (EOxLayerControlLayerConfig.layer.getSource().getTileUrlFunction()) {
|
|
20
|
+
if (!newTileUrlFunc) {
|
|
21
|
+
newTileUrlFunc = EOxLayerControlLayerConfig.layer
|
|
22
|
+
.getSource()
|
|
23
|
+
// @ts-expect-error TODO
|
|
24
|
+
.getTileUrlFunction();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Setting a new tile URL function for the layer's source by applying updated data to the existing function.
|
|
28
|
+
EOxLayerControlLayerConfig.layer
|
|
29
|
+
.getSource()
|
|
30
|
+
// @ts-expect-error TODO
|
|
31
|
+
.setTileUrlFunction((...args) =>
|
|
32
|
+
updateUrl(newTileUrlFunc(...args), data),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// TODO: It's not advisable to access protected methods directly.
|
|
36
|
+
// Setting a new key for the layer source to trigger a refresh.
|
|
37
|
+
// @ts-expect-error TODO
|
|
38
|
+
EOxLayerControlLayerConfig.layer.getSource().setKey(new Date());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return newTileUrlFunc;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default dataChangeMethod;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Importing methods from respective files and exporting them
|
|
2
|
+
|
|
3
|
+
export { default as dataChangeMethod } from "./data-change"; // Handles data change with help of new tile url function
|
|
4
|
+
export {
|
|
5
|
+
default as applyUpdatedStyles,
|
|
6
|
+
flattenObject,
|
|
7
|
+
} from "./apply-updated-styles"; // Extracts values of layer styles variables from the jsonform output
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Importing helper functions from the 'helpers' directory
|
|
2
|
+
import { checkProperties, createSortable } from "../../helpers";
|
|
3
|
+
import _debounce from "lodash.debounce";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Handles initial settings and event triggers upon the component's first update.
|
|
7
|
+
* Handles updating and triggering events when the layers change length upon component update.
|
|
8
|
+
*
|
|
9
|
+
* @param {import("../../components/layer-list").EOxLayerControlLayerList} EOxLayerControlLayerList - The EOxLayerControlLayerList object containing layers.
|
|
10
|
+
*/
|
|
11
|
+
const firstUpdatedMethod = (EOxLayerControlLayerList) => {
|
|
12
|
+
// Destructuring properties from the EOxLayerControlLayerList object
|
|
13
|
+
const { layers, idProperty, titleProperty, renderRoot } =
|
|
14
|
+
EOxLayerControlLayerList;
|
|
15
|
+
|
|
16
|
+
// Debounced function for handling changes in layers' length
|
|
17
|
+
const debHandleLayersChangeLength = _debounce(() => {
|
|
18
|
+
EOxLayerControlLayerList.requestUpdate();
|
|
19
|
+
EOxLayerControlLayerList.dispatchEvent(
|
|
20
|
+
new CustomEvent("changed", { bubbles: true }),
|
|
21
|
+
);
|
|
22
|
+
}, 50);
|
|
23
|
+
|
|
24
|
+
// Function to handle changes in layers' length
|
|
25
|
+
const handleLayersChangeLength = () => debHandleLayersChangeLength();
|
|
26
|
+
|
|
27
|
+
// If layers do not exist, exit the function
|
|
28
|
+
if (!layers) return;
|
|
29
|
+
|
|
30
|
+
// Unregister previous listeners to prevent duplicates
|
|
31
|
+
if (layers.hasListener("change:length"))
|
|
32
|
+
layers?.un("change:length", handleLayersChangeLength);
|
|
33
|
+
|
|
34
|
+
// Register a listener for changes in the layers' length
|
|
35
|
+
layers.on("change:length", handleLayersChangeLength);
|
|
36
|
+
|
|
37
|
+
// Checking if layers exist
|
|
38
|
+
if (layers) {
|
|
39
|
+
// Selecting the unordered list element from the renderRoot
|
|
40
|
+
const element = renderRoot.querySelector("ul");
|
|
41
|
+
|
|
42
|
+
// Checking properties of the layers
|
|
43
|
+
checkProperties(
|
|
44
|
+
layers,
|
|
45
|
+
idProperty,
|
|
46
|
+
titleProperty,
|
|
47
|
+
EOxLayerControlLayerList,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Creating a sortable list using helper function createSortable
|
|
51
|
+
createSortable(element, layers, idProperty, EOxLayerControlLayerList);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default firstUpdatedMethod;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getElement } from "@eox/elements-utils";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the EOxMap element based on the provided selector in EOxLayerControl's 'for' property.
|
|
5
|
+
* Updates the EOxLayerControl's map property based on the target element's map.
|
|
6
|
+
*
|
|
7
|
+
* @param {import("../../main").EOxLayerControl} EOxLayerControl - The EOxLayerControl element.
|
|
8
|
+
* @returns {import("@eox/map/main").EOxMap | null} The EOxMap element or null if not found.
|
|
9
|
+
*/
|
|
10
|
+
const firstUpdatedMethod = (EOxLayerControl) => {
|
|
11
|
+
const foundElement = getElement(EOxLayerControl.for);
|
|
12
|
+
|
|
13
|
+
// Check if the element exists and its map property differs from EOxLayerControl.map
|
|
14
|
+
if (foundElement && foundElement.map !== EOxLayerControl.map) {
|
|
15
|
+
// Update the EOxLayerControl's map property
|
|
16
|
+
EOxLayerControl.map = foundElement.map;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return foundElement;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default firstUpdatedMethod;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Importing methods from respective files and exporting them
|
|
2
|
+
|
|
3
|
+
export { default as layerListChangeMethod } from "./layer-list-change"; // Handles changes in the layer list within the EOxLayerControl component.
|
|
4
|
+
export { default as firstUpdatedMethod } from "./first-update"; // Initial settings and event triggers upon the component's first update.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers an update request for the EOxLayerControl and optional list elements upon a layer list change event.
|
|
3
|
+
*
|
|
4
|
+
* @param {CustomEvent & { target: Element }} evt - The custom event containing the target element.
|
|
5
|
+
* @param {import("../../main").EOxLayerControl} EOxLayerControl - The EOxLayerControl element.
|
|
6
|
+
*/
|
|
7
|
+
const layerListChangeMethod = (evt, EOxLayerControl) => {
|
|
8
|
+
// Request an update for the EOxLayerControl
|
|
9
|
+
EOxLayerControl.requestUpdate();
|
|
10
|
+
|
|
11
|
+
// Check if the event target matches the specified element tag
|
|
12
|
+
if (evt.target.tagName === "EOX-LAYERCONTROL-LAYER-TOOLS") {
|
|
13
|
+
const optionalListEl = EOxLayerControl.renderRoot.querySelector(
|
|
14
|
+
"eox-layercontrol-optional-list",
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// Request an update for the optional list element if found
|
|
18
|
+
/** * @type {Element & { requestUpdate: function }} */
|
|
19
|
+
(optionalListEl)?.requestUpdate();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default layerListChangeMethod;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { filterLayers } from "../../helpers";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the selected layer to the optional list in the layer control.
|
|
5
|
+
*
|
|
6
|
+
* @param {import("../../components/optional-list").EOxLayerControlOptionalList} EOxLayerControlOptionalList - The optional list component.
|
|
7
|
+
*/
|
|
8
|
+
const addToListMethod = (EOxLayerControlOptionalList) => {
|
|
9
|
+
// Get the selected layer based on the value from the dropdown
|
|
10
|
+
/** @type HTMLInputElement*/
|
|
11
|
+
const optionalSelect = EOxLayerControlOptionalList.querySelector(
|
|
12
|
+
"select[name=optional]",
|
|
13
|
+
);
|
|
14
|
+
const selectedValue = optionalSelect ? optionalSelect.value : null;
|
|
15
|
+
|
|
16
|
+
const selectedLayer = filterLayers(
|
|
17
|
+
EOxLayerControlOptionalList.layers.getArray(),
|
|
18
|
+
"layerControlOptional",
|
|
19
|
+
true,
|
|
20
|
+
).find(
|
|
21
|
+
(layer) =>
|
|
22
|
+
// @ts-expect-error TODO
|
|
23
|
+
(layer.get(EOxLayerControlOptionalList.idProperty) || layer.ol_uid) ===
|
|
24
|
+
selectedValue,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Update visibility and dispatch 'changed' event
|
|
28
|
+
selectedLayer?.set("layerControlOptional", false);
|
|
29
|
+
selectedLayer?.setVisible(true);
|
|
30
|
+
EOxLayerControlOptionalList.dispatchEvent(
|
|
31
|
+
new CustomEvent("changed", { bubbles: true }),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Update related components
|
|
35
|
+
EOxLayerControlOptionalList.renderRoot.parentNode
|
|
36
|
+
.querySelectorAll("eox-layercontrol-layer-list")
|
|
37
|
+
.forEach((layerList) =>
|
|
38
|
+
/** @type {import("lit").LitElement} */ (layerList).requestUpdate(),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
EOxLayerControlOptionalList.requestUpdate();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default addToListMethod;
|
package/test/_mockMap.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
class MockLayer {
|
|
2
|
-
constructor(layer) {
|
|
3
|
-
Object.keys(layer).forEach((k) => {
|
|
4
|
-
if (k === "properties") {
|
|
5
|
-
this.properties = {
|
|
6
|
-
...this.properties,
|
|
7
|
-
...layer.properties,
|
|
8
|
-
};
|
|
9
|
-
} else {
|
|
10
|
-
this[k] = layer[k];
|
|
11
|
-
}
|
|
12
|
-
if (layer.layers) {
|
|
13
|
-
this.layers = new MockCollection(layer.layers);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
get(prop) {
|
|
18
|
-
return this.properties[prop] || this[prop];
|
|
19
|
-
}
|
|
20
|
-
getLayers() {
|
|
21
|
-
return this.layers || new MockCollection([]);
|
|
22
|
-
}
|
|
23
|
-
getOpacity() {
|
|
24
|
-
return this.opacity;
|
|
25
|
-
}
|
|
26
|
-
getVisible() {
|
|
27
|
-
return this.visible;
|
|
28
|
-
}
|
|
29
|
-
layers;
|
|
30
|
-
opacity = 1;
|
|
31
|
-
properties = {
|
|
32
|
-
id: "foo",
|
|
33
|
-
title: "layer",
|
|
34
|
-
};
|
|
35
|
-
minZoom = -Infinity;
|
|
36
|
-
maxZoom = Infinity;
|
|
37
|
-
set(prop, value) {
|
|
38
|
-
this.properties[prop] = value;
|
|
39
|
-
}
|
|
40
|
-
setVisible(visible) {
|
|
41
|
-
this.visible = visible;
|
|
42
|
-
}
|
|
43
|
-
visible = true;
|
|
44
|
-
events = {
|
|
45
|
-
["change"]: () => undefined,
|
|
46
|
-
};
|
|
47
|
-
on = (event, fun) => (this.events = { [event]: fun });
|
|
48
|
-
un = (event, fun) => {
|
|
49
|
-
if (this.events[event] == fun) {
|
|
50
|
-
delete this.events[event];
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class MockCollection {
|
|
56
|
-
constructor(layers) {
|
|
57
|
-
this.layers = layers.map((l) => new MockLayer(l));
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
this.events["change:length"]();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
events = {
|
|
63
|
-
["change:length"]: () => undefined,
|
|
64
|
-
};
|
|
65
|
-
getArray = () => {
|
|
66
|
-
return this.layers;
|
|
67
|
-
};
|
|
68
|
-
layers = [];
|
|
69
|
-
on = (event, fun) => (this.events = { [event]: fun });
|
|
70
|
-
un = (event, fun) => {
|
|
71
|
-
if (this.events[event] == fun) {
|
|
72
|
-
delete this.events[event];
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
hasListener = (event) => event in this.events;
|
|
76
|
-
pop() {
|
|
77
|
-
this.layers.pop();
|
|
78
|
-
this.events["change:length"]();
|
|
79
|
-
}
|
|
80
|
-
push(newLayer) {
|
|
81
|
-
this.layers.push(new MockLayer(newLayer));
|
|
82
|
-
this.events["change:length"]();
|
|
83
|
-
}
|
|
84
|
-
remove(layer) {
|
|
85
|
-
layer = new MockLayer(layer);
|
|
86
|
-
const i = this.layers.indexOf(layer);
|
|
87
|
-
if (i) {
|
|
88
|
-
this.layers.splice(i, 1);
|
|
89
|
-
return layer;
|
|
90
|
-
} else {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
removeAt(index) {
|
|
95
|
-
this.layers = [...this.layers.slice(index)];
|
|
96
|
-
}
|
|
97
|
-
insertAt(index, layer) {
|
|
98
|
-
layer = new MockLayer(layer);
|
|
99
|
-
this.layers = [
|
|
100
|
-
...this.layers.slice(0, index),
|
|
101
|
-
layer,
|
|
102
|
-
...this.layers.slice(index),
|
|
103
|
-
];
|
|
104
|
-
}
|
|
105
|
-
getLength() {
|
|
106
|
-
return this.layers.length;
|
|
107
|
-
}
|
|
108
|
-
forEach(func) {
|
|
109
|
-
this.layers.forEach(func);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export class MockMap extends HTMLElement {
|
|
114
|
-
constructor() {
|
|
115
|
-
super();
|
|
116
|
-
}
|
|
117
|
-
layers;
|
|
118
|
-
events = {
|
|
119
|
-
"change:resolution": [],
|
|
120
|
-
};
|
|
121
|
-
map = {
|
|
122
|
-
getInteractions: () => ({
|
|
123
|
-
getArray: () => [{}],
|
|
124
|
-
}),
|
|
125
|
-
getLayers: () => {
|
|
126
|
-
if (this.layers) {
|
|
127
|
-
return this.layers;
|
|
128
|
-
} else {
|
|
129
|
-
return new MockCollection([]);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
getEvents: () => this.events,
|
|
133
|
-
getView: () => ({
|
|
134
|
-
getZoom: () => this.zoom,
|
|
135
|
-
on: (type, listener) => {
|
|
136
|
-
this.events = {
|
|
137
|
-
...this.events,
|
|
138
|
-
[type]: [...this.events[type], listener],
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
}),
|
|
142
|
-
};
|
|
143
|
-
zoom = 1;
|
|
144
|
-
setZoom = (z) => {
|
|
145
|
-
this.zoom = z;
|
|
146
|
-
};
|
|
147
|
-
addOrUpdateLayer = (json) => {
|
|
148
|
-
this.setLayers([json]);
|
|
149
|
-
};
|
|
150
|
-
setLayers = (layers) => {
|
|
151
|
-
this.layers = new MockCollection(layers.reverse());
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
customElements.define("mock-map", MockMap);
|
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
{
|
|
10
|
-
properties: { layerControlExpand: undefined },
|
|
11
|
-
layers: [{ visible: true }],
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
properties: { layerControlExpand: true },
|
|
15
|
-
layers: [{ visible: true }],
|
|
16
|
-
},
|
|
17
|
-
]);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Verify if the section opens within the LayerControl component
|
|
21
|
-
cy.get("eox-layercontrol")
|
|
22
|
-
.shadow()
|
|
23
|
-
.within(() => {
|
|
24
|
-
// Checking if a details tag (any open section) exists
|
|
25
|
-
cy.get("details[open]").should("have.length", 1);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default checkPreOpenSection;
|
|
@@ -1,26 +0,0 @@
|
|
|
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.disabled").should("have.length", 1);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default disableDrag;
|
|
@@ -1,41 +0,0 @@
|
|
|
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;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Function to simulate exclusive layers and groups within the LayerControl
|
|
2
|
-
const exclusiveLayers = () => {
|
|
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 and a group with layerControlExclusive
|
|
8
|
-
mockMap.setLayers([
|
|
9
|
-
{ properties: { id: "a", layerControlExclusive: true }, visible: true },
|
|
10
|
-
{ properties: { id: "b", layerControlExclusive: true }, visible: false },
|
|
11
|
-
{
|
|
12
|
-
type: "Group",
|
|
13
|
-
properties: {
|
|
14
|
-
id: "c",
|
|
15
|
-
layerControlExclusive: true,
|
|
16
|
-
layerControlExpand: true,
|
|
17
|
-
},
|
|
18
|
-
layers: [{ properties: { id: "d", visible: true } }],
|
|
19
|
-
visible: false,
|
|
20
|
-
},
|
|
21
|
-
]);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Verify the effect on the LayerControl
|
|
25
|
-
cy.get("eox-layercontrol")
|
|
26
|
-
.shadow()
|
|
27
|
-
.within(() => {
|
|
28
|
-
// Checking the number of checked radio inputs in the LayerControl
|
|
29
|
-
cy.get("ul").find("input[type=radio]:checked").should("have.length", 1);
|
|
30
|
-
cy.get("ul").find("input[type=radio]:not(:checked)").last().click();
|
|
31
|
-
cy.get("ul").find("input[type=radio]:checked").should("have.length", 1);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default exclusiveLayers;
|
|
@@ -1,23 +0,0 @@
|
|
|
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;
|
|
@@ -1,9 +0,0 @@
|
|
|
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 exclusiveLayers } from "./exclusive-layers";
|
|
6
|
-
export { default as hideLayers } from "./hide-layers";
|
|
7
|
-
export { default as emptyGroup } from "./empty-groups";
|
|
8
|
-
export { default as renderOptionalLayer } from "./render-optional-layer";
|
|
9
|
-
export { default as showCorrectLayerTitle } from "./show-layer-title";
|
|
@@ -1,31 +0,0 @@
|
|
|
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;
|
|
@@ -1,23 +0,0 @@
|
|
|
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;
|