@eox/itemfilter 0.14.2-dev.1721300624.0 → 0.14.2-dev.1721739772.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "0.14.2-dev.1721300624.0",
3
+ "version": "0.14.2-dev.1721739772.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
@@ -29,7 +29,7 @@
29
29
  "lint:fix": "eslint --ext .js,.ts . --fix"
30
30
  },
31
31
  "dependencies": {
32
- "@floating-ui/dom": "^1.5.3",
32
+ "@floating-ui/dom": "^1.6.8",
33
33
  "@turf/boolean-intersects": "^7.0.0",
34
34
  "@turf/boolean-within": "^7.0.0",
35
35
  "fuse.js": "^7.0.0",
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tests the `filterKeys` options within the `filterObject`.
3
+ * It verifies that the `filterKeys` override the normally rendered filter keys.
4
+ *
5
+ * @param {Array} filterKeys - An array including the custom filter keys.
6
+ */
7
+ const filterKeysTest = (filterKeys) => {
8
+ cy.get("eox-itemfilter")
9
+ .shadow()
10
+ .within(() => {
11
+ cy.get("eox-itemfilter-select")
12
+ .should("be.visible")
13
+ .shadow()
14
+ .within(($el) => {
15
+ const identifiers = $el[0].querySelectorAll("li[data-identifier");
16
+ expect(identifiers.length).to.eq(filterKeys.length);
17
+ expect(identifiers[0].dataset.identifier).to.eq(filterKeys[0]);
18
+ });
19
+ });
20
+ };
21
+
22
+ export default filterKeysTest;
@@ -0,0 +1,3 @@
1
+ // Exported test methods
2
+
3
+ export { default as filterkeysTest } from "./filter-keys";
@@ -29,7 +29,7 @@ const externalFilterTest = () => {
29
29
  cy.get("eox-itemfilter-results summary .title")
30
30
  .first()
31
31
  .contains(testItems[5].themes[0]);
32
- cy.get("eox-itemfilter-results label .title")
32
+ cy.get("eox-itemfilter-results li .title")
33
33
  .first()
34
34
  .contains(testItems[5].title);
35
35
  });
@@ -9,3 +9,4 @@ export { default as accordionTest } from "./accordion";
9
9
  export { default as spatialFilterTest } from "./spatial-filter";
10
10
  export { default as externalFilterTest } from "./external-filter";
11
11
  export { default as nestedPropertyTest } from "./nested-property";
12
+ export { default as subtitleTest } from "./subtitle";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Tests the subtitle functionality. If the confif option `subTitleProperty` is set,
3
+ * then an additional subtitle is rendered.
4
+ */
5
+ const subtitleTest = () => {
6
+ cy.get("eox-itemfilter")
7
+ .shadow()
8
+ .within(() => {
9
+ cy.get("eox-itemfilter-results").within(() => {
10
+ cy.get(".title").siblings(".subtitle").should("exist");
11
+ });
12
+ });
13
+ };
14
+
15
+ export default subtitleTest;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Tests that the specified result is pre-checked in the eox-itemfilter-results component.
3
- * It verifies that the radio button at the specified index is checked and that only one radio button is checked.
3
+ * It verifies that the result at the specified index is selected and that only one result is selected.
4
4
  *
5
5
  * @param {number} selectedResultIndex - The index of the result that should be pre-checked.
6
6
  */
@@ -9,10 +9,10 @@ const resultPreCheckedTest = (selectedResultIndex) => {
9
9
  .shadow()
10
10
  .within(() => {
11
11
  cy.get("eox-itemfilter-results").within(() => {
12
- cy.get("input[data-cy=result-radio]")
12
+ cy.get(".details-results li")
13
13
  .eq(selectedResultIndex)
14
- .should("be.checked");
15
- cy.get("input[data-cy=result-radio][checked]").should("have.length", 1);
14
+ .should("have.class", "highlighted");
15
+ cy.get(".details-results li.highlighted").should("have.length", 1);
16
16
  });
17
17
  });
18
18
  };
@@ -0,0 +1,56 @@
1
+ import "../src/main";
2
+ import testItems from "./testItems.json";
3
+ import { filterkeysTest } from "./cases/filters/";
4
+
5
+ describe("Item Filter Config", () => {
6
+ const state = {
7
+ agriculture: true,
8
+ health: true,
9
+ };
10
+
11
+ const customOrder = {
12
+ health: 0,
13
+ water: 1,
14
+ air: 2,
15
+ economy: 3,
16
+ agriculture: 4,
17
+ };
18
+
19
+ const selectedResultIndex = 1;
20
+
21
+ const filterKeys = ["foo", "bar", 0, true];
22
+
23
+ /**
24
+ * Runs before each test case to mount the eox-itemfilter component and configure it.
25
+ */
26
+ beforeEach(() => {
27
+ cy.mount(`<eox-itemfilter></eox-itemfilter>`)
28
+ .as("eox-itemfilter")
29
+ .then(($el) => {
30
+ const eoxItemFilter = $el[0];
31
+ Object.assign(eoxItemFilter, {
32
+ config: {
33
+ titleProperty: "title",
34
+ filterProperties: [
35
+ {
36
+ key: "themes",
37
+ type: "multiselect",
38
+ expanded: true,
39
+ sort: (a, b) => customOrder[a] - customOrder[b],
40
+ state,
41
+ filterKeys,
42
+ },
43
+ ],
44
+ aggregateResults: "themes",
45
+ },
46
+ items: testItems,
47
+ selectedResult: testItems[selectedResultIndex],
48
+ });
49
+ });
50
+ });
51
+
52
+ /**
53
+ * Test case for filterKeys
54
+ */
55
+ it("should support setting filterKeys", () => filterkeysTest(filterKeys));
56
+ });
@@ -11,6 +11,7 @@ import {
11
11
  spatialFilterTest,
12
12
  externalFilterTest,
13
13
  nestedPropertyTest,
14
+ subtitleTest,
14
15
  } from "./cases/general/";
15
16
 
16
17
  /**
@@ -29,6 +30,7 @@ describe("Item Filter Config", () => {
29
30
  Object.assign(eoxItemFilter, {
30
31
  config: {
31
32
  titleProperty: "title",
33
+ subTitleProperty: "description",
32
34
  filterProperties: [
33
35
  {
34
36
  keys: ["title", "themes"],
@@ -92,4 +94,9 @@ describe("Item Filter Config", () => {
92
94
  * Test case to check whether nested properties work or not
93
95
  */
94
96
  it("should run with nested property", () => nestedPropertyTest());
97
+
98
+ /**
99
+ * Test case to check if subtitles are rendered correctly
100
+ */
101
+ it.only("should render subtitles", () => subtitleTest());
95
102
  });
package/test/state.cy.js CHANGED
@@ -33,6 +33,7 @@ describe("Item Filter Config", () => {
33
33
  const eoxItemFilter = $el[0];
34
34
  Object.assign(eoxItemFilter, {
35
35
  config: {
36
+ idProperty: "title",
36
37
  titleProperty: "title",
37
38
  filterProperties: [
38
39
  {