@eox/itemfilter 0.9.0-alpha.1 → 0.10.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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "0.9.0-alpha.1",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
7
7
  "@types/lodash.debounce": "^4.0.7",
8
- "@typescript-eslint/eslint-plugin": "^5.50.0",
9
- "@typescript-eslint/parser": "^5.50.0",
8
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
9
+ "@typescript-eslint/parser": "^6.8.0",
10
10
  "eslint-plugin-typescript": "^0.14.0",
11
- "typescript": "^4.9.3",
11
+ "typescript": "^5.2.2",
12
12
  "vite": "^4.0.0"
13
13
  },
14
14
  "engines": {
@@ -22,7 +22,7 @@
22
22
  "main": "./dist/eox-itemfilter.js",
23
23
  "scripts": {
24
24
  "build": "tsc && vite build",
25
- "watch": "vite build --watch",
25
+ "watch": "tsc && vite build --watch",
26
26
  "format": "prettier --write .",
27
27
  "lint": "eslint --ext .js,.ts .",
28
28
  "lint:fix": "eslint --ext .js,.ts . --fix"
@@ -31,8 +31,8 @@
31
31
  "@floating-ui/dom": "^1.5.3",
32
32
  "@turf/boolean-intersects": "^6.5.0",
33
33
  "@turf/boolean-within": "^6.5.0",
34
- "fuse.js": "^6.6.2",
35
- "lit": "^2.7.4",
34
+ "fuse.js": "^7.0.0",
35
+ "lit": "^3.0.2",
36
36
  "lodash.debounce": "^4.0.8",
37
37
  "toolcool-range-slider": "^4.0.27"
38
38
  }
@@ -0,0 +1,20 @@
1
+ export class MockMap extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ this.attachShadow({ mode: "open" });
5
+ const canvas = document.createElement("canvas");
6
+ this.shadowRoot.appendChild(canvas);
7
+ }
8
+ addDraw() {}
9
+ interactions = {
10
+ drawInteraction: {
11
+ on: () => {},
12
+ },
13
+ drawInteraction_modify: {
14
+ on: () => {},
15
+ },
16
+ };
17
+ removeInteraction() {}
18
+ setLayers() {}
19
+ }
20
+ customElements.define("eox-map", MockMap);
@@ -1,4 +1,5 @@
1
1
  import "../src/main";
2
+ import "./_mockMap";
2
3
  import testItems from "./testItems.json";
3
4
 
4
5
  describe("Item Filter Config", () => {
@@ -10,8 +11,9 @@ describe("Item Filter Config", () => {
10
11
  </eox-itemfilter>`
11
12
  )
12
13
  .as("eox-itemfilter")
13
- .then((eoxItemFilter: any) => {
14
- eoxItemFilter[0].config = {
14
+ .then(($el) => {
15
+ const eoxItemFilter = <EOxItemFilter>$el[0];
16
+ eoxItemFilter.config = {
15
17
  titleProperty: "title",
16
18
  filterProperties: [
17
19
  {
@@ -25,7 +27,7 @@ describe("Item Filter Config", () => {
25
27
  aggregateResults: "themes",
26
28
  enableHighlighting: true,
27
29
  };
28
- eoxItemFilter[0].apply(testItems);
30
+ eoxItemFilter.apply(testItems);
29
31
  });
30
32
  });
31
33
 
@@ -85,10 +87,16 @@ describe("Item Filter Config", () => {
85
87
  cy.get("eox-itemfilter")
86
88
  .shadow()
87
89
  .within(() => {
88
- cy.get('[type="checkbox"]').first().check();
89
- cy.get('[type="checkbox"]').eq(1).check();
90
- cy.get('[type="checkbox"]').first().check().should("be.checked");
91
- cy.get('[type="checkbox"]').eq(1).check().should("be.checked");
90
+ cy.get("eox-selectionlist")
91
+ .shadow()
92
+ .within(() => {
93
+ cy.get('[type="checkbox"]').first().check();
94
+ cy.get('[type="checkbox"]').eq(1).check();
95
+ cy.get('[type="checkbox"]').first().check();
96
+ cy.get('[type="checkbox"]').first().should("be.checked");
97
+ cy.get('[type="checkbox"]').eq(1).check();
98
+ cy.get('[type="checkbox"]').eq(1).should("be.checked");
99
+ });
92
100
  });
93
101
  });
94
102
 
@@ -185,4 +193,36 @@ describe("Item Filter Config", () => {
185
193
  checkExclusiveOpen("ul#filters", true);
186
194
  checkExclusiveOpen("ul#results");
187
195
  });
196
+
197
+ it("should show the map when spatial filter is enabled", () => {
198
+ cy.get("eox-itemfilter").and(($el) => {
199
+ const eoxItemFilter = <EOxItemFilter>$el[0];
200
+ eoxItemFilter.config = {
201
+ titleProperty: "title",
202
+ filterProperties: [
203
+ {
204
+ key: "geometry",
205
+ type: "spatial",
206
+ expanded: true,
207
+ },
208
+ ],
209
+ };
210
+ eoxItemFilter.apply(testItems);
211
+ });
212
+ cy.get("eox-itemfilter")
213
+ .shadow()
214
+ .within(() => {
215
+ cy.get("eox-itemfilter-spatial")
216
+ .get("eox-itemfilter-spatial-filter")
217
+ .shadow()
218
+ .within(() => {
219
+ cy.get("eox-map").should("exist");
220
+ cy.get("eox-map")
221
+ .shadow()
222
+ .within(() => {
223
+ cy.get("canvas").should("exist");
224
+ });
225
+ });
226
+ });
227
+ });
188
228
  });
package/test/state.cy.ts CHANGED
@@ -10,21 +10,23 @@ describe("Item Filter Config", () => {
10
10
  beforeEach(() => {
11
11
  cy.mount(`<eox-itemfilter></eox-itemfilter>`)
12
12
  .as("eox-itemfilter")
13
- .then((eoxItemFilter: any) => {
14
- eoxItemFilter[0].config = {
13
+ .then(($el) => {
14
+ const eoxItemFilter = <EOxItemFilter>$el[0];
15
+ eoxItemFilter.config = {
15
16
  titleProperty: "title",
16
17
  filterProperties: [
17
18
  {
18
19
  key: "themes",
19
20
  type: "multiselect",
20
21
  expanded: true,
22
+ // @ts-ignore
21
23
  state,
22
24
  },
23
25
  ],
24
26
  aggregateResults: "themes",
25
27
  };
26
- eoxItemFilter[0].apply(testItems);
27
- eoxItemFilter[0].selectedResult = testItems[selectedResultIndex];
28
+ eoxItemFilter.apply(testItems);
29
+ eoxItemFilter.selectedResult = testItems[selectedResultIndex];
28
30
  });
29
31
  });
30
32
 
@@ -32,10 +34,11 @@ describe("Item Filter Config", () => {
32
34
  cy.get("eox-itemfilter")
33
35
  .shadow()
34
36
  .within(() => {
35
- cy.get("input[data-cy=multiselect-checkbox][checked]").should(
36
- "have.length",
37
- 2
38
- );
37
+ cy.get("eox-selectionlist")
38
+ .shadow()
39
+ .within(() => {
40
+ cy.get('[type="checkbox"]:checked').should("have.length", 2);
41
+ });
39
42
  });
40
43
  });
41
44