@eeacms/volto-globalsearch 1.0.19 → 1.0.21
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/.eslintignore +1 -0
- package/.husky/pre-commit +2 -0
- package/CHANGELOG.md +43 -9
- package/DEVELOP.md +60 -6
- package/README.md +18 -2
- package/cypress.config.js +2 -2
- package/docker-compose.yml +32 -0
- package/jest-addon.config.js +2 -0
- package/locales/de/LC_MESSAGES/volto.po +14 -0
- package/locales/en/LC_MESSAGES/volto.po +14 -0
- package/locales/it/LC_MESSAGES/volto.po +14 -0
- package/locales/ro/LC_MESSAGES/volto.po +14 -0
- package/locales/volto.pot +16 -0
- package/package.json +26 -2
- package/src/components/MasonryLandingPage.test.jsx +99 -0
- package/src/config/facets.js +1 -1
- package/src/config/filters.js +26 -22
- package/src/config/global-search-config.js +20 -0
- package/src/config/healthcheck.js +315 -10
- package/src/config/healthcheck.test.js +300 -0
- package/src/config/healthcheck_queries/empty_resp.json +18 -0
- package/src/config/healthcheck_queries/failed_scheduled_atempts_since_last_started.json +36 -0
- package/src/config/healthcheck_queries/failed_scheduled_atempts_since_last_started_resp.json +41 -0
- package/src/config/healthcheck_queries/failed_site_since_last_started.json +31 -0
- package/src/config/healthcheck_queries/last_scheduled_indexing.json +28 -0
- package/src/config/healthcheck_queries/last_scheduled_started_indexing.json +29 -0
- package/src/config/healthcheck_queries/last_scheduled_started_indexing_resp.json +41 -0
- package/src/config/healthcheck_queries/last_sync_task_since_last_start.json +36 -0
- package/src/config/healthcheck_queries/last_sync_task_since_last_start_resp.json +63 -0
- package/src/config/healthcheck_queries/latest_tasks_for_site.json +23 -0
- package/src/config/healthcheck_queries/latest_tasks_for_site_resp.json +70 -0
- package/src/config/healthcheck_queries/started_or_finished_site_since_last_started.json +35 -0
- package/src/config/healthcheck_queries/started_or_finished_site_since_last_started_resp.json +36 -0
- package/src/config/index.test.js +191 -0
- package/src/utils.test.js +435 -0
- package/.i18n.babel.config.js +0 -1
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import {
|
|
2
|
+
build_runtime_mappings,
|
|
3
|
+
getTodayWithTime,
|
|
4
|
+
getGlobalsearchIconUrl,
|
|
5
|
+
getGlobalsearchThumbUrl,
|
|
6
|
+
get_cluster_icons,
|
|
7
|
+
get_cluster_icons_dict,
|
|
8
|
+
} from './utils';
|
|
9
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
10
|
+
|
|
11
|
+
describe('build_runtime_mappings', () => {
|
|
12
|
+
it('should build runtime mappings based on settings', () => {
|
|
13
|
+
const settings = {
|
|
14
|
+
clusters: [
|
|
15
|
+
{ name: 'cluster1', values: ['value1', 'value2'] },
|
|
16
|
+
{ name: 'cluster2', values: ['value3', 'value4'] },
|
|
17
|
+
],
|
|
18
|
+
field: 'fieldName',
|
|
19
|
+
name: 'mappingName',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const expectedMappings = {
|
|
23
|
+
mappingName: {
|
|
24
|
+
type: 'keyword',
|
|
25
|
+
script: {
|
|
26
|
+
source:
|
|
27
|
+
'emit("_all_"); def clusters_settings = [["name": "cluster1", "values": ["value1","value2"]],["name": "cluster2", "values": ["value3","value4"]]]; def vals = doc[\'fieldName\']; def clusters = [\'All\']; for (val in vals) { for (cs in clusters_settings) { if (cs.values.contains(val)) { emit(cs.name) } } }',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mappings = build_runtime_mappings(settings);
|
|
33
|
+
|
|
34
|
+
expect(mappings).toEqual(expectedMappings);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('getTodayWithTime', () => {
|
|
39
|
+
it('should return the current date in UTC format', () => {
|
|
40
|
+
// The output will vary depending on the current date and time,
|
|
41
|
+
// so we can't hardcode the expected value. We will only test
|
|
42
|
+
// if the function returns a string in a valid UTC format.
|
|
43
|
+
const output = getTodayWithTime();
|
|
44
|
+
|
|
45
|
+
expect(typeof output).toBe('string');
|
|
46
|
+
expect(output).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('getGlobalsearchIconUrl', () => {
|
|
51
|
+
const contentTypeNormalize = {
|
|
52
|
+
content_type_1: 'icon_type_1',
|
|
53
|
+
content_type_2: 'icon_type_2',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
it('should return the default fallback image when no match is found', () => {
|
|
57
|
+
const result = {
|
|
58
|
+
about: { raw: 'some_non_matching_url' },
|
|
59
|
+
objectProvides: { raw: 'Non-matching Content Type' },
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const config = null;
|
|
63
|
+
const fallback =
|
|
64
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_thumb';
|
|
65
|
+
|
|
66
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
67
|
+
result,
|
|
68
|
+
config,
|
|
69
|
+
fallback,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(imageUrl).toBe(fallback);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should return the glossary term icon for matching about.raw URLs', () => {
|
|
76
|
+
const result = {
|
|
77
|
+
about: { raw: 'http://www.eea.europa.eu/help/glossary/some_term' },
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const config = null;
|
|
81
|
+
const fallback = 'fallback_image_url';
|
|
82
|
+
|
|
83
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
84
|
+
result,
|
|
85
|
+
config,
|
|
86
|
+
fallback,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(imageUrl).toBe(
|
|
90
|
+
'https://www.eea.europa.eu/portal_depiction/term/image_thumb',
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should return the content_type_1 e icon for matching objectProvides.raw', () => {
|
|
95
|
+
const result = {
|
|
96
|
+
about: { raw: 'some_non_matching_url' },
|
|
97
|
+
objectProvides: { raw: 'content_type_1' },
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const config = null;
|
|
101
|
+
const fallback = 'fallback_image_url';
|
|
102
|
+
|
|
103
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
104
|
+
result,
|
|
105
|
+
config,
|
|
106
|
+
fallback,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(imageUrl).toBe(
|
|
110
|
+
'https://www.eea.europa.eu/portal_depiction/icon_type_1/image_thumb',
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should return the country profile icon for matching objectProvides.raw', () => {
|
|
115
|
+
const result = {
|
|
116
|
+
about: { raw: 'some_non_matching_url' },
|
|
117
|
+
objectProvides: { raw: 'Country profile' },
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const config = null;
|
|
121
|
+
const fallback = 'fallback_image_url';
|
|
122
|
+
|
|
123
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
124
|
+
result,
|
|
125
|
+
config,
|
|
126
|
+
fallback,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(imageUrl).toBe(
|
|
130
|
+
'https://www.eea.europa.eu/portal_depiction/country-profile/image_thumb',
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should return the generic if no content_type matches the ones in contentTypeNormalize', () => {
|
|
135
|
+
const result = {
|
|
136
|
+
about: { raw: 'some_non_matching_url' },
|
|
137
|
+
objectProvides: { raw: ['content_type_3', 'content_type_4'] },
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const config = null;
|
|
141
|
+
const fallback = 'fallback_image_url';
|
|
142
|
+
|
|
143
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
144
|
+
result,
|
|
145
|
+
config,
|
|
146
|
+
fallback,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
expect(imageUrl).toBe(
|
|
150
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_thumb',
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should return the generic if objectProvides.raw is empty', () => {
|
|
155
|
+
const result = {
|
|
156
|
+
about: { raw: 'some_non_matching_url' },
|
|
157
|
+
objectProvides: { raw: [] },
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const config = null;
|
|
161
|
+
const fallback = 'fallback_image_url';
|
|
162
|
+
|
|
163
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
164
|
+
result,
|
|
165
|
+
config,
|
|
166
|
+
fallback,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
expect(imageUrl).toBe(
|
|
170
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_thumb',
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should return the data icon for matching about.raw URL containing land.copernicus.eu', () => {
|
|
175
|
+
const result = {
|
|
176
|
+
about: { raw: 'https://land.copernicus.eu/some_data' },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const config = null;
|
|
180
|
+
const fallback = 'fallback_image_url';
|
|
181
|
+
|
|
182
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
183
|
+
result,
|
|
184
|
+
config,
|
|
185
|
+
fallback,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(imageUrl).toBe(
|
|
189
|
+
'https://www.eea.europa.eu/portal_depiction/data/image_thumb',
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should return the image_preview URL from result if specific conditions are met', () => {
|
|
194
|
+
const result = {
|
|
195
|
+
site_id: { raw: 'sdi' },
|
|
196
|
+
'overview.url': { raw: 'some_overview_url' },
|
|
197
|
+
about: { raw: 'some_non_matching_url' },
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const config = null;
|
|
201
|
+
const fallback = 'fallback_image_url';
|
|
202
|
+
|
|
203
|
+
const imageUrl = getGlobalsearchIconUrl(contentTypeNormalize)(
|
|
204
|
+
result,
|
|
205
|
+
config,
|
|
206
|
+
fallback,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
expect(imageUrl).toBe('fallback_image_url');
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('getGlobalsearchThumbUrl', () => {
|
|
214
|
+
const contentTypeNormalize = {
|
|
215
|
+
content_type_1: 'icon_type_1',
|
|
216
|
+
content_type_2: 'icon_type_2',
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
it('should return the default fallback image when no match is found', () => {
|
|
220
|
+
const result = {
|
|
221
|
+
about: { raw: 'some_non_matching_url' },
|
|
222
|
+
objectProvides: { raw: 'Non-matching Content Type' },
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const config = null;
|
|
226
|
+
const fallback =
|
|
227
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_preview';
|
|
228
|
+
|
|
229
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
230
|
+
result,
|
|
231
|
+
config,
|
|
232
|
+
fallback,
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
expect(imageUrl).toBe(fallback);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should return the glossary term preview image for matching about.raw URLs', () => {
|
|
239
|
+
const result = {
|
|
240
|
+
about: { raw: 'http://www.eea.europa.eu/help/glossary/some_term' },
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const config = null;
|
|
244
|
+
const fallback =
|
|
245
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_preview';
|
|
246
|
+
|
|
247
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
248
|
+
result,
|
|
249
|
+
config,
|
|
250
|
+
fallback,
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
expect(imageUrl).toBe(
|
|
254
|
+
'http://www.eea.europa.eu/help/glossary/some_term/image_preview',
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('should return the objectProvides.raw icon for matching objectProvides.raw', () => {
|
|
259
|
+
const result = {
|
|
260
|
+
about: { raw: 'some_non_matching_url' },
|
|
261
|
+
objectProvides: { raw: 'content_type_1' },
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const config = null;
|
|
265
|
+
const fallback =
|
|
266
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_preview';
|
|
267
|
+
|
|
268
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
269
|
+
result,
|
|
270
|
+
config,
|
|
271
|
+
fallback,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
expect(imageUrl).toBe(
|
|
275
|
+
'https://www.eea.europa.eu/portal_depiction/icon_type_1/image_preview',
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('should return the generic for not matching objectProvides.raw', () => {
|
|
280
|
+
const result = {
|
|
281
|
+
about: { raw: 'some_non_matching_url' },
|
|
282
|
+
objectProvides: { raw: ['content_type_3', 'content_type_4'] },
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const config = null;
|
|
286
|
+
const fallback =
|
|
287
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_preview';
|
|
288
|
+
|
|
289
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
290
|
+
result,
|
|
291
|
+
config,
|
|
292
|
+
fallback,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
expect(imageUrl).toBe(fallback);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should return generic for empty objectProvides.raw', () => {
|
|
299
|
+
const result = {
|
|
300
|
+
about: { raw: 'some_non_matching_url' },
|
|
301
|
+
objectProvides: { raw: [] },
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const config = null;
|
|
305
|
+
const fallback =
|
|
306
|
+
'https://www.eea.europa.eu/portal_depiction/generic/image_preview';
|
|
307
|
+
|
|
308
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
309
|
+
result,
|
|
310
|
+
config,
|
|
311
|
+
fallback,
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
expect(imageUrl).toBe(fallback);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('should return the glossary term preview image for matching about.raw URLs', () => {
|
|
318
|
+
const result = {
|
|
319
|
+
about: { raw: 'http://www.eea.europa.eu/en/help/glossary/some_term' },
|
|
320
|
+
image_preview: undefined,
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const config = null;
|
|
324
|
+
const fallback =
|
|
325
|
+
'https://www.eea.europa.eu/portal_depiction/country-profile/image_preview';
|
|
326
|
+
|
|
327
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
328
|
+
result,
|
|
329
|
+
config,
|
|
330
|
+
fallback,
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
expect(imageUrl).toBe(fallback);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('should return the data preview image for matching about.raw URL containing land.copernicus.eu', () => {
|
|
337
|
+
const result = {
|
|
338
|
+
about: { raw: 'https://land.copernicus.eu/some_data' },
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const config = null;
|
|
342
|
+
const fallback = 'fallback_image_url';
|
|
343
|
+
|
|
344
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
345
|
+
result,
|
|
346
|
+
config,
|
|
347
|
+
fallback,
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
expect(imageUrl).toBe('https://land.copernicus.eu/some_data/image_preview');
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('should return the specific preview image from result if specific conditions are met', () => {
|
|
354
|
+
const result = {
|
|
355
|
+
site_id: { raw: 'sdi' },
|
|
356
|
+
'overview.url': { raw: 'some_overview_url' },
|
|
357
|
+
image_preview: { raw: 'specific_preview_image' },
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const config = null;
|
|
361
|
+
const fallback = 'fallback_image_url';
|
|
362
|
+
|
|
363
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
364
|
+
result,
|
|
365
|
+
config,
|
|
366
|
+
fallback,
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
expect(imageUrl).toBe('specific_preview_image');
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('should return the image_preview URL from result for specific about.raw URLs', () => {
|
|
373
|
+
const result = {
|
|
374
|
+
about: { raw: 'https://biodiversity.europa.eu/some_data' },
|
|
375
|
+
image_preview: { raw: 'specific_about_image_preview' },
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const config = null;
|
|
379
|
+
const fallback = 'fallback_image_url';
|
|
380
|
+
|
|
381
|
+
const imageUrl = getGlobalsearchThumbUrl(contentTypeNormalize)(
|
|
382
|
+
result,
|
|
383
|
+
config,
|
|
384
|
+
fallback,
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
expect(imageUrl).toBe('specific_about_image_preview');
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe('get_cluster_icons', () => {
|
|
392
|
+
it('should return icons object from clusters with multiple values', () => {
|
|
393
|
+
const settings = {
|
|
394
|
+
clusters: [
|
|
395
|
+
{ name: 'cluster1', icon: 'icon1', values: ['value1', 'value2'] },
|
|
396
|
+
{ name: 'cluster2', icon: 'icon2', values: ['value3'] },
|
|
397
|
+
],
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const expectedIcons = {
|
|
401
|
+
fallback: { name: 'file outline' },
|
|
402
|
+
value1: { cluster: 'cluster1', icon: 'icon1' },
|
|
403
|
+
value2: { cluster: 'cluster1', icon: 'icon1' },
|
|
404
|
+
value3: { cluster: 'cluster2', icon: 'icon2' },
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
const icons = get_cluster_icons(settings);
|
|
408
|
+
|
|
409
|
+
expect(icons).toEqual(expectedIcons);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe('get_cluster_icons_dict', () => {
|
|
414
|
+
it('should return icons object from clusters with multiple values', () => {
|
|
415
|
+
const settings = {
|
|
416
|
+
clusters: [
|
|
417
|
+
{ name: 'cluster1', icon: 'icon1', values: ['value1', 'value2'] },
|
|
418
|
+
{ name: 'cluster2', icon: 'icon2', values: ['value3'] },
|
|
419
|
+
],
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const expectedIcons = {
|
|
423
|
+
fallback: { name: 'file outline' },
|
|
424
|
+
value1: 'icon1',
|
|
425
|
+
value2: 'icon1',
|
|
426
|
+
value3: 'icon2',
|
|
427
|
+
cluster1: 'icon1',
|
|
428
|
+
cluster2: 'icon2',
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const icons = get_cluster_icons_dict(settings);
|
|
432
|
+
|
|
433
|
+
expect(icons).toEqual(expectedIcons);
|
|
434
|
+
});
|
|
435
|
+
});
|
package/.i18n.babel.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('@plone/volto/babel');
|