@eeacms/volto-globalsearch 2.1.1 → 3.0.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/CHANGELOG.md CHANGED
@@ -4,13 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [2.1.1](https://github.com/eea/volto-globalsearch/compare/2.1.0...2.1.1) - 13 May 2025
7
+ ### [3.0.0](https://github.com/eea/volto-globalsearch/compare/2.1.2...3.0.0) - 26 January 2026
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: Automated code fix [eea-jenkins - [`6a780cc`](https://github.com/eea/volto-globalsearch/commit/6a780cc4c5a78f60754e0a9d17551104b68f258d)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - Prepare major release 3.0.0 [Miu Razvan - [`afe6005`](https://github.com/eea/volto-globalsearch/commit/afe6005abc2d747a1cb4a27ff5757f095102d050)]
16
+ - clean up [Miu Razvan - [`a09c03a`](https://github.com/eea/volto-globalsearch/commit/a09c03a34832bc3ea07905e420fab41c0430f911)]
17
+ - increase tests coverage [Miu Razvan - [`aa568dc`](https://github.com/eea/volto-globalsearch/commit/aa568dc329d58b2a399783bd8a02cec49ed260eb)]
18
+ ### [2.1.2](https://github.com/eea/volto-globalsearch/compare/2.1.1...2.1.2) - 15 May 2025
19
+
20
+ ### [2.1.1](https://github.com/eea/volto-globalsearch/compare/2.1.0...2.1.1) - 14 May 2025
8
21
 
9
22
  #### :hammer_and_wrench: Others
10
23
 
11
24
  - Only this works [Tiberiu Ichim - [`9f24fae`](https://github.com/eea/volto-globalsearch/commit/9f24fae84804ed33bd56391531aa9edc17908ac8)]
12
- - Tweak bundling for png files [Tiberiu Ichim - [`62834c2`](https://github.com/eea/volto-globalsearch/commit/62834c21527dbfbcaa30fe3a261c084918d0b8fb)]
13
- - Tweak bundling for png files [Tiberiu Ichim - [`6b9be03`](https://github.com/eea/volto-globalsearch/commit/6b9be0304923d36094dcd465bbfb51456b6018a0)]
14
25
  ### [2.1.0](https://github.com/eea/volto-globalsearch/compare/2.0.11...2.1.0) - 8 May 2025
15
26
 
16
27
  ### [2.0.11](https://github.com/eea/volto-globalsearch/compare/2.0.10...2.0.11) - 8 April 2025
@@ -20,7 +31,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
20
31
  #### :hammer_and_wrench: Others
21
32
 
22
33
  - Update package.json [Krisztina Elekes - [`37141a6`](https://github.com/eea/volto-globalsearch/commit/37141a6d38c96f87ce0c6b443b476739b728797f)]
23
- - Add Sonarqube tag using fise-frontend addons list [EEA Jenkins - [`661bae3`](https://github.com/eea/volto-globalsearch/commit/661bae385546a308e2b44389ec734be80a6fc916)]
24
34
  ### [2.0.9](https://github.com/eea/volto-globalsearch/compare/2.0.8...2.0.9) - 6 March 2025
25
35
 
26
36
  #### :hammer_and_wrench: Others
@@ -66,7 +76,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66
76
 
67
77
  - added logo for copernicus insitu [Zoltan Szabo - [`b6b00ea`](https://github.com/eea/volto-globalsearch/commit/b6b00eacaf5fd798426fd5cf0af50858f8be79ef)]
68
78
  - added copernicus in situ [Zoltan Szabo - [`54e3657`](https://github.com/eea/volto-globalsearch/commit/54e3657c28f8aa5a839952e83f9fbdb238e99ff0)]
69
- - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`173f015`](https://github.com/eea/volto-globalsearch/commit/173f015579c8e334c853238d9fbf39261ced1cb4)]
70
79
  ### [2.0.2](https://github.com/eea/volto-globalsearch/compare/2.0.1...2.0.2) - 16 December 2024
71
80
 
72
81
  #### :house: Internal changes
@@ -75,7 +84,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
75
84
 
76
85
  #### :hammer_and_wrench: Others
77
86
 
78
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`5c6aa68`](https://github.com/eea/volto-globalsearch/commit/5c6aa68b0677dca98776114e69275ade89dcdf25)]
79
87
  ### [2.0.1](https://github.com/eea/volto-globalsearch/compare/2.0.0...2.0.1) - 14 October 2024
80
88
 
81
89
  ## [2.0.0](https://github.com/eea/volto-globalsearch/compare/1.1.0...2.0.0) - 22 April 2024
@@ -87,7 +95,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
87
95
 
88
96
  #### :hammer_and_wrench: Others
89
97
 
90
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`d37a6cb`](https://github.com/eea/volto-globalsearch/commit/d37a6cbbe18e53abed600c082d7d23f8907fd7d3)]
91
98
  ### [1.1.0](https://github.com/eea/volto-globalsearch/compare/1.0.22...1.1.0) - 16 January 2024
92
99
 
93
100
  #### :hammer_and_wrench: Others
@@ -101,7 +108,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
101
108
 
102
109
  #### :house: Internal changes
103
110
 
104
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`af030b5`](https://github.com/eea/volto-globalsearch/commit/af030b5cc8780353dd67f30857fd20edf746d5a0)]
105
111
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`866609d`](https://github.com/eea/volto-globalsearch/commit/866609d540bd0efe4bab088305bb2127105d8df7)]
106
112
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`e09f5e2`](https://github.com/eea/volto-globalsearch/commit/e09f5e2c1161b4b867c04eb1c0421274bd6c7110)]
107
113
 
@@ -109,11 +115,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
109
115
 
110
116
  - removed try/catch [Zoltan Szabo - [`86cec5d`](https://github.com/eea/volto-globalsearch/commit/86cec5d49d06d41541dc6d42464e9b95769da745)]
111
117
  - avoid async promise executor functions [Zoltan Szabo - [`61012e3`](https://github.com/eea/volto-globalsearch/commit/61012e331776fadaa9eafe9f7667b18d08b2351a)]
112
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`693b9c7`](https://github.com/eea/volto-globalsearch/commit/693b9c7f8c9d96533f04f5ae165e7e63b753222d)]
113
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`66db063`](https://github.com/eea/volto-globalsearch/commit/66db0635134d95f57c913c400902096980f2b66b)]
114
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`4b8920b`](https://github.com/eea/volto-globalsearch/commit/4b8920b5456e5a7f0ef355a0aa208267b50d395f)]
115
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`5ea9790`](https://github.com/eea/volto-globalsearch/commit/5ea97905931323146c33be941646fab45643b18b)]
116
- - test: [JENKINS] Improve cypress time [valentinab25 - [`1b94a8c`](https://github.com/eea/volto-globalsearch/commit/1b94a8c137d6c4961f811bbc4596da93d2b588bd)]
117
118
  ### [1.0.21](https://github.com/eea/volto-globalsearch/compare/1.0.20...1.0.21) - 29 September 2023
118
119
 
119
120
  #### :house: Internal changes
@@ -176,13 +177,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
176
177
 
177
178
  #### :house: Internal changes
178
179
 
179
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ae6efed`](https://github.com/eea/volto-globalsearch/commit/ae6efed386f8fd053972a388a3f8714ff36cf575)]
180
180
 
181
181
  #### :hammer_and_wrench: Others
182
182
 
183
183
  - added missing logo [Zoltan Szabo - [`94684b9`](https://github.com/eea/volto-globalsearch/commit/94684b979698c47de353ecc2a9014a8f70d7ecc1)]
184
184
  - updated frontend with configuration for 'Climate Advisory Board' [Zoltan Szabo - [`28cf22c`](https://github.com/eea/volto-globalsearch/commit/28cf22c93237226c3957223b497a33ab3cb73623)]
185
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`b655d51`](https://github.com/eea/volto-globalsearch/commit/b655d51fa3631ae42c89eb85bdcc850f70d9c72c)]
186
185
  ### [1.0.15](https://github.com/eea/volto-globalsearch/compare/1.0.14...1.0.15) - 14 March 2023
187
186
 
188
187
  #### :hammer_and_wrench: Others
@@ -202,7 +201,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
202
201
  #### :hammer_and_wrench: Others
203
202
 
204
203
  - set the middleware proxy address for globalsearchbase [Zoltan Szabo - [`d0a0802`](https://github.com/eea/volto-globalsearch/commit/d0a08026fa73ce8fd15b666c922e7db71104a5d1)]
205
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b710a4f`](https://github.com/eea/volto-globalsearch/commit/b710a4f73f61e164ecf502a83e7f07d0daf578b3)]
206
204
  ### [1.0.12](https://github.com/eea/volto-globalsearch/compare/1.0.11...1.0.12) - 1 March 2023
207
205
 
208
206
  #### :hammer_and_wrench: Others
@@ -270,14 +268,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
270
268
  - Make last 2 years default [Tiberiu Ichim - [`ff765e2`](https://github.com/eea/volto-globalsearch/commit/ff765e24a1d93c60f091aeffa7c3156d8fb98e49)]
271
269
  - Add compact listing, placeholder for now [Tiberiu Ichim - [`3f6104f`](https://github.com/eea/volto-globalsearch/commit/3f6104fb1725f7e3c22736a30629f64e4882242a)]
272
270
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`8120264`](https://github.com/eea/volto-globalsearch/commit/812026495c31b272e6ae6415642cf1a6b2f783cf)]
273
- - yarn 3 [Alin Voinea - [`b61ad50`](https://github.com/eea/volto-globalsearch/commit/b61ad5075a79bebfce1044a6cd4978c92d98fbdc)]
274
271
  ### [1.0.1](https://github.com/eea/volto-globalsearch/compare/1.0.0...1.0.1) - 16 November 2022
275
272
 
276
273
  #### :hammer_and_wrench: Others
277
274
 
278
275
  - Fix eslint [Tiberiu Ichim - [`cf2886b`](https://github.com/eea/volto-globalsearch/commit/cf2886b412013f9427cf5d39cdf00004bdd9f80b)]
279
276
  - test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`40c08d2`](https://github.com/eea/volto-globalsearch/commit/40c08d2d4eda81ce306225a81f09e0bcfe6794eb)]
280
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`af6e020`](https://github.com/eea/volto-globalsearch/commit/af6e020794798c1f69fee8c08bdf71fc3992230a)]
281
277
  ## [1.0.0](https://github.com/eea/volto-globalsearch/compare/0.1.7...1.0.0) - 28 October 2022
282
278
 
283
279
  #### :nail_care: Enhancements
@@ -296,7 +292,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
296
292
  #### :hammer_and_wrench: Others
297
293
 
298
294
  - Fix dependencies [kreafox - [`50ad307`](https://github.com/eea/volto-globalsearch/commit/50ad307d64140c43df9dded27c0b532923885764)]
299
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c2d848e`](https://github.com/eea/volto-globalsearch/commit/c2d848e1efa456f53d883c50769882101e1ce19f)]
300
295
  ### [0.1.5](https://github.com/eea/volto-globalsearch/compare/0.1.4...0.1.5) - 28 July 2022
301
296
 
302
297
  #### :hammer_and_wrench: Others
@@ -309,7 +304,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
309
304
 
310
305
  #### :hammer_and_wrench: Others
311
306
 
312
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5dce07b`](https://github.com/eea/volto-globalsearch/commit/5dce07ba7d1e82776a426e9746d5dab1b0acf738)]
313
307
  ### [0.1.3](https://github.com/eea/volto-globalsearch/compare/0.1.2...0.1.3) - 10 June 2022
314
308
 
315
309
  ### [0.1.2](https://github.com/eea/volto-globalsearch/compare/0.1.1...0.1.2) - 10 June 2022
@@ -332,7 +326,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
332
326
  - ignore eslint for *.json files [Zoltan Szabo - [`e18919e`](https://github.com/eea/volto-globalsearch/commit/e18919e1255818c5cf33bf769cca078d75ca3422)]
333
327
  - formatting [Zoltan Szabo - [`18282ed`](https://github.com/eea/volto-globalsearch/commit/18282ed159865bcbc50e2fd17417cf6d90d3e593)]
334
328
  - updated dependencies [Zoltan Szabo - [`cfcf46e`](https://github.com/eea/volto-globalsearch/commit/cfcf46ee33b23bb31f76955c12a857411f042daf)]
335
- - [JENKINSFILE] fix after bootstrap [valentinab25 - [`61c8c46`](https://github.com/eea/volto-globalsearch/commit/61c8c46891edf3b52768f12cf7505c034ef7bb89)]
336
329
  ### 0.0.1 - 19 May 2022
337
330
 
338
331
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-globalsearch",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "description": "@eeacms/volto-globalsearch: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
package/razzle.extend.js CHANGED
@@ -1,30 +1,30 @@
1
- const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
2
- const fileLoaderFinder = makeLoaderFinder('file-loader');
1
+ // const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
2
+ // const fileLoaderFinder = makeLoaderFinder('file-loader');
3
3
 
4
4
  const plugins = (defaultPlugins) => {
5
5
  return defaultPlugins;
6
6
  };
7
7
 
8
8
  const modify = (config, { target, dev }, webpack) => {
9
- const fileLoader = config.module.rules.find(fileLoaderFinder);
10
-
11
- fileLoader.exclude = [
12
- /\.(config|variables|overrides)$/,
13
- /icons\/.*\.svg$/,
14
- /\.html$/,
15
- /\.(js|jsx|mjs)$/,
16
- /\.(ts|tsx)$/,
17
- /\.(vue)$/,
18
- /\.(less)$/,
19
- /\.(re)$/,
20
- /\.(s?css|sass)$/,
21
- /\.json$/,
22
- /\.bmp$/,
23
- /\.gif$/,
24
- /\.jpe?g$/,
25
- // .png files we don't want them in the bundle
26
- /static\/\.png$/,
27
- ];
9
+ // const fileLoader = config.module.rules.find(fileLoaderFinder);
10
+ //
11
+ // fileLoader.exclude = [
12
+ // /\.(config|variables|overrides)$/,
13
+ // /icons\/.*\.svg$/,
14
+ // /\.html$/,
15
+ // /\.(js|jsx|mjs)$/,
16
+ // /\.(ts|tsx)$/,
17
+ // /\.(vue)$/,
18
+ // /\.(less)$/,
19
+ // /\.(re)$/,
20
+ // /\.(s?css|sass)$/,
21
+ // /\.json$/,
22
+ // /\.bmp$/,
23
+ // /\.gif$/,
24
+ // /\.jpe?g$/,
25
+ // // .png files we don't want them in the bundle
26
+ // /static\/\.png$/,
27
+ // ];
28
28
 
29
29
  return config;
30
30
  };
@@ -0,0 +1,221 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+
3
+ import config, {
4
+ clusters,
5
+ clusterIcons,
6
+ typesForClustersOptionsFilter,
7
+ } from './clusters';
8
+
9
+ // Mock static image imports
10
+ jest.mock('../static/website-logo.png', () => 'website-logo.png', {
11
+ virtual: true,
12
+ });
13
+ jest.mock('../static/eea-logo.svg', () => 'eea-logo.svg', { virtual: true });
14
+ jest.mock('../static/ias-logo.png', () => 'ias-logo.png', { virtual: true });
15
+ jest.mock('../static/bise-logo.png', () => 'bise-logo.png', { virtual: true });
16
+ jest.mock('../static/wise-logo.png', () => 'wise-logo.png', { virtual: true });
17
+ jest.mock('../static/energy-logo.png', () => 'energy-logo.png', {
18
+ virtual: true,
19
+ });
20
+ jest.mock('../static/water-logo.png', () => 'water-logo.png', {
21
+ virtual: true,
22
+ });
23
+ jest.mock('../static/forest-logo.png', () => 'forest-logo.png', {
24
+ virtual: true,
25
+ });
26
+ jest.mock('../static/industry-logo.png', () => 'industry-logo.png', {
27
+ virtual: true,
28
+ });
29
+ jest.mock('../static/climate-adapt-logo.png', () => 'climate-adapt-logo.png', {
30
+ virtual: true,
31
+ });
32
+ jest.mock('../static/eionet-logo.png', () => 'eionet-logo.png', {
33
+ virtual: true,
34
+ });
35
+ jest.mock('../static/etc-atni.png', () => 'etc-atni.png', { virtual: true });
36
+ jest.mock('../static/etc-bd.jpg', () => 'etc-bd.jpg', { virtual: true });
37
+ jest.mock('../static/etc-cca.jpeg', () => 'etc-cca.jpeg', { virtual: true });
38
+ jest.mock('../static/etc-cme.png', () => 'etc-cme.png', { virtual: true });
39
+ jest.mock('../static/etc-icm.jpg', () => 'etc-icm.jpg', { virtual: true });
40
+ jest.mock('../static/etc-uls.png', () => 'etc-uls.png', { virtual: true });
41
+ jest.mock('../static/etc-wmge.png', () => 'etc-wmge.png', { virtual: true });
42
+ jest.mock('../static/cab-logo.png', () => 'cab-logo.png', { virtual: true });
43
+ jest.mock(
44
+ '../static/copernicus_insitu_logo.svg',
45
+ () => 'copernicus_insitu_logo.svg',
46
+ { virtual: true },
47
+ );
48
+
49
+ describe('clusters configuration', () => {
50
+ describe('clusters object', () => {
51
+ it('should export clusters object', () => {
52
+ expect(clusters).toBeDefined();
53
+ });
54
+
55
+ it('should have name property', () => {
56
+ expect(clusters.name).toBe('op_cluster');
57
+ });
58
+
59
+ it('should have field property', () => {
60
+ expect(clusters.field).toBe('objectProvides');
61
+ });
62
+
63
+ it('should have clusters array', () => {
64
+ expect(clusters.clusters).toBeDefined();
65
+ expect(Array.isArray(clusters.clusters)).toBe(true);
66
+ });
67
+
68
+ it('should have News cluster', () => {
69
+ const newsCluster = clusters.clusters.find((c) => c.name === 'News');
70
+ expect(newsCluster).toBeDefined();
71
+ expect(newsCluster.values).toContain('News');
72
+ expect(newsCluster.values).toContain('Article');
73
+ });
74
+
75
+ it('should have Publications cluster', () => {
76
+ const pubCluster = clusters.clusters.find(
77
+ (c) => c.name === 'Publications',
78
+ );
79
+ expect(pubCluster).toBeDefined();
80
+ expect(pubCluster.values).toContain('Report');
81
+ expect(pubCluster.values).toContain('Indicator');
82
+ });
83
+
84
+ it('should have Maps and charts cluster', () => {
85
+ const mapsCluster = clusters.clusters.find(
86
+ (c) => c.name === 'Maps and charts',
87
+ );
88
+ expect(mapsCluster).toBeDefined();
89
+ expect(mapsCluster.values).toContain('Dashboard');
90
+ });
91
+
92
+ it('should have Data cluster', () => {
93
+ const dataCluster = clusters.clusters.find((c) => c.name === 'Data');
94
+ expect(dataCluster).toBeDefined();
95
+ expect(dataCluster.values).toContain('Data set');
96
+ });
97
+
98
+ it('should have Others cluster', () => {
99
+ const othersCluster = clusters.clusters.find((c) => c.name === 'Others');
100
+ expect(othersCluster).toBeDefined();
101
+ expect(othersCluster.values).toContain('Webpage');
102
+ });
103
+
104
+ it('each cluster should have defaultResultView', () => {
105
+ clusters.clusters.forEach((cluster) => {
106
+ expect(cluster.defaultResultView).toBeDefined();
107
+ });
108
+ });
109
+ });
110
+
111
+ describe('clusterIcons', () => {
112
+ it('should export clusterIcons', () => {
113
+ expect(clusterIcons).toBeDefined();
114
+ });
115
+
116
+ it('should have fallback icon', () => {
117
+ expect(clusterIcons.fallback).toBeDefined();
118
+ });
119
+
120
+ it('should have News icon mapping', () => {
121
+ expect(clusterIcons.News).toBeDefined();
122
+ });
123
+ });
124
+
125
+ describe('config', () => {
126
+ it('should export default config', () => {
127
+ expect(config).toBeDefined();
128
+ });
129
+
130
+ it('should have icons configuration', () => {
131
+ expect(config.icons).toBeDefined();
132
+ });
133
+
134
+ it('should have Content types icons', () => {
135
+ expect(config.icons['Content types']).toBeDefined();
136
+ });
137
+
138
+ it('should have Sources icons', () => {
139
+ expect(config.icons.Sources).toBeDefined();
140
+ });
141
+
142
+ it('should have contentSectionsParams', () => {
143
+ expect(config.contentSectionsParams).toBeDefined();
144
+ });
145
+
146
+ it('should have contentSectionsParams.enable set to true', () => {
147
+ expect(config.contentSectionsParams.enable).toBe(true);
148
+ });
149
+
150
+ it('should have contentSectionsParams.sectionFacetsField', () => {
151
+ expect(config.contentSectionsParams.sectionFacetsField).toBe(
152
+ 'op_cluster',
153
+ );
154
+ });
155
+
156
+ it('should have clusterMapping in contentSectionsParams', () => {
157
+ expect(config.contentSectionsParams.clusterMapping).toBeDefined();
158
+ });
159
+ });
160
+
161
+ describe('typesForClustersOptionsFilter', () => {
162
+ const mockOptions = [
163
+ { value: 'News' },
164
+ { value: 'Article' },
165
+ { value: 'Report' },
166
+ { value: 'Dashboard' },
167
+ { value: 'Data set' },
168
+ ];
169
+
170
+ it('should return all options when no cluster filter is active', () => {
171
+ const filters = [];
172
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
173
+ expect(result).toEqual(mockOptions);
174
+ });
175
+
176
+ it('should return all options when filters is undefined', () => {
177
+ const result = typesForClustersOptionsFilter(mockOptions, undefined);
178
+ expect(result).toEqual(mockOptions);
179
+ });
180
+
181
+ it('should filter options for News cluster', () => {
182
+ const filters = [{ field: 'op_cluster', values: ['News'] }];
183
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
184
+
185
+ expect(result).toContainEqual({ value: 'News' });
186
+ expect(result).toContainEqual({ value: 'Article' });
187
+ expect(result).not.toContainEqual({ value: 'Report' });
188
+ });
189
+
190
+ it('should filter options for Publications cluster', () => {
191
+ const filters = [{ field: 'op_cluster', values: ['Publications'] }];
192
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
193
+
194
+ expect(result).toContainEqual({ value: 'Report' });
195
+ expect(result).not.toContainEqual({ value: 'News' });
196
+ });
197
+
198
+ it('should filter options for Data cluster', () => {
199
+ const filters = [{ field: 'op_cluster', values: ['Data'] }];
200
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
201
+
202
+ expect(result).toContainEqual({ value: 'Data set' });
203
+ expect(result).not.toContainEqual({ value: 'News' });
204
+ });
205
+
206
+ it('should filter options for Maps and charts cluster', () => {
207
+ const filters = [{ field: 'op_cluster', values: ['Maps and charts'] }];
208
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
209
+
210
+ expect(result).toContainEqual({ value: 'Dashboard' });
211
+ expect(result).not.toContainEqual({ value: 'News' });
212
+ });
213
+
214
+ it('should return empty array when no options match the cluster', () => {
215
+ const filters = [{ field: 'op_cluster', values: ['NonExistent'] }];
216
+ const result = typesForClustersOptionsFilter(mockOptions, filters);
217
+
218
+ expect(result).toEqual([]);
219
+ });
220
+ });
221
+ });
@@ -0,0 +1,67 @@
1
+ import filters from './filters';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+
4
+ describe('filters configuration', () => {
5
+ it('should export filters object', () => {
6
+ expect(filters).toBeDefined();
7
+ });
8
+
9
+ it('should have permanentFilters array', () => {
10
+ expect(filters.permanentFilters).toBeDefined();
11
+ expect(Array.isArray(filters.permanentFilters)).toBe(true);
12
+ });
13
+
14
+ it('should have published workflow state filter', () => {
15
+ const workflowFilter = filters.permanentFilters.find(
16
+ (f) => f.term && f.term.hasWorkflowState === 'published',
17
+ );
18
+ expect(workflowFilter).toBeDefined();
19
+ });
20
+
21
+ it('should have constantScore filter function', () => {
22
+ const constantScoreFilter = filters.permanentFilters.find(
23
+ (f) => typeof f === 'function' && f.id === 'constantScore',
24
+ );
25
+ expect(constantScoreFilter).toBeDefined();
26
+ });
27
+
28
+ it('constantScore filter should return correct structure', () => {
29
+ const constantScoreFilter = filters.permanentFilters.find(
30
+ (f) => typeof f === 'function' && f.id === 'constantScore',
31
+ );
32
+ const result = constantScoreFilter();
33
+
34
+ expect(result.constant_score).toBeDefined();
35
+ expect(result.constant_score.filter).toBeDefined();
36
+ expect(result.constant_score.filter.bool).toBeDefined();
37
+ expect(result.constant_score.filter.bool.should).toBeDefined();
38
+ expect(Array.isArray(result.constant_score.filter.bool.should)).toBe(true);
39
+ });
40
+
41
+ it('constantScore filter should have must_not exists condition', () => {
42
+ const constantScoreFilter = filters.permanentFilters.find(
43
+ (f) => typeof f === 'function' && f.id === 'constantScore',
44
+ );
45
+ const result = constantScoreFilter();
46
+
47
+ const mustNotExistsCondition =
48
+ result.constant_score.filter.bool.should.find(
49
+ (s) => s.bool && s.bool.must_not && s.bool.must_not.exists,
50
+ );
51
+ expect(mustNotExistsCondition).toBeDefined();
52
+ expect(mustNotExistsCondition.bool.must_not.exists.field).toBe('issued');
53
+ });
54
+
55
+ it('constantScore filter should have range condition for issued.date', () => {
56
+ const constantScoreFilter = filters.permanentFilters.find(
57
+ (f) => typeof f === 'function' && f.id === 'constantScore',
58
+ );
59
+ const result = constantScoreFilter();
60
+
61
+ const rangeCondition = result.constant_score.filter.bool.should.find(
62
+ (s) => s.range && s.range['issued.date'],
63
+ );
64
+ expect(rangeCondition).toBeDefined();
65
+ expect(rangeCondition.range['issued.date'].lte).toBeDefined();
66
+ });
67
+ });
@@ -10,8 +10,6 @@ import latest_tasks_for_site from './healthcheck_queries/latest_tasks_for_site.j
10
10
  import started_or_finished_site_since_last_started from './healthcheck_queries/started_or_finished_site_since_last_started.json';
11
11
 
12
12
  const default_documentCountThreshold = 60000;
13
- const default_queryTimeSecondsThreshold_OK = 2;
14
- const default_queryTimeSecondsThreshold_WARNING = 5;
15
13
  const default_failedSyncThreshold_WARNING = 5;
16
14
  const default_failedSyncThreshold_OK = 2;
17
15
 
@@ -24,11 +22,11 @@ export function buildQuery(query, values) {
24
22
  }
25
23
 
26
24
  async function executeQuery(q, appConfig, params = {}, callback) {
27
- params['index_name'] = 'status_' + appConfig['index_name'];
25
+ const { id, host } = appConfig;
26
+ const url = new URL(host);
27
+ url.pathname = `/_es/{status_}${id}/_search`;
28
28
  const query = buildQuery(q, params);
29
- //console.log(JSON.stringify(query));
30
- const resp = await runRequest(query, appConfig);
31
- // console.log(JSON.stringify(resp.body));
29
+ const resp = await runRequest(query, appConfig, url);
32
30
  return Promise.resolve(callback(resp.body, params));
33
31
  }
34
32
 
@@ -101,8 +99,7 @@ export function getlatesttasks_for_site(body, params = {}) {
101
99
  export async function getStatus(appConfig, params) {
102
100
  let resp = 'OK';
103
101
  let error = null;
104
- // console.log('=======================================');
105
- // console.log('STEP 1');
102
+ // console.log('==== STEP 1 ====');
106
103
  const step1 = await executeQuery(
107
104
  last_scheduled_started_indexing,
108
105
  appConfig,
@@ -110,16 +107,13 @@ export async function getStatus(appConfig, params) {
110
107
  getlastandnext_started_execution,
111
108
  );
112
109
 
113
- // console.log(step1);
114
-
115
110
  // const last_successful_schedule = step1.last_started;
116
111
  let next_schedule = step1.next_execution_date;
117
112
 
118
113
  const now = params.now || Date.now() - 60 * 1000;
119
114
  if (now >= next_schedule) {
120
115
  try {
121
- // console.log('=======================================');
122
- // console.log('STEP 2');
116
+ // console.log('==== STEP 2 ====');
123
117
  const step2 = await executeQuery(
124
118
  failed_scheduled_atempts_since_last_started,
125
119
  appConfig,
@@ -127,7 +121,6 @@ export async function getStatus(appConfig, params) {
127
121
  getlastfailed_execution,
128
122
  );
129
123
  next_schedule = step2.next_execution_date;
130
- // console.log(step2);
131
124
  } catch {
132
125
  resp = 'CRITICAL';
133
126
  error = 'Failed to get status info from elasticsearch';
@@ -139,19 +132,17 @@ export async function getStatus(appConfig, params) {
139
132
  error = 'Airflow stopped indexing, no new schedules in the queue';
140
133
  } else {
141
134
  try {
135
+ // console.log('==== STEP 3 ====');
142
136
  const step3 = await executeQuery(
143
137
  last_sync_task_since_last_start,
144
138
  appConfig,
145
139
  step1,
146
140
  getlastsynctaskssincestarted,
147
141
  );
148
- // console.log(step3.sites);
149
142
  const all_sites_status = {};
150
143
  for (let i = 0; i < step3.sites.length; i++) {
151
144
  try {
152
- // console.log('=======================================');
153
- // console.log('STEP 4');
154
- // const step4 =
145
+ // console.log('==== STEP 4 ====');
155
146
  await executeQuery(
156
147
  started_or_finished_site_since_last_started,
157
148
  appConfig,
@@ -162,10 +153,8 @@ export async function getStatus(appConfig, params) {
162
153
  getlastsuccessfultasks_for_site,
163
154
  );
164
155
  all_sites_status[step3.sites[i]] = 'OK';
165
- // console.log(step4);
166
156
  } catch {
167
- // console.log('=======================================');
168
- // console.log('STEP 5');
157
+ // console.log('==== STEP 5 ====');
169
158
  const step5 = await executeQuery(
170
159
  latest_tasks_for_site,
171
160
  appConfig,
@@ -182,7 +171,6 @@ export async function getStatus(appConfig, params) {
182
171
  all_sites_status[step3.sites[i]] = step5;
183
172
  }
184
173
  }
185
- // console.log(all_sites_status);
186
174
  const oks = [];
187
175
  const warnings = [];
188
176
  const criticals = [];
@@ -232,19 +220,12 @@ export default async function healthcheck(appConfig, params) {
232
220
  try {
233
221
  let {
234
222
  documentCountThreshold,
235
- queryTimeSecondsThreshold_OK,
236
- queryTimeSecondsThreshold_WARNING,
237
223
  failedSyncThreshold_OK,
238
224
  failedSyncThreshold_WARNING,
239
225
  now,
240
226
  } = params;
241
227
  documentCountThreshold =
242
228
  documentCountThreshold || default_documentCountThreshold;
243
- queryTimeSecondsThreshold_OK =
244
- queryTimeSecondsThreshold_OK || default_queryTimeSecondsThreshold_OK;
245
- queryTimeSecondsThreshold_WARNING =
246
- queryTimeSecondsThreshold_WARNING ||
247
- default_queryTimeSecondsThreshold_WARNING;
248
229
  failedSyncThreshold_OK =
249
230
  failedSyncThreshold_OK || default_failedSyncThreshold_OK;
250
231
  failedSyncThreshold_WARNING =
@@ -256,9 +237,7 @@ export default async function healthcheck(appConfig, params) {
256
237
  now: now,
257
238
  };
258
239
 
259
- ///////////////////
260
240
  const body_total = buildRequest({ filters: [] }, appConfig);
261
- //console.log(body_total);
262
241
  const resp_total = await runRequest(body_total, appConfig);
263
242
  const total = resp_total.body.hits.total.value;
264
243
  const total_status =
@@ -269,41 +248,15 @@ export default async function healthcheck(appConfig, params) {
269
248
  error:
270
249
  'The number of documents in elasticsearch dropped drastically',
271
250
  };
272
- const body_nlp = buildRequest(
273
- { filters: [], searchTerm: 'what is bise?' },
274
- appConfig,
275
- );
276
- const resp_nlp = await runRequest(body_nlp, appConfig);
277
- const elapsed = resp_nlp.body.elapsed;
278
-
279
- let total_elapsed = 0;
280
- Object.keys(elapsed).forEach((key) => {
281
- elapsed[key].forEach((nlp_step) => {
282
- Object.keys(nlp_step).forEach((step_name) => {
283
- total_elapsed += nlp_step[step_name].delta;
284
- });
285
- });
286
- });
287
-
288
- const elapsed_status =
289
- total_elapsed < queryTimeSecondsThreshold_OK
290
- ? { status: 'OK' }
291
- : total_elapsed < queryTimeSecondsThreshold_WARNING
292
- ? { status: 'WARNING', error: 'Slow response from NLP' }
293
- : { status: 'CRITICAL', error: 'Slow response from NLP' };
294
251
 
295
252
  const airflow_status = await getStatus(appConfig, airflow_params);
296
253
 
297
254
  let status = { status: 'OK' };
298
- if (
299
- elapsed_status.status === 'WARNING' ||
300
- airflow_status.status === 'WARNING'
301
- ) {
255
+ if (airflow_status.status === 'WARNING') {
302
256
  status = { status: 'WARNING' };
303
257
  }
304
258
  if (
305
259
  total_status.status === 'CRITICAL' ||
306
- elapsed_status.status === 'CRITICAL' ||
307
260
  airflow_status.status === 'CRITICAL'
308
261
  ) {
309
262
  status = { status: 'CRITICAL' };
@@ -313,9 +266,6 @@ export default async function healthcheck(appConfig, params) {
313
266
  if (total_status.error) {
314
267
  errors_list.push(total_status.error);
315
268
  }
316
- if (elapsed_status.error) {
317
- errors_list.push(elapsed_status.error);
318
- }
319
269
  if (airflow_status.error) {
320
270
  errors_list.push(airflow_status.error);
321
271
  }
@@ -29,6 +29,15 @@ jest.mock('@eeacms/search', () => ({
29
29
  buildRequest: jest.fn(),
30
30
  }));
31
31
 
32
+ beforeEach(() => {
33
+ runRequest.mockClear();
34
+ });
35
+
36
+ const mockAppConfig = {
37
+ id: 'test_index',
38
+ host: 'http://localhost:9200',
39
+ };
40
+
32
41
  const query1 = {
33
42
  query: {
34
43
  bool: {
@@ -253,7 +262,7 @@ describe('test the status of the index', () => {
253
262
  // }),
254
263
  );
255
264
  const params = { index_name: 'test_index', now: 1695732000000 };
256
- const status = await getStatus({}, params);
265
+ const status = await getStatus(mockAppConfig, params);
257
266
  expect(status).toEqual({ status: 'OK' });
258
267
  });
259
268
  });
@@ -261,20 +270,11 @@ describe('test the status of the index', () => {
261
270
  describe('test the healthcheck', () => {
262
271
  it('test', async () => {
263
272
  runRequest
273
+ // First call: total document count check
264
274
  .mockReturnValueOnce(
265
275
  Promise.resolve({ body: { hits: { total: { value: 60001 } } } }),
266
276
  )
267
- .mockReturnValueOnce(
268
- Promise.resolve({
269
- body: {
270
- elapsed: {
271
- step1: [{ query: { delta: 0.5 } }],
272
- step2: [{ query: { delta: 0.6 } }],
273
- },
274
- },
275
- }),
276
- )
277
-
277
+ // getStatus calls:
278
278
  .mockReturnValueOnce(
279
279
  Promise.resolve({ body: last_scheduled_started_indexing_resp }),
280
280
  )
@@ -288,13 +288,18 @@ describe('test the healthcheck', () => {
288
288
  body: last_sync_task_since_last_start_resp,
289
289
  }),
290
290
  )
291
+ .mockReturnValueOnce(
292
+ Promise.resolve({
293
+ body: started_or_finished_site_since_last_started_resp,
294
+ }),
295
+ )
291
296
  .mockReturnValueOnce(
292
297
  Promise.resolve({
293
298
  body: started_or_finished_site_since_last_started_resp,
294
299
  }),
295
300
  );
296
301
  const params = { index_name: 'test_index', now: 1695732000000 };
297
- const status = await healthcheck({}, params);
302
+ const status = await healthcheck(mockAppConfig, params);
298
303
  expect(status).toEqual({ status: 'OK' });
299
304
  });
300
305
  });
@@ -31,6 +31,5 @@
31
31
  "start_time_ts": "desc"
32
32
  }
33
33
  ],
34
- "aggs": {},
35
- "index": "<index_name>"
34
+ "aggs": {}
36
35
  }
@@ -24,6 +24,5 @@
24
24
  "start_time_ts": "desc"
25
25
  }
26
26
  ],
27
- "aggs": {},
28
- "index": "<index_name>"
27
+ "aggs": {}
29
28
  }
@@ -31,6 +31,5 @@
31
31
  "start_time_ts": "desc"
32
32
  }
33
33
  ],
34
- "aggs": {},
35
- "index": "<index_name>"
34
+ "aggs": {}
36
35
  }
@@ -18,6 +18,5 @@
18
18
  {
19
19
  "start_time_ts": "desc"
20
20
  }
21
- ],
22
- "index": "<index_name>"
21
+ ]
23
22
  }
@@ -30,6 +30,5 @@
30
30
  {
31
31
  "start_time_ts": "desc"
32
32
  }
33
- ],
34
- "index": "<index_name>"
33
+ ]
35
34
  }
@@ -0,0 +1,64 @@
1
+ import query from './query';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+
4
+ describe('query configuration', () => {
5
+ it('should export query object', () => {
6
+ expect(query).toBeDefined();
7
+ });
8
+
9
+ it('should have debugQuery set to false', () => {
10
+ expect(query.debugQuery).toBe(false);
11
+ });
12
+
13
+ it('should have extraQueryParams', () => {
14
+ expect(query.extraQueryParams).toBeDefined();
15
+ });
16
+
17
+ it('should have text_fields in extraQueryParams', () => {
18
+ expect(query.extraQueryParams.text_fields).toBeDefined();
19
+ expect(Array.isArray(query.extraQueryParams.text_fields)).toBe(true);
20
+ });
21
+
22
+ it('should have title with boost in text_fields', () => {
23
+ expect(query.extraQueryParams.text_fields).toContain('title^2');
24
+ });
25
+
26
+ it('should have subject with boost in text_fields', () => {
27
+ expect(query.extraQueryParams.text_fields).toContain('subject^1.5');
28
+ });
29
+
30
+ it('should have description with boost in text_fields', () => {
31
+ expect(query.extraQueryParams.text_fields).toContain('description^1.5');
32
+ });
33
+
34
+ it('should have all_fields_for_freetext in text_fields', () => {
35
+ expect(query.extraQueryParams.text_fields).toContain(
36
+ 'all_fields_for_freetext',
37
+ );
38
+ });
39
+
40
+ it('should have functions in extraQueryParams', () => {
41
+ expect(query.extraQueryParams.functions).toBeDefined();
42
+ expect(Array.isArray(query.extraQueryParams.functions)).toBe(true);
43
+ });
44
+
45
+ it('should have exp function for issued.date', () => {
46
+ const expFunction = query.extraQueryParams.functions.find((f) => f.exp);
47
+ expect(expFunction).toBeDefined();
48
+ expect(expFunction.exp['issued.date']).toBeDefined();
49
+ });
50
+
51
+ it('should have correct offset for issued.date function', () => {
52
+ const expFunction = query.extraQueryParams.functions.find((f) => f.exp);
53
+ expect(expFunction.exp['issued.date'].offset).toBe('30d');
54
+ });
55
+
56
+ it('should have correct scale for issued.date function', () => {
57
+ const expFunction = query.extraQueryParams.functions.find((f) => f.exp);
58
+ expect(expFunction.exp['issued.date'].scale).toBe('1800d');
59
+ });
60
+
61
+ it('should have score_mode set to sum', () => {
62
+ expect(query.extraQueryParams.score_mode).toBe('sum');
63
+ });
64
+ });
@@ -0,0 +1,92 @@
1
+ import vocabWrapper from './vocabulary';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+
4
+ describe('vocabulary', () => {
5
+ it('should export vocab wrapper object', () => {
6
+ expect(vocabWrapper).toBeDefined();
7
+ expect(vocabWrapper.vocab).toBeDefined();
8
+ });
9
+
10
+ it('should have language vocabulary', () => {
11
+ expect(vocabWrapper.vocab.language).toBeDefined();
12
+ expect(typeof vocabWrapper.vocab.language).toBe('object');
13
+ });
14
+
15
+ it('should have cluster_name vocabulary', () => {
16
+ expect(vocabWrapper.vocab.cluster_name).toBeDefined();
17
+ expect(typeof vocabWrapper.vocab.cluster_name).toBe('object');
18
+ });
19
+
20
+ it('should have English language entry', () => {
21
+ expect(vocabWrapper.vocab.language.en).toBe('English (en)');
22
+ });
23
+
24
+ it('should have eea cluster name', () => {
25
+ expect(vocabWrapper.vocab.cluster_name.eea).toBe(
26
+ 'European Environment Agency',
27
+ );
28
+ });
29
+
30
+ it('should have all expected languages', () => {
31
+ const expectedLanguages = [
32
+ 'ar',
33
+ 'bg',
34
+ 'bs',
35
+ 'cs',
36
+ 'da',
37
+ 'de',
38
+ 'el',
39
+ 'en',
40
+ 'es',
41
+ 'et',
42
+ 'fi',
43
+ 'fr',
44
+ 'ga',
45
+ 'hr',
46
+ 'hu',
47
+ 'is',
48
+ 'it',
49
+ 'lt',
50
+ 'lv',
51
+ 'mk',
52
+ 'mt',
53
+ 'nl',
54
+ 'no',
55
+ 'pl',
56
+ 'pt',
57
+ 'ro',
58
+ 'ru',
59
+ 'sk',
60
+ 'sl',
61
+ 'sq',
62
+ 'sr',
63
+ 'sv',
64
+ 'tr',
65
+ ];
66
+
67
+ expectedLanguages.forEach((lang) => {
68
+ expect(vocabWrapper.vocab.language[lang]).toBeDefined();
69
+ });
70
+ });
71
+
72
+ it('should have all expected cluster names', () => {
73
+ const expectedClusters = [
74
+ 'eea',
75
+ 'fise',
76
+ 'bise',
77
+ 'industry',
78
+ 'energy',
79
+ 'cca',
80
+ 'ias',
81
+ 'wise-freshwater',
82
+ 'wise-marine',
83
+ 'etc',
84
+ 'sdi',
85
+ 'cab',
86
+ ];
87
+
88
+ expectedClusters.forEach((cluster) => {
89
+ expect(vocabWrapper.vocab.cluster_name[cluster]).toBeDefined();
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,74 @@
1
+ import applyConfig from './index';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+
4
+ jest.mock('./config', () =>
5
+ jest.fn((registry) => ({
6
+ ...registry,
7
+ searchui: {
8
+ ...registry.searchui,
9
+ globalsearch: { id: 'globalsearch' },
10
+ globalsearchbase: { id: 'globalsearchbase' },
11
+ },
12
+ })),
13
+ );
14
+
15
+ describe('volto-globalsearch applyConfig', () => {
16
+ let config;
17
+
18
+ beforeEach(() => {
19
+ config = {
20
+ settings: {
21
+ searchlib: {
22
+ searchui: {
23
+ default: {},
24
+ },
25
+ },
26
+ },
27
+ };
28
+ });
29
+
30
+ it('should apply the globalsearch configuration', () => {
31
+ const result = applyConfig(config);
32
+
33
+ expect(result.settings.searchlib.searchui.globalsearch).toBeDefined();
34
+ expect(result.settings.searchlib.searchui.globalsearchbase).toBeDefined();
35
+ });
36
+
37
+ it('should set elastic_index for globalsearch', () => {
38
+ const result = applyConfig(config);
39
+
40
+ expect(result.settings.searchlib.searchui.globalsearch.elastic_index).toBe(
41
+ '_es/globalsearch',
42
+ );
43
+ });
44
+
45
+ it('should set index_name for globalsearch', () => {
46
+ const result = applyConfig(config);
47
+
48
+ expect(result.settings.searchlib.searchui.globalsearch.index_name).toBe(
49
+ 'data_searchui',
50
+ );
51
+ });
52
+
53
+ it('should set elastic_index for globalsearchbase', () => {
54
+ const result = applyConfig(config);
55
+
56
+ expect(
57
+ result.settings.searchlib.searchui.globalsearchbase.elastic_index,
58
+ ).toBe('_es/globalsearch');
59
+ });
60
+
61
+ it('should set index_name for globalsearchbase', () => {
62
+ const result = applyConfig(config);
63
+
64
+ expect(result.settings.searchlib.searchui.globalsearchbase.index_name).toBe(
65
+ 'data_searchui',
66
+ );
67
+ });
68
+
69
+ it('should return the modified config', () => {
70
+ const result = applyConfig(config);
71
+
72
+ expect(result).toBe(config);
73
+ });
74
+ });