@eeacms/volto-bise-policy 1.3.5 → 1.3.6
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 +28 -12
- package/package.json +2 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerEdit.jsx +22 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.jsx +17 -12
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.test.jsx +1 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.jsx +59 -13
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyListing.jsx +28 -16
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyListing.test.jsx +54 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +68 -35
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.test.jsx +37 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +41 -39
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.test.jsx +39 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/index.js +2 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/schema.js +19 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +33 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +171 -93
- package/src/components/manage/Blocks/CaseStudyExplorer/utils.test.js +96 -1
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import './mockJsdom';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FALLBACK_STATUS_COLOR,
|
|
5
|
+
getFeatures,
|
|
6
|
+
getStatusColor,
|
|
7
|
+
filterCases,
|
|
8
|
+
getFilters,
|
|
9
|
+
} from './utils';
|
|
4
10
|
|
|
5
11
|
describe('utils.js', () => {
|
|
12
|
+
test('maps exact statuses and unknown statuses to colors', () => {
|
|
13
|
+
expect(getStatusColor('planned')).toBe('#006bb8');
|
|
14
|
+
expect(getStatusColor('ongoing')).toBe('#ff9933');
|
|
15
|
+
expect(getStatusColor('completed')).toBe('#00a390');
|
|
16
|
+
expect(getStatusColor('Planned')).toBe(FALLBACK_STATUS_COLOR);
|
|
17
|
+
expect(getStatusColor('future')).toBe(FALLBACK_STATUS_COLOR);
|
|
18
|
+
});
|
|
19
|
+
|
|
6
20
|
const mockCases = [
|
|
7
21
|
{
|
|
8
22
|
geometry: { coordinates: [0, 0] },
|
|
@@ -70,6 +84,83 @@ describe('utils.js', () => {
|
|
|
70
84
|
expect(mockCasesFiltered).toStrictEqual([]);
|
|
71
85
|
});
|
|
72
86
|
|
|
87
|
+
test('filterCases treats search input as literal text (ReDoS-safe)', () => {
|
|
88
|
+
const cases = [
|
|
89
|
+
{
|
|
90
|
+
geometry: { coordinates: [0, 0] },
|
|
91
|
+
properties: {
|
|
92
|
+
title: 'the river project (R1)',
|
|
93
|
+
description: 'a aaa aaaa aaaaa b',
|
|
94
|
+
url: '/the-river-project-r1',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const noFilters = {
|
|
99
|
+
measures_implemented: [],
|
|
100
|
+
typology_of_measures: [],
|
|
101
|
+
current_status: [],
|
|
102
|
+
habitat_ecosystem_type: [],
|
|
103
|
+
nrr_article: [],
|
|
104
|
+
scale_of_planning: [],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Malformed regex input must not throw (previously: SyntaxError)
|
|
108
|
+
expect(() => filterCases(cases, noFilters, null, '(')).not.toThrow();
|
|
109
|
+
// Regex metacharacters are matched literally, not interpreted
|
|
110
|
+
expect(() => filterCases(cases, noFilters, null, '(a+)+$')).not.toThrow();
|
|
111
|
+
expect(filterCases(cases, noFilters, null, '(a+)+$')).toHaveLength(0);
|
|
112
|
+
expect(filterCases(cases, noFilters, null, '(r1')).toHaveLength(1);
|
|
113
|
+
// Whole-word semantics are preserved
|
|
114
|
+
expect(filterCases(cases, noFilters, null, 'rive')).toHaveLength(0);
|
|
115
|
+
expect(filterCases(cases, noFilters, null, 'river')).toHaveLength(1);
|
|
116
|
+
// Case-insensitive
|
|
117
|
+
expect(filterCases(cases, noFilters, null, 'R1')).toHaveLength(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('filters new scalar and multi-value fields', () => {
|
|
121
|
+
const cases = [
|
|
122
|
+
{
|
|
123
|
+
geometry: { coordinates: [0, 0] },
|
|
124
|
+
properties: {
|
|
125
|
+
title: 'planned river case',
|
|
126
|
+
description: '',
|
|
127
|
+
url: '/planned-river-case',
|
|
128
|
+
current_status: 'planned',
|
|
129
|
+
ecosystem_typology: ['River', 'Wetland'],
|
|
130
|
+
nrr_article: [{ id: 'article-1', title: 'Article 1' }],
|
|
131
|
+
scale_of_planning: 'Regional',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
geometry: { coordinates: [0, 0] },
|
|
136
|
+
properties: {
|
|
137
|
+
title: 'future case',
|
|
138
|
+
description: '',
|
|
139
|
+
url: '/future-case',
|
|
140
|
+
current_status: 'Future',
|
|
141
|
+
ecosystem_typology: ['Forest'],
|
|
142
|
+
nrr_article: ['article-2'],
|
|
143
|
+
scale_of_planning: 'National',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
expect(
|
|
149
|
+
filterCases(cases, {
|
|
150
|
+
measures_implemented: [],
|
|
151
|
+
typology_of_measures: [],
|
|
152
|
+
current_status: ['planned'],
|
|
153
|
+
habitat_ecosystem_type: ['River'],
|
|
154
|
+
nrr_article: ['article-1'],
|
|
155
|
+
scale_of_planning: ['Regional'],
|
|
156
|
+
}),
|
|
157
|
+
).toHaveLength(1);
|
|
158
|
+
expect(getFilters(cases).nrr_article).toEqual({
|
|
159
|
+
'article-1': 'Article 1',
|
|
160
|
+
'article-2': 'article-2',
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
73
164
|
test('getFilters', () => {
|
|
74
165
|
const mockCasesObject = mockCases.reduce((acc, item, index) => {
|
|
75
166
|
acc[index] = item;
|
|
@@ -83,6 +174,10 @@ describe('utils.js', () => {
|
|
|
83
174
|
typology_of_measures: {
|
|
84
175
|
testsector: 'testsector',
|
|
85
176
|
},
|
|
177
|
+
current_status: {},
|
|
178
|
+
habitat_ecosystem_type: {},
|
|
179
|
+
nrr_article: {},
|
|
180
|
+
scale_of_planning: {},
|
|
86
181
|
});
|
|
87
182
|
});
|
|
88
183
|
});
|