@eox/itemfilter 0.14.1 → 0.14.2-dev.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-itemfilter.js +8521 -6809
- package/dist/eox-itemfilter.umd.cjs +613 -804
- package/package.json +6 -3
- package/test/cases/general/accordion.js +60 -0
- package/test/cases/general/disable-highlight.js +21 -0
- package/test/cases/general/external-filter.js +38 -0
- package/test/cases/general/highlight-result.js +16 -0
- package/test/cases/general/index.js +10 -0
- package/test/cases/general/multiple-filters.js +21 -0
- package/test/cases/general/search-bar.js +12 -0
- package/test/cases/general/search-result.js +14 -0
- package/test/cases/general/spatial-filter.js +22 -0
- package/test/cases/state/custom-order.js +24 -0
- package/test/cases/state/index.js +6 -0
- package/test/cases/state/render-checkbox.js +17 -0
- package/test/cases/state/result-pre-checked.js +20 -0
- package/test/cases/state/results-with-pre-set-filters.js +30 -0
- package/test/general.cy.js +89 -0
- package/test/state.cy.js +75 -0
- package/test/testItems.json +40 -20
- package/test/general.cy.ts +0 -230
- package/test/state.cy.ts +0 -100
package/test/testItems.json
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
[-90.0, 82.0]
|
|
24
24
|
]
|
|
25
25
|
]
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"tags": ["agriculture", "Sentinel-2", "asparagus"]
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
30
|
"archived": false,
|
|
@@ -49,7 +50,8 @@
|
|
|
49
50
|
[0, 10]
|
|
50
51
|
]
|
|
51
52
|
]
|
|
52
|
-
}
|
|
53
|
+
},
|
|
54
|
+
"tags": ["agriculture", "workers", "availability"]
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
"archived": false,
|
|
@@ -75,7 +77,8 @@
|
|
|
75
77
|
[-180.0, -61.0]
|
|
76
78
|
]
|
|
77
79
|
]
|
|
78
|
-
}
|
|
80
|
+
},
|
|
81
|
+
"tags": ["air quality", "sea ice", "freeboard"]
|
|
79
82
|
},
|
|
80
83
|
{
|
|
81
84
|
"archived": false,
|
|
@@ -89,7 +92,8 @@
|
|
|
89
92
|
"likes": 177,
|
|
90
93
|
"years": [2021, 2022],
|
|
91
94
|
"timestamp": "2023-06-11T13:56:38+00:00",
|
|
92
|
-
"datetime": ["2023-06-11T10:56:38+00:00", "2023-06-11T22:56:38+00:00"]
|
|
95
|
+
"datetime": ["2023-06-11T10:56:38+00:00", "2023-06-11T22:56:38+00:00"],
|
|
96
|
+
"tags": ["economy", "vessel density", "average"]
|
|
93
97
|
},
|
|
94
98
|
{
|
|
95
99
|
"archived": false,
|
|
@@ -103,7 +107,8 @@
|
|
|
103
107
|
"likes": 0,
|
|
104
108
|
"years": [2005, 2016],
|
|
105
109
|
"timestamp": "2023-06-10T13:56:38+00:00",
|
|
106
|
-
"datetime": ["2023-06-10T10:56:38+00:00", "2023-06-10T22:56:38+00:00"]
|
|
110
|
+
"datetime": ["2023-06-10T10:56:38+00:00", "2023-06-10T22:56:38+00:00"],
|
|
111
|
+
"tags": ["economy", "vessel density", "cargo"]
|
|
107
112
|
},
|
|
108
113
|
{
|
|
109
114
|
"archived": false,
|
|
@@ -117,7 +122,8 @@
|
|
|
117
122
|
"likes": 0,
|
|
118
123
|
"years": [2006, 2017],
|
|
119
124
|
"timestamp": "2023-06-09T13:56:38+00:00",
|
|
120
|
-
"datetime": ["2023-06-09T10:56:38+00:00", "2023-06-09T22:56:38+00:00"]
|
|
125
|
+
"datetime": ["2023-06-09T10:56:38+00:00", "2023-06-09T22:56:38+00:00"],
|
|
126
|
+
"tags": ["economy", "vessel density", "tanker"]
|
|
121
127
|
},
|
|
122
128
|
{
|
|
123
129
|
"archived": false,
|
|
@@ -131,7 +137,8 @@
|
|
|
131
137
|
"likes": 2,
|
|
132
138
|
"years": [2001, 2003],
|
|
133
139
|
"timestamp": "2023-06-08T13:56:38+00:00",
|
|
134
|
-
"datetime": ["2023-06-08T10:56:38+00:00", "2023-06-08T22:56:38+00:00"]
|
|
140
|
+
"datetime": ["2023-06-08T10:56:38+00:00", "2023-06-08T22:56:38+00:00"],
|
|
141
|
+
"tags": ["economy", "vessel density", "others"]
|
|
135
142
|
},
|
|
136
143
|
{
|
|
137
144
|
"archived": false,
|
|
@@ -146,7 +153,8 @@
|
|
|
146
153
|
"likes": 65,
|
|
147
154
|
"years": [2015, 2020],
|
|
148
155
|
"timestamp": "2023-06-07T13:56:38+00:00",
|
|
149
|
-
"datetime": ["2023-06-07T10:56:38+00:00", "2023-06-07T22:56:38+00:00"]
|
|
156
|
+
"datetime": ["2023-06-07T10:56:38+00:00", "2023-06-07T22:56:38+00:00"],
|
|
157
|
+
"tags": ["economy", "air", "NO2", "boat traffic"]
|
|
150
158
|
},
|
|
151
159
|
{
|
|
152
160
|
"archived": false,
|
|
@@ -160,7 +168,8 @@
|
|
|
160
168
|
"likes": 34,
|
|
161
169
|
"years": [2021, 2021],
|
|
162
170
|
"timestamp": "2023-06-06T13:56:38+00:00",
|
|
163
|
-
"datetime": ["2023-06-06T10:56:38+00:00", "2023-06-06T22:56:38+00:00"]
|
|
171
|
+
"datetime": ["2023-06-06T10:56:38+00:00", "2023-06-06T22:56:38+00:00"],
|
|
172
|
+
"tags": ["air", "temperature", "C3S Data"]
|
|
164
173
|
},
|
|
165
174
|
{
|
|
166
175
|
"archived": false,
|
|
@@ -174,7 +183,8 @@
|
|
|
174
183
|
"likes": 88,
|
|
175
184
|
"years": [2000, 2023],
|
|
176
185
|
"timestamp": "2023-06-05T13:56:38+00:00",
|
|
177
|
-
"datetime": ["2023-06-05T10:56:38+00:00", "2023-06-05T22:56:38+00:00"]
|
|
186
|
+
"datetime": ["2023-06-05T10:56:38+00:00", "2023-06-05T22:56:38+00:00"],
|
|
187
|
+
"tags": ["air", "PM2.5", "city level"]
|
|
178
188
|
},
|
|
179
189
|
{
|
|
180
190
|
"archived": false,
|
|
@@ -188,7 +198,8 @@
|
|
|
188
198
|
"likes": 77,
|
|
189
199
|
"years": [2019, 2022],
|
|
190
200
|
"timestamp": "2023-06-04T13:56:38+00:00",
|
|
191
|
-
"datetime": ["2023-06-04T10:56:38+00:00", "2023-06-04T22:56:38+00:00"]
|
|
201
|
+
"datetime": ["2023-06-04T10:56:38+00:00", "2023-06-04T22:56:38+00:00"],
|
|
202
|
+
"tags": ["air", "NO2", "city level"]
|
|
192
203
|
},
|
|
193
204
|
{
|
|
194
205
|
"archived": false,
|
|
@@ -202,7 +213,8 @@
|
|
|
202
213
|
"likes": 23,
|
|
203
214
|
"years": [2014, 2018],
|
|
204
215
|
"timestamp": "2023-06-03T13:56:38+00:00",
|
|
205
|
-
"datetime": ["2023-06-03T10:56:38+00:00", "2023-06-03T22:56:38+00:00"]
|
|
216
|
+
"datetime": ["2023-06-03T10:56:38+00:00", "2023-06-03T22:56:38+00:00"],
|
|
217
|
+
"tags": ["air", "PM10", "city level"]
|
|
206
218
|
},
|
|
207
219
|
{
|
|
208
220
|
"archived": false,
|
|
@@ -216,7 +228,8 @@
|
|
|
216
228
|
"likes": 56,
|
|
217
229
|
"years": [2017, 2018],
|
|
218
230
|
"timestamp": "2023-06-02T13:56:38+00:00",
|
|
219
|
-
"datetime": ["2023-06-02T10:56:38+00:00", "2023-06-02T22:56:38+00:00"]
|
|
231
|
+
"datetime": ["2023-06-02T10:56:38+00:00", "2023-06-02T22:56:38+00:00"],
|
|
232
|
+
"tags": ["air", "O3", "city level"]
|
|
220
233
|
},
|
|
221
234
|
{
|
|
222
235
|
"archived": false,
|
|
@@ -230,7 +243,8 @@
|
|
|
230
243
|
"likes": 11,
|
|
231
244
|
"years": [2018, 2019],
|
|
232
245
|
"timestamp": "2023-06-01T13:56:38+00:00",
|
|
233
|
-
"datetime": ["2023-06-01T10:56:38+00:00", "2023-06-01T22:56:38+00:00"]
|
|
246
|
+
"datetime": ["2023-06-01T10:56:38+00:00", "2023-06-01T22:56:38+00:00"],
|
|
247
|
+
"tags": ["economy", "cargo ships", "AIS data"]
|
|
234
248
|
},
|
|
235
249
|
{
|
|
236
250
|
"archived": false,
|
|
@@ -244,7 +258,8 @@
|
|
|
244
258
|
"likes": 8,
|
|
245
259
|
"years": [2015, 2017],
|
|
246
260
|
"timestamp": "2023-05-29T13:56:38+00:00",
|
|
247
|
-
"datetime": ["2023-05-29T10:56:38+00:00", "2023-05-29T22:56:38+00:00"]
|
|
261
|
+
"datetime": ["2023-05-29T10:56:38+00:00", "2023-05-29T22:56:38+00:00"],
|
|
262
|
+
"tags": ["economy", "traffic", "mobile data"]
|
|
248
263
|
},
|
|
249
264
|
{
|
|
250
265
|
"archived": false,
|
|
@@ -258,7 +273,8 @@
|
|
|
258
273
|
"likes": 37,
|
|
259
274
|
"years": [2014, 2015],
|
|
260
275
|
"timestamp": "2023-05-28T13:56:38+00:00",
|
|
261
|
-
"datetime": ["2023-05-28T10:56:38+00:00", "2023-05-28T22:56:38+00:00"]
|
|
276
|
+
"datetime": ["2023-05-28T10:56:38+00:00", "2023-05-28T22:56:38+00:00"],
|
|
277
|
+
"tags": ["water", "CHL-a", "concentration"]
|
|
262
278
|
},
|
|
263
279
|
{
|
|
264
280
|
"archived": false,
|
|
@@ -272,7 +288,8 @@
|
|
|
272
288
|
"likes": 4,
|
|
273
289
|
"years": [2001, 2013],
|
|
274
290
|
"timestamp": "2023-05-27T13:56:38+00:00",
|
|
275
|
-
"datetime": ["2023-05-27T10:56:38+00:00", "2023-05-27T22:56:38+00:00"]
|
|
291
|
+
"datetime": ["2023-05-27T10:56:38+00:00", "2023-05-27T22:56:38+00:00"],
|
|
292
|
+
"tags": ["health", "Covid-19", "cases"]
|
|
276
293
|
},
|
|
277
294
|
{
|
|
278
295
|
"archived": false,
|
|
@@ -286,7 +303,8 @@
|
|
|
286
303
|
"likes": 39,
|
|
287
304
|
"years": [2015, 2016],
|
|
288
305
|
"timestamp": "2023-05-26T13:56:38+00:00",
|
|
289
|
-
"datetime": ["2023-05-26T10:56:38+00:00", "2023-05-26T22:56:38+00:00"]
|
|
306
|
+
"datetime": ["2023-05-26T10:56:38+00:00", "2023-05-26T22:56:38+00:00"],
|
|
307
|
+
"tags": ["health", "Covid-19", "vaccinations"]
|
|
290
308
|
},
|
|
291
309
|
{
|
|
292
310
|
"archived": false,
|
|
@@ -300,7 +318,8 @@
|
|
|
300
318
|
"likes": 28,
|
|
301
319
|
"years": [2014, 2020],
|
|
302
320
|
"timestamp": "2023-05-25T13:56:38+00:00",
|
|
303
|
-
"datetime": ["2023-05-25T10:56:38+00:00", "2023-05-25T22:56:38+00:00"]
|
|
321
|
+
"datetime": ["2023-05-25T10:56:38+00:00", "2023-05-25T22:56:38+00:00"],
|
|
322
|
+
"tags": ["economy", "crude oil", "input materials"]
|
|
304
323
|
},
|
|
305
324
|
{
|
|
306
325
|
"archived": false,
|
|
@@ -314,6 +333,7 @@
|
|
|
314
333
|
"likes": 17,
|
|
315
334
|
"years": [1998, 1999],
|
|
316
335
|
"timestamp": "2023-05-24T13:56:38+00:00",
|
|
317
|
-
"datetime": ["2023-05-24T10:56:38+00:00", "2023-05-24T22:56:38+00:00"]
|
|
336
|
+
"datetime": ["2023-05-24T10:56:38+00:00", "2023-05-24T22:56:38+00:00"],
|
|
337
|
+
"tags": ["economy", "cruise ships", "AIS data"]
|
|
318
338
|
}
|
|
319
339
|
]
|
package/test/general.cy.ts
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import "../src/main";
|
|
2
|
-
import "./_mockMap";
|
|
3
|
-
import testItems from "./testItems.json";
|
|
4
|
-
|
|
5
|
-
describe("Item Filter Config", () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
cy.mount(
|
|
8
|
-
`<eox-itemfilter>
|
|
9
|
-
<h4 slot="filterstitle">Filter</h4>
|
|
10
|
-
<h4 slot="resultstitle">Results</h4>
|
|
11
|
-
</eox-itemfilter>`
|
|
12
|
-
)
|
|
13
|
-
.as("eox-itemfilter")
|
|
14
|
-
.then(($el) => {
|
|
15
|
-
const eoxItemFilter = <EOxItemFilter>$el[0];
|
|
16
|
-
Object.assign(eoxItemFilter, {
|
|
17
|
-
config: {
|
|
18
|
-
titleProperty: "title",
|
|
19
|
-
filterProperties: [
|
|
20
|
-
{
|
|
21
|
-
keys: ["title", "themes"],
|
|
22
|
-
title: "Search",
|
|
23
|
-
type: "text",
|
|
24
|
-
expanded: true,
|
|
25
|
-
},
|
|
26
|
-
{ key: "themes", expanded: true },
|
|
27
|
-
],
|
|
28
|
-
aggregateResults: "themes",
|
|
29
|
-
enableHighlighting: true,
|
|
30
|
-
},
|
|
31
|
-
items: testItems,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("should have a search bar", () => {
|
|
37
|
-
cy.get("eox-itemfilter")
|
|
38
|
-
.shadow()
|
|
39
|
-
.within(() => {
|
|
40
|
-
cy.get("[data-cy='search']").should("exist");
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should filter results based on search string", () => {
|
|
45
|
-
cy.get("eox-itemfilter")
|
|
46
|
-
.shadow()
|
|
47
|
-
.within(() => {
|
|
48
|
-
cy.get("[data-cy='search']").type("white");
|
|
49
|
-
cy.get("ul#results").children();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should highlight results", () => {
|
|
54
|
-
cy.get("eox-itemfilter")
|
|
55
|
-
.shadow()
|
|
56
|
-
.within(() => {
|
|
57
|
-
cy.get("[data-cy='search']").type("white");
|
|
58
|
-
cy.get("mark.highlight").contains("White");
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should disable highlight", () => {
|
|
63
|
-
cy.get("eox-itemfilter").should(($el) => {
|
|
64
|
-
(<EOxItemFilter>$el[0]).config.enableHighlighting = false;
|
|
65
|
-
});
|
|
66
|
-
cy.get("eox-itemfilter")
|
|
67
|
-
.shadow()
|
|
68
|
-
.within(() => {
|
|
69
|
-
cy.get("[data-cy='search']").type("white");
|
|
70
|
-
cy.get("mark.highlight").should("not.exist");
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// it("should not have a search bar", () => {
|
|
75
|
-
// cy.get("eox-itemfilter").should(($el) => {
|
|
76
|
-
// (<EOxItemFilter>$el[0]).config = {
|
|
77
|
-
// titleProperty: "title",
|
|
78
|
-
// filterProperties: [{ key: "themes", type: "multiselect", title: "foobar" }],
|
|
79
|
-
// };
|
|
80
|
-
// EOxItemFilter.apply(testItems);
|
|
81
|
-
// });
|
|
82
|
-
// cy.get("eox-itemfilter")
|
|
83
|
-
// .shadow()
|
|
84
|
-
// .find("input[type='text']")
|
|
85
|
-
// .should("not.exist");
|
|
86
|
-
// });
|
|
87
|
-
|
|
88
|
-
it("should allow multiple filters", () => {
|
|
89
|
-
cy.get("eox-itemfilter")
|
|
90
|
-
.shadow()
|
|
91
|
-
.within(() => {
|
|
92
|
-
cy.get("eox-selectionlist").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
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// it("should allow only one filter", () => {
|
|
104
|
-
// cy.get("eox-itemfilter").should(($el) => {
|
|
105
|
-
// const EOxItemFilter = <EOxItemFilter>$el[0];
|
|
106
|
-
// // have to replace the entire config, otherwise exclusiveFilters = true doesn't work
|
|
107
|
-
// EOxItemFilter.config = {
|
|
108
|
-
// titleProperty: "title",
|
|
109
|
-
// filterProperties: [{ key: "themes", exclusive: true }],
|
|
110
|
-
// aggregateResults: "themes",
|
|
111
|
-
// enableHighlighting: true,
|
|
112
|
-
// };
|
|
113
|
-
// EOxItemFilter.apply(testItems);
|
|
114
|
-
// });
|
|
115
|
-
// cy.get("eox-itemfilter")
|
|
116
|
-
// .shadow()
|
|
117
|
-
// .within(() => {
|
|
118
|
-
// cy.get(".details-filter").click();
|
|
119
|
-
// cy.get('[type="radio"]').first().check();
|
|
120
|
-
// cy.get('[type="radio"]').eq(1).check();
|
|
121
|
-
// cy.get('[type="radio"]').first().should("not.be.checked");
|
|
122
|
-
// });
|
|
123
|
-
// });
|
|
124
|
-
|
|
125
|
-
// it("should clear all filters", () => {
|
|
126
|
-
// cy.get("eox-itemfilter")
|
|
127
|
-
// .shadow()
|
|
128
|
-
// .within(() => {
|
|
129
|
-
// cy.get("[data-cy='search']").type("city");
|
|
130
|
-
// cy.get(".details-filter").click()
|
|
131
|
-
// .find('[type="checkbox"]')
|
|
132
|
-
// .then(($value) => {
|
|
133
|
-
// [...Array($value.length)].map((_, i) => {
|
|
134
|
-
// cy.get('[type="checkbox"]').eq(i).check();
|
|
135
|
-
// });
|
|
136
|
-
// });
|
|
137
|
-
// cy.get("[data-cy='filter-reset']").click();
|
|
138
|
-
// cy.get("[data-cy='search']").should("have.value", "");
|
|
139
|
-
// cy.get(".details-filter")
|
|
140
|
-
// .find('[type="checkbox"]')
|
|
141
|
-
// .then(($value) => {
|
|
142
|
-
// [...Array($value.length)].map((_, i) => {
|
|
143
|
-
// cy.get('[type="checkbox"]').eq(i).should("not.be.checked");
|
|
144
|
-
// });
|
|
145
|
-
// });
|
|
146
|
-
// });
|
|
147
|
-
// });
|
|
148
|
-
|
|
149
|
-
it("should allow only one accordion of each type to be open at a time if configured", () => {
|
|
150
|
-
cy.get("eox-itemfilter").then(($el) => {
|
|
151
|
-
(<EOxItemFilter>$el[0]).config.expandMultipleFilters = false;
|
|
152
|
-
(<EOxItemFilter>$el[0]).config.expandMultipleResults = false;
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const checkExclusiveOpen = (selector: string, isSubcomponent = false) => {
|
|
156
|
-
cy.get("eox-itemfilter")
|
|
157
|
-
.shadow()
|
|
158
|
-
.within(() => {
|
|
159
|
-
cy.get(selector).then((accordions) => {
|
|
160
|
-
for (let i = 0; i < accordions.length; i++) {
|
|
161
|
-
const accordionToClick = isSubcomponent
|
|
162
|
-
? cy
|
|
163
|
-
.get(selector)
|
|
164
|
-
.eq(i)
|
|
165
|
-
.find("eox-itemfilter-expandcontainer")
|
|
166
|
-
.shadow()
|
|
167
|
-
.find("details")
|
|
168
|
-
: cy.get(selector).eq(i).find("details");
|
|
169
|
-
|
|
170
|
-
accordionToClick.click({ multiple: true, force: true });
|
|
171
|
-
accordionToClick.should("have.attr", "open");
|
|
172
|
-
|
|
173
|
-
// Check that all other accordions are closed
|
|
174
|
-
for (let j = 0; j < accordions.length; j++) {
|
|
175
|
-
if (i !== j) {
|
|
176
|
-
const accordionToCheck = isSubcomponent
|
|
177
|
-
? cy
|
|
178
|
-
.get(selector)
|
|
179
|
-
.eq(j)
|
|
180
|
-
.find("eox-itemfilter-expandcontainer")
|
|
181
|
-
.shadow()
|
|
182
|
-
.find("details")
|
|
183
|
-
: cy.get(selector).eq(j).find("details");
|
|
184
|
-
|
|
185
|
-
accordionToCheck.should("not.have.attr", "open");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
checkExclusiveOpen("ul#filters", true);
|
|
194
|
-
checkExclusiveOpen("ul#results");
|
|
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
|
-
Object.assign(eoxItemFilter, {
|
|
201
|
-
config: {
|
|
202
|
-
titleProperty: "title",
|
|
203
|
-
filterProperties: [
|
|
204
|
-
{
|
|
205
|
-
key: "geometry",
|
|
206
|
-
type: "spatial",
|
|
207
|
-
expanded: true,
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
items: testItems,
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
cy.get("eox-itemfilter")
|
|
215
|
-
.shadow()
|
|
216
|
-
.within(() => {
|
|
217
|
-
cy.get("eox-itemfilter-spatial")
|
|
218
|
-
.get("eox-itemfilter-spatial-filter")
|
|
219
|
-
.shadow()
|
|
220
|
-
.within(() => {
|
|
221
|
-
cy.get("eox-map").should("exist");
|
|
222
|
-
cy.get("eox-map")
|
|
223
|
-
.shadow()
|
|
224
|
-
.within(() => {
|
|
225
|
-
cy.get("canvas").should("exist");
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
package/test/state.cy.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import "../src/main";
|
|
2
|
-
import testItems from "./testItems.json";
|
|
3
|
-
|
|
4
|
-
describe("Item Filter Config", () => {
|
|
5
|
-
const state = {
|
|
6
|
-
agriculture: true,
|
|
7
|
-
health: true,
|
|
8
|
-
};
|
|
9
|
-
const customOrder = {
|
|
10
|
-
health: 0,
|
|
11
|
-
water: 1,
|
|
12
|
-
air: 2,
|
|
13
|
-
economy: 3,
|
|
14
|
-
agriculture: 4,
|
|
15
|
-
} as { [key: string]: number };
|
|
16
|
-
const selectedResultIndex = 1;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
cy.mount(`<eox-itemfilter></eox-itemfilter>`)
|
|
19
|
-
.as("eox-itemfilter")
|
|
20
|
-
.then(($el) => {
|
|
21
|
-
const eoxItemFilter = <EOxItemFilter>$el[0];
|
|
22
|
-
Object.assign(eoxItemFilter, {
|
|
23
|
-
config: {
|
|
24
|
-
titleProperty: "title",
|
|
25
|
-
filterProperties: [
|
|
26
|
-
{
|
|
27
|
-
key: "themes",
|
|
28
|
-
type: "multiselect",
|
|
29
|
-
expanded: true,
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
sort: (a, b) => customOrder[a] - customOrder[b],
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
state,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
aggregateResults: "themes",
|
|
37
|
-
},
|
|
38
|
-
items: testItems,
|
|
39
|
-
selectedResult: testItems[selectedResultIndex],
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should render the checkboxes as checked", () => {
|
|
45
|
-
cy.get("eox-itemfilter")
|
|
46
|
-
.shadow()
|
|
47
|
-
.within(() => {
|
|
48
|
-
cy.get("eox-selectionlist").within(() => {
|
|
49
|
-
cy.get('[type="checkbox"]:checked').should("have.length", 2);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should only show the results of the pre-set filters", () => {
|
|
55
|
-
cy.get("eox-itemfilter")
|
|
56
|
-
.shadow()
|
|
57
|
-
.within(() => {
|
|
58
|
-
Object.keys(state).forEach((key) => {
|
|
59
|
-
cy.get(".details-results > summary > .title").should(
|
|
60
|
-
"contain.text",
|
|
61
|
-
key
|
|
62
|
-
);
|
|
63
|
-
cy.get(".details-results > summary > .title").should(
|
|
64
|
-
"contain.text",
|
|
65
|
-
key
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
cy.get(".details-results > summary > .title").should(
|
|
69
|
-
"have.length",
|
|
70
|
-
Object.keys(state).length
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should render the pre-set result as checked", () => {
|
|
76
|
-
cy.get("eox-itemfilter")
|
|
77
|
-
.shadow()
|
|
78
|
-
.within(() => {
|
|
79
|
-
cy.get("input[data-cy=result-radio]")
|
|
80
|
-
.eq(selectedResultIndex)
|
|
81
|
-
.should("be.checked");
|
|
82
|
-
cy.get("input[data-cy=result-radio][checked]").should("have.length", 1);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should have a custom order", () => {
|
|
87
|
-
cy.get("eox-itemfilter")
|
|
88
|
-
.shadow()
|
|
89
|
-
.within(() => {
|
|
90
|
-
cy.get("eox-itemfilter-multiselect > eox-selectionlist").within(() => {
|
|
91
|
-
Object.keys(customOrder).forEach((state) => {
|
|
92
|
-
cy.get("ul [data-identifier]")
|
|
93
|
-
.eq(customOrder[state])
|
|
94
|
-
.invoke("attr", "data-identifier")
|
|
95
|
-
.should("eq", state);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|