@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.
Files changed (36) hide show
  1. package/.eslintignore +1 -0
  2. package/.husky/pre-commit +2 -0
  3. package/CHANGELOG.md +43 -9
  4. package/DEVELOP.md +60 -6
  5. package/README.md +18 -2
  6. package/cypress.config.js +2 -2
  7. package/docker-compose.yml +32 -0
  8. package/jest-addon.config.js +2 -0
  9. package/locales/de/LC_MESSAGES/volto.po +14 -0
  10. package/locales/en/LC_MESSAGES/volto.po +14 -0
  11. package/locales/it/LC_MESSAGES/volto.po +14 -0
  12. package/locales/ro/LC_MESSAGES/volto.po +14 -0
  13. package/locales/volto.pot +16 -0
  14. package/package.json +26 -2
  15. package/src/components/MasonryLandingPage.test.jsx +99 -0
  16. package/src/config/facets.js +1 -1
  17. package/src/config/filters.js +26 -22
  18. package/src/config/global-search-config.js +20 -0
  19. package/src/config/healthcheck.js +315 -10
  20. package/src/config/healthcheck.test.js +300 -0
  21. package/src/config/healthcheck_queries/empty_resp.json +18 -0
  22. package/src/config/healthcheck_queries/failed_scheduled_atempts_since_last_started.json +36 -0
  23. package/src/config/healthcheck_queries/failed_scheduled_atempts_since_last_started_resp.json +41 -0
  24. package/src/config/healthcheck_queries/failed_site_since_last_started.json +31 -0
  25. package/src/config/healthcheck_queries/last_scheduled_indexing.json +28 -0
  26. package/src/config/healthcheck_queries/last_scheduled_started_indexing.json +29 -0
  27. package/src/config/healthcheck_queries/last_scheduled_started_indexing_resp.json +41 -0
  28. package/src/config/healthcheck_queries/last_sync_task_since_last_start.json +36 -0
  29. package/src/config/healthcheck_queries/last_sync_task_since_last_start_resp.json +63 -0
  30. package/src/config/healthcheck_queries/latest_tasks_for_site.json +23 -0
  31. package/src/config/healthcheck_queries/latest_tasks_for_site_resp.json +70 -0
  32. package/src/config/healthcheck_queries/started_or_finished_site_since_last_started.json +35 -0
  33. package/src/config/healthcheck_queries/started_or_finished_site_since_last_started_resp.json +36 -0
  34. package/src/config/index.test.js +191 -0
  35. package/src/utils.test.js +435 -0
  36. package/.i18n.babel.config.js +0 -1
@@ -0,0 +1,41 @@
1
+ {
2
+ "took": 963,
3
+ "timed_out": false,
4
+ "_shards": {
5
+ "total": 1,
6
+ "successful": 1,
7
+ "skipped": 0,
8
+ "failed": 0
9
+ },
10
+ "hits": {
11
+ "total": {
12
+ "value": 624,
13
+ "relation": "eq"
14
+ },
15
+ "max_score": null,
16
+ "hits": [
17
+ {
18
+ "_index": "status_test_index",
19
+ "_id": "main_task_2023_09_26_12_50_13",
20
+ "_score": null,
21
+ "_source": {
22
+ "@version": "1",
23
+ "cluster": "main_task",
24
+ "start_time_ts": 1695732613000,
25
+ "docs_cnt": 92190,
26
+ "sites": ["test_site"],
27
+ "next_execution_date": "2023_09_26_12_55_00",
28
+ "next_execution_date_ts": 1695732900000,
29
+ "start_time": "2023_09_26_12_50_13",
30
+ "task_name": "scheduled",
31
+ "msg": "",
32
+ "index_name": "status_test_index",
33
+ "id": "main_task_2023_09_26_12_50_13",
34
+ "status": "Failed",
35
+ "@timestamp": "2023-09-26T12:50:13.450Z"
36
+ },
37
+ "sort": [1695732613000]
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "terms": {
7
+ "cluster.keyword": ["<site_name>"]
8
+ }
9
+ },
10
+ {
11
+ "terms": {
12
+ "status.keyword": ["Failed"]
13
+ }
14
+ },
15
+ {
16
+ "range": {
17
+ "start_time_ts": {
18
+ "gt": "<last_started>"
19
+ }
20
+ }
21
+ }
22
+ ],
23
+ "must_not": [],
24
+ "should": []
25
+ }
26
+ },
27
+ "from": 0,
28
+ "size": 10,
29
+ "sort": [],
30
+ "aggs": {}
31
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "match": {
7
+ "task_name.keyword": "scheduled"
8
+ }
9
+ },
10
+ {
11
+ "match": {
12
+ "status.keyword": "Started"
13
+ }
14
+ }
15
+ ],
16
+ "must_not": [],
17
+ "should": []
18
+ }
19
+ },
20
+ "from": 0,
21
+ "size": 1,
22
+ "sort": [
23
+ {
24
+ "start_time_ts": "desc"
25
+ }
26
+ ],
27
+ "aggs": {}
28
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "match": {
7
+ "task_name.keyword": "scheduled"
8
+ }
9
+ },
10
+ {
11
+ "match": {
12
+ "status.keyword": "Started"
13
+ }
14
+ }
15
+ ],
16
+ "must_not": [],
17
+ "should": []
18
+ }
19
+ },
20
+ "from": 0,
21
+ "size": 1,
22
+ "sort": [
23
+ {
24
+ "start_time_ts": "desc"
25
+ }
26
+ ],
27
+ "aggs": {},
28
+ "index": "<index_name>"
29
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "took": 963,
3
+ "timed_out": false,
4
+ "_shards": {
5
+ "total": 1,
6
+ "successful": 1,
7
+ "skipped": 0,
8
+ "failed": 0
9
+ },
10
+ "hits": {
11
+ "total": {
12
+ "value": 624,
13
+ "relation": "eq"
14
+ },
15
+ "max_score": null,
16
+ "hits": [
17
+ {
18
+ "_index": "status_test_index",
19
+ "_id": "main_task_2023_09_26_12_50_13",
20
+ "_score": null,
21
+ "_source": {
22
+ "@version": "1",
23
+ "cluster": "main_task",
24
+ "start_time_ts": 1695732613000,
25
+ "docs_cnt": 92190,
26
+ "sites": ["test_site"],
27
+ "next_execution_date": "2023_09_26_12_55_00",
28
+ "next_execution_date_ts": 1695732900000,
29
+ "start_time": "2023_09_26_12_50_13",
30
+ "task_name": "scheduled",
31
+ "msg": "",
32
+ "index_name": "status_test_index",
33
+ "id": "main_task_2023_09_26_12_50_13",
34
+ "status": "Started",
35
+ "@timestamp": "2023-09-26T12:50:13.450Z"
36
+ },
37
+ "sort": [1695732613000]
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "match": {
7
+ "task_name.keyword": ""
8
+ }
9
+ },
10
+ {
11
+ "match": {
12
+ "cluster.keyword": "main_task"
13
+ }
14
+ },
15
+ {
16
+ "range": {
17
+ "start_time_ts": {
18
+ "gt": "<last_started>"
19
+ }
20
+ }
21
+ }
22
+ ],
23
+ "must_not": [],
24
+ "should": []
25
+ }
26
+ },
27
+ "from": 0,
28
+ "size": 10,
29
+ "sort": [
30
+ {
31
+ "start_time_ts": "desc"
32
+ }
33
+ ],
34
+ "aggs": {},
35
+ "index": "<index_name>"
36
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "took": 28,
3
+ "timed_out": false,
4
+ "_shards": {
5
+ "total": 1,
6
+ "successful": 1,
7
+ "skipped": 0,
8
+ "failed": 0
9
+ },
10
+ "hits": {
11
+ "total": {
12
+ "value": 288,
13
+ "relation": "eq"
14
+ },
15
+ "max_score": null,
16
+ "hits": [
17
+ {
18
+ "_index": "status_test_index",
19
+ "_id": "main_task_2023_09_26_13_01_12",
20
+ "_score": null,
21
+ "_source": {
22
+ "@version": "1",
23
+ "cluster": "main_task",
24
+ "start_time_ts": 1695733272000,
25
+ "docs_cnt": 242,
26
+ "sites": ["test_site1", "test_site2"],
27
+ "next_execution_date": "2023_09_26_14_00_00",
28
+ "next_execution_date_ts": 1695736800000,
29
+ "start_time": "2023_09_26_13_01_12",
30
+ "task_name": "",
31
+ "msg": "",
32
+ "index_name": "status_test_index",
33
+ "id": "main_task_2023_09_26_13_01_12",
34
+ "status": "Started",
35
+ "@timestamp": "2023-09-26T13:01:12.601Z"
36
+ },
37
+ "sort": [1695733272000]
38
+ },
39
+ {
40
+ "_index": "status_test_index",
41
+ "_id": "main_task_2023_09_26_12_00_24",
42
+ "_score": null,
43
+ "_source": {
44
+ "@version": "1",
45
+ "cluster": "main_task",
46
+ "start_time_ts": 1695729624000,
47
+ "docs_cnt": 242,
48
+ "sites": ["test_site1", "test_site2"],
49
+ "next_execution_date": "2023_09_26_13_00_00",
50
+ "next_execution_date_ts": 1695733200000,
51
+ "start_time": "2023_09_26_12_00_24",
52
+ "task_name": "",
53
+ "msg": "",
54
+ "index_name": "status_test_index",
55
+ "id": "main_task_2023_09_26_12_00_24",
56
+ "status": "Started",
57
+ "@timestamp": "2023-09-26T12:00:24.187Z"
58
+ },
59
+ "sort": [1695729624000]
60
+ }
61
+ ]
62
+ }
63
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "terms": {
7
+ "cluster.keyword": ["<site_name>"]
8
+ }
9
+ }
10
+ ],
11
+ "must_not": [],
12
+ "should": []
13
+ }
14
+ },
15
+ "from": 0,
16
+ "size": "<THRESHOLD_WARNING>",
17
+ "sort": [
18
+ {
19
+ "start_time_ts": "desc"
20
+ }
21
+ ],
22
+ "index": "<index_name>"
23
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "took": 63,
3
+ "timed_out": false,
4
+ "_shards": {
5
+ "total": 1,
6
+ "successful": 1,
7
+ "skipped": 0,
8
+ "failed": 0
9
+ },
10
+ "hits": {
11
+ "total": {
12
+ "value": 288,
13
+ "relation": "eq"
14
+ },
15
+ "max_score": null,
16
+ "hits": [
17
+ {
18
+ "_index": "status_test_index",
19
+ "_id": "test_site_2023_09_26_13_02_28",
20
+ "_score": null,
21
+ "_source": {
22
+ "@version": "1",
23
+ "@timestamp": "2023-09-26T13:04:34.337Z",
24
+ "cluster": "test_site",
25
+ "start_time_ts": 1695733348000,
26
+ "msg": "",
27
+ "index_name": "status_test_index",
28
+ "id": "test_site_2023_09_26_13_02_28",
29
+ "start_time": "2023_09_26_13_02_28",
30
+ "status": "Finished"
31
+ },
32
+ "sort": [1695733348000]
33
+ },
34
+ {
35
+ "_index": "status_test_index",
36
+ "_id": "test_site_2023_09_26_12_02_32",
37
+ "_score": null,
38
+ "_source": {
39
+ "@version": "1",
40
+ "@timestamp": "2023-09-26T12:04:57.781Z",
41
+ "cluster": "test_site",
42
+ "start_time_ts": 1695729752000,
43
+ "msg": "",
44
+ "index_name": "test_site",
45
+ "id": "test_site_2023_09_26_12_02_32",
46
+ "start_time": "2023_09_26_12_02_32",
47
+ "status": "Finished"
48
+ },
49
+ "sort": [1695729752000]
50
+ },
51
+ {
52
+ "_index": "status_test_index",
53
+ "_id": "test_site_2023_09_26_11_02_41",
54
+ "_score": null,
55
+ "_source": {
56
+ "@version": "1",
57
+ "@timestamp": "2023-09-26T11:04:21.093Z",
58
+ "cluster": "test_site",
59
+ "start_time_ts": 1695726161000,
60
+ "msg": "",
61
+ "index_name": "status_test_index",
62
+ "id": "test_site_2023_09_26_11_02_41",
63
+ "start_time": "2023_09_26_11_02_41",
64
+ "status": "Finished"
65
+ },
66
+ "sort": [1695726161000]
67
+ }
68
+ ]
69
+ }
70
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "query": {
3
+ "bool": {
4
+ "must": [
5
+ {
6
+ "terms": {
7
+ "cluster.keyword": ["<site_name>"]
8
+ }
9
+ },
10
+ {
11
+ "terms": {
12
+ "status.keyword": ["Started", "Finished"]
13
+ }
14
+ },
15
+ {
16
+ "range": {
17
+ "start_time_ts": {
18
+ "gt": "<last_started>"
19
+ }
20
+ }
21
+ }
22
+ ],
23
+ "must_not": [],
24
+ "should": []
25
+ }
26
+ },
27
+ "from": 0,
28
+ "size": 1,
29
+ "sort": [
30
+ {
31
+ "start_time_ts": "desc"
32
+ }
33
+ ],
34
+ "index": "<index_name>"
35
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "took": 18,
3
+ "timed_out": false,
4
+ "_shards": {
5
+ "total": 1,
6
+ "successful": 1,
7
+ "skipped": 0,
8
+ "failed": 0
9
+ },
10
+ "hits": {
11
+ "total": {
12
+ "value": 271,
13
+ "relation": "eq"
14
+ },
15
+ "max_score": null,
16
+ "hits": [
17
+ {
18
+ "_index": "status_test_index",
19
+ "_id": "test_site_2023_09_26_13_02_28",
20
+ "_score": null,
21
+ "_source": {
22
+ "@version": "1",
23
+ "@timestamp": "2023-09-26T13:04:34.337Z",
24
+ "cluster": "test_site",
25
+ "start_time_ts": 1695733348000,
26
+ "msg": "",
27
+ "index_name": "status_test_index",
28
+ "id": "test_site_2023_09_26_13_02_28",
29
+ "start_time": "2023_09_26_13_02_28",
30
+ "status": "Finished"
31
+ },
32
+ "sort": [1695733348000]
33
+ }
34
+ ]
35
+ }
36
+ }
@@ -0,0 +1,191 @@
1
+ import install from './index';
2
+ import globalSearchConfig from './global-search-config.js';
3
+
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ const SLOTS = [
7
+ 'aboveSearchInput',
8
+ 'belowSearchInput',
9
+ 'aboveResults',
10
+ 'belowResults',
11
+ ];
12
+
13
+ jest.mock('@eeacms/search', () => ({
14
+ runRequest: jest.fn(),
15
+ booleanFacet: jest.fn(),
16
+ multiTermFacet: jest.fn(),
17
+ makeRange: jest.fn(),
18
+ histogramFacet: jest.fn(),
19
+ fixedRangeFacet: jest.fn(),
20
+ dateRangeFacet: jest.fn(),
21
+ mergeConfig: jest.fn((config) => config),
22
+ suiFacet: jest.fn(),
23
+ isFilterValueDefaultValue: jest.fn(),
24
+ SLOTS: SLOTS,
25
+ }));
26
+
27
+ jest.mock('./facets', () => ({
28
+ facets: [],
29
+ }));
30
+
31
+ jest.mock('./clusters', () => ({
32
+ typesForClustersOptionsFilter: jest.fn(),
33
+ clusters: {
34
+ name: 'op_cluster',
35
+ field: 'objectProvides',
36
+ clusters: [
37
+ {
38
+ name: 'News',
39
+ icon: { name: 'bullhorn' },
40
+ values: ['News', 'Article'],
41
+ defaultResultView: 'horizontalCard',
42
+ },
43
+ {
44
+ name: 'Publications',
45
+ icon: { name: 'book' },
46
+ values: [
47
+ 'Report',
48
+ 'Indicator',
49
+ 'Briefing',
50
+ 'Topic page',
51
+ 'Country fact sheet',
52
+ ],
53
+ defaultResultView: 'horizontalCard',
54
+ },
55
+ ],
56
+ },
57
+ }));
58
+
59
+ describe('getActiveFilters', () => {
60
+ it('should return an array with issued.date', () => {
61
+ const filters = [
62
+ { field: 'foo' },
63
+ { field: 'issued.date', values: ['All time'] },
64
+ { field: 'issued.date', values: ['test'] },
65
+ ];
66
+ const appConfig = {
67
+ searchui: {
68
+ default: {},
69
+ minimal: {
70
+ facets: [],
71
+ },
72
+ },
73
+ resolve: {
74
+ getGlobalSearchhealthcheck: 'global',
75
+ },
76
+ facets: [
77
+ {
78
+ isFilter: true,
79
+ showInFacetsList: undefined,
80
+ field: 'issued.date',
81
+ },
82
+ ],
83
+ };
84
+ const result = install(appConfig);
85
+ const activeFilters = result.resolve.getGlobalSearchActiveFilters(
86
+ filters,
87
+ appConfig,
88
+ );
89
+ expect(activeFilters).toEqual([{ field: 'issued.date', values: ['test'] }]);
90
+ });
91
+
92
+ it('should return an array with provided field name', () => {
93
+ const filters = [{ field: 'foo' }];
94
+ const appConfig = {
95
+ searchui: {
96
+ default: {},
97
+ minimal: {
98
+ facets: [],
99
+ },
100
+ },
101
+ resolve: {
102
+ getGlobalSearchhealthcheck: 'global',
103
+ },
104
+ facets: [
105
+ {
106
+ isFilter: false,
107
+ showInFacetsList: true,
108
+ field: 'foo',
109
+ },
110
+ ],
111
+ };
112
+ const result = install(appConfig);
113
+ const activeFilters = result.resolve.getGlobalSearchActiveFilters(
114
+ filters,
115
+ appConfig,
116
+ );
117
+ expect(activeFilters).toEqual([
118
+ {
119
+ field: 'foo',
120
+ },
121
+ ]);
122
+ });
123
+
124
+ it('should return an empty array if no facets are provided', () => {
125
+ const filters = [{ field: 'foo' }];
126
+ const appConfig = {
127
+ searchui: {
128
+ default: {},
129
+ minimal: {
130
+ facets: [],
131
+ },
132
+ },
133
+ resolve: {
134
+ getGlobalSearchhealthcheck: 'global',
135
+ },
136
+ facets: undefined,
137
+ };
138
+ const result = install(appConfig);
139
+ const activeFilters = result.resolve.getGlobalSearchActiveFilters(
140
+ filters,
141
+ appConfig,
142
+ );
143
+ expect(activeFilters).toEqual([]);
144
+ });
145
+
146
+ it('should return an array with provided field name and showInFacetsList is undefined', () => {
147
+ const filters = [{ field: 'foo' }];
148
+ const appConfig = {
149
+ searchui: {
150
+ default: {},
151
+ minimal: {
152
+ facets: [],
153
+ },
154
+ },
155
+ resolve: {
156
+ getGlobalSearchhealthcheck: 'global',
157
+ },
158
+ facets: [
159
+ {
160
+ isFilter: false,
161
+ showInFacetsList: undefined,
162
+ field: 'foo',
163
+ },
164
+ ],
165
+ };
166
+ const result = install(appConfig);
167
+ const activeFilters = result.resolve.getGlobalSearchActiveFilters(
168
+ filters,
169
+ appConfig,
170
+ );
171
+ expect(activeFilters).toEqual([
172
+ {
173
+ field: 'foo',
174
+ },
175
+ ]);
176
+ });
177
+ });
178
+
179
+ describe('getGlobalsearchConfig', () => {
180
+ it('should have customized permanent filters for globalsearch', () => {
181
+ const index = globalSearchConfig.permanentFilters.findIndex(
182
+ (f) => f.id === 'constantScore',
183
+ );
184
+ const constantScore = globalSearchConfig.permanentFilters[index]();
185
+ expect(constantScore.constant_score.filter.bool['must_not']).toEqual({
186
+ exists: {
187
+ field: 'exclude_from_globalsearch',
188
+ },
189
+ });
190
+ });
191
+ });