@eeacms/volto-eea-website-theme 3.12.0 → 3.14.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 +10 -0
- package/jest-addon.config.js +421 -6
- package/package.json +2 -1
- package/src/components/theme/Widgets/NavigationBehaviorWidget.jsx +17 -25
- package/src/components/theme/Widgets/NavigationBehaviorWidget.test.jsx +114 -0
- package/src/components/theme/Widgets/UserSelectWidget.test.jsx +330 -1
- package/src/config.js +6 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +15 -9
- package/src/helpers/setupPrintView.js +161 -27
- package/src/helpers/setupPrintView.test.js +535 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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
|
+
### [3.14.0](https://github.com/eea/volto-eea-website-theme/compare/3.13.0...3.14.0) - 6 November 2025
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Bump version from 3.13.0 to 3.14.0 [David Ichim - [`7e37c1d`](https://github.com/eea/volto-eea-website-theme/commit/7e37c1d97ab6037cb72444ace400f8b653334cba)]
|
|
12
|
+
### [3.13.0](https://github.com/eea/volto-eea-website-theme/compare/3.12.0...3.13.0) - 4 November 2025
|
|
13
|
+
|
|
14
|
+
#### :hammer_and_wrench: Others
|
|
15
|
+
|
|
16
|
+
- Bump version from 3.12.1 to 3.13.0 [David Ichim - [`c182fea`](https://github.com/eea/volto-eea-website-theme/commit/c182fea83aad1c0b224c37287a5c2935a2e893d0)]
|
|
7
17
|
### [3.12.0](https://github.com/eea/volto-eea-website-theme/compare/3.11.0...3.12.0) - 4 November 2025
|
|
8
18
|
|
|
9
19
|
#### :bug: Bug Fixes
|
package/jest-addon.config.js
CHANGED
|
@@ -1,10 +1,415 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Generic Jest configuration for Volto addons
|
|
3
|
+
*
|
|
4
|
+
* This configuration automatically:
|
|
5
|
+
* - Detects the addon name from the config file path
|
|
6
|
+
* - Configures test coverage to focus on the specific test path
|
|
7
|
+
* - Handles different ways of specifying test paths:
|
|
8
|
+
* - Full paths like src/addons/addon-name/src/components
|
|
9
|
+
* - Just filenames like Component.test.jsx
|
|
10
|
+
* - Just directory names like components
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* RAZZLE_JEST_CONFIG=src/addons/addon-name/jest-addon.config.js CI=true yarn test [test-path] --collectCoverage
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
require('dotenv').config({ path: __dirname + '/.env' });
|
|
17
|
+
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const fg = require('fast-glob');
|
|
21
|
+
|
|
22
|
+
// Get the addon name from the current file path
|
|
23
|
+
const pathParts = __filename.split(path.sep);
|
|
24
|
+
const addonsIdx = pathParts.lastIndexOf('addons');
|
|
25
|
+
const addonName =
|
|
26
|
+
addonsIdx !== -1 && addonsIdx < pathParts.length - 1
|
|
27
|
+
? pathParts[addonsIdx + 1]
|
|
28
|
+
: path.basename(path.dirname(__filename)); // Fallback to folder name
|
|
29
|
+
const addonBasePath = `src/addons/${addonName}/src`;
|
|
30
|
+
|
|
31
|
+
// --- Performance caches ---
|
|
32
|
+
const fileSearchCache = new Map();
|
|
33
|
+
const dirSearchCache = new Map();
|
|
34
|
+
const dirListingCache = new Map();
|
|
35
|
+
const statCache = new Map();
|
|
36
|
+
const implementationCache = new Map();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Cached fs.statSync wrapper to avoid redundant filesystem calls
|
|
40
|
+
* @param {string} p
|
|
41
|
+
* @returns {fs.Stats|null}
|
|
42
|
+
*/
|
|
43
|
+
const getStatSync = (p) => {
|
|
44
|
+
if (statCache.has(p)) return statCache.get(p);
|
|
45
|
+
try {
|
|
46
|
+
const s = fs.statSync(p);
|
|
47
|
+
statCache.set(p, s);
|
|
48
|
+
return s;
|
|
49
|
+
} catch {
|
|
50
|
+
statCache.set(p, null);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find files that match a specific pattern using fast-glob
|
|
57
|
+
* @param {string} baseDir - The base directory to search in
|
|
58
|
+
* @param {string} fileName - The name of the file to find
|
|
59
|
+
* @param {string} [pathPattern=''] - Optional path pattern to filter results
|
|
60
|
+
* @returns {string[]} - Array of matching file paths
|
|
61
|
+
*/
|
|
62
|
+
const findFilesWithPattern = (baseDir, fileName, pathPattern = '') => {
|
|
63
|
+
const cacheKey = `${baseDir}|${fileName}|${pathPattern}`;
|
|
64
|
+
if (fileSearchCache.has(cacheKey)) {
|
|
65
|
+
return fileSearchCache.get(cacheKey);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let files = [];
|
|
69
|
+
try {
|
|
70
|
+
const patterns = fileName
|
|
71
|
+
? [`${baseDir}/**/${fileName}`]
|
|
72
|
+
: [`${baseDir}/**/*.{js,jsx,ts,tsx}`];
|
|
73
|
+
|
|
74
|
+
files = fg.sync(patterns, { onlyFiles: true });
|
|
75
|
+
|
|
76
|
+
if (pathPattern) {
|
|
77
|
+
files = files.filter((file) => file.includes(pathPattern));
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
files = [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fileSearchCache.set(cacheKey, files);
|
|
84
|
+
return files;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Find directories that match a specific pattern using fast-glob
|
|
89
|
+
* @param {string} baseDir - The base directory to search in
|
|
90
|
+
* @param {string} dirName - The name of the directory to find
|
|
91
|
+
* @param {string} [pathPattern=''] - Optional path pattern to filter results
|
|
92
|
+
* @returns {string[]} - Array of matching directory paths
|
|
93
|
+
*/
|
|
94
|
+
const findDirsWithPattern = (baseDir, dirName, pathPattern = '') => {
|
|
95
|
+
const cacheKey = `${baseDir}|${dirName}|${pathPattern}`;
|
|
96
|
+
if (dirSearchCache.has(cacheKey)) {
|
|
97
|
+
return dirSearchCache.get(cacheKey);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let dirs = [];
|
|
101
|
+
try {
|
|
102
|
+
const patterns = dirName
|
|
103
|
+
? [`${baseDir}/**/${dirName}`]
|
|
104
|
+
: [`${baseDir}/**/`];
|
|
105
|
+
|
|
106
|
+
dirs = fg.sync(patterns, { onlyDirectories: true });
|
|
107
|
+
|
|
108
|
+
if (pathPattern) {
|
|
109
|
+
dirs = dirs.filter((dir) => dir.includes(pathPattern));
|
|
110
|
+
}
|
|
111
|
+
} catch {
|
|
112
|
+
dirs = [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
dirSearchCache.set(cacheKey, dirs);
|
|
116
|
+
return dirs;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Find files or directories in the addon using fast-glob
|
|
121
|
+
* @param {string} name - The name to search for
|
|
122
|
+
* @param {string} type - The type of item to find ('f' for files, 'd' for directories)
|
|
123
|
+
* @param {string} [additionalOptions=''] - Additional options for flexible path matching
|
|
124
|
+
* @returns {string|null} - The path of the found item or null if not found
|
|
125
|
+
*/
|
|
126
|
+
const findInAddon = (name, type, additionalOptions = '') => {
|
|
127
|
+
const isFile = type === 'f';
|
|
128
|
+
const isDirectory = type === 'd';
|
|
129
|
+
const isFlexiblePathMatch = additionalOptions.includes('-path');
|
|
130
|
+
|
|
131
|
+
let pathPattern = '';
|
|
132
|
+
if (isFlexiblePathMatch) {
|
|
133
|
+
const match = additionalOptions.match(/-path "([^"]+)"/);
|
|
134
|
+
if (match && match[1]) {
|
|
135
|
+
pathPattern = match[1].replace(/\*/g, '');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
let results = [];
|
|
141
|
+
if (isFile) {
|
|
142
|
+
results = findFilesWithPattern(addonBasePath, name, pathPattern);
|
|
143
|
+
} else if (isDirectory) {
|
|
144
|
+
results = findDirsWithPattern(addonBasePath, name, pathPattern);
|
|
145
|
+
}
|
|
146
|
+
return results.length > 0 ? results[0] : null;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Find the implementation file for a test file
|
|
154
|
+
* @param {string} testPath - Path to the test file
|
|
155
|
+
* @returns {string|null} - Path to the implementation file or null if not found
|
|
156
|
+
*/
|
|
157
|
+
const findImplementationFile = (testPath) => {
|
|
158
|
+
if (implementationCache.has(testPath)) {
|
|
159
|
+
return implementationCache.get(testPath);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!fs.existsSync(testPath)) {
|
|
163
|
+
implementationCache.set(testPath, null);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const dirPath = path.dirname(testPath);
|
|
168
|
+
const fileName = path.basename(testPath);
|
|
169
|
+
|
|
170
|
+
// Regex for common test file patterns (e.g., .test.js, .spec.ts)
|
|
171
|
+
const TEST_OR_SPEC_FILE_REGEX = /\.(test|spec)\.[jt]sx?$/;
|
|
172
|
+
|
|
173
|
+
if (!TEST_OR_SPEC_FILE_REGEX.test(fileName)) {
|
|
174
|
+
implementationCache.set(testPath, null);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const baseFileName = path
|
|
179
|
+
.basename(fileName, path.extname(fileName))
|
|
180
|
+
.replace(/\.(test|spec)$/, ''); // Remove .test or .spec
|
|
181
|
+
|
|
182
|
+
let dirFiles = dirListingCache.get(dirPath);
|
|
183
|
+
if (!dirFiles) {
|
|
184
|
+
dirFiles = fs.readdirSync(dirPath);
|
|
185
|
+
dirListingCache.set(dirPath, dirFiles);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const exactMatch = dirFiles.find((file) => {
|
|
189
|
+
const fileBaseName = path.basename(file, path.extname(file));
|
|
190
|
+
return (
|
|
191
|
+
fileBaseName === baseFileName && !TEST_OR_SPEC_FILE_REGEX.test(file) // Ensure it's not another test/spec file
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (exactMatch) {
|
|
196
|
+
const result = `${dirPath}/${exactMatch}`;
|
|
197
|
+
implementationCache.set(testPath, result);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const similarMatch = dirFiles.find((file) => {
|
|
202
|
+
if (
|
|
203
|
+
TEST_OR_SPEC_FILE_REGEX.test(file) ||
|
|
204
|
+
(getStatSync(`${dirPath}/${file}`)?.isDirectory() ?? false)
|
|
205
|
+
) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const fileBaseName = path.basename(file, path.extname(file));
|
|
209
|
+
return (
|
|
210
|
+
fileBaseName.toLowerCase().includes(baseFileName.toLowerCase()) ||
|
|
211
|
+
baseFileName.toLowerCase().includes(fileBaseName.toLowerCase())
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (similarMatch) {
|
|
216
|
+
const result = `${dirPath}/${similarMatch}`;
|
|
217
|
+
implementationCache.set(testPath, result);
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
implementationCache.set(testPath, null);
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the test path from command line arguments
|
|
227
|
+
* @returns {string|null} - The resolved test path or null if not found
|
|
228
|
+
*/
|
|
229
|
+
const getTestPath = () => {
|
|
230
|
+
const args = process.argv;
|
|
231
|
+
let testPath = null;
|
|
232
|
+
const TEST_FILE_REGEX = /\.test\.[jt]sx?$/; // Matches .test.js, .test.jsx, .test.ts, .test.tsx
|
|
233
|
+
|
|
234
|
+
testPath = args.find(
|
|
235
|
+
(arg) =>
|
|
236
|
+
arg.includes(addonName) &&
|
|
237
|
+
!arg.startsWith('--') &&
|
|
238
|
+
arg !== 'test' &&
|
|
239
|
+
arg !== 'node',
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
if (!testPath) {
|
|
243
|
+
const testIndex = args.findIndex((arg) => arg === 'test');
|
|
244
|
+
if (testIndex !== -1 && testIndex < args.length - 1) {
|
|
245
|
+
const nextArg = args[testIndex + 1];
|
|
246
|
+
if (!nextArg.startsWith('--')) {
|
|
247
|
+
testPath = nextArg;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!testPath) {
|
|
253
|
+
testPath = args.find((arg) => TEST_FILE_REGEX.test(arg));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (!testPath) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (!testPath.includes(path.sep)) {
|
|
261
|
+
if (TEST_FILE_REGEX.test(testPath)) {
|
|
262
|
+
const foundTestFile = findInAddon(testPath, 'f');
|
|
263
|
+
if (foundTestFile) {
|
|
264
|
+
return foundTestFile;
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
const foundDir = findInAddon(testPath, 'd');
|
|
268
|
+
if (foundDir) {
|
|
269
|
+
return foundDir;
|
|
270
|
+
}
|
|
271
|
+
const flexibleDir = findInAddon(testPath, 'd', `-path "*${testPath}*"`);
|
|
272
|
+
if (flexibleDir) {
|
|
273
|
+
return flexibleDir;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} else if (
|
|
277
|
+
TEST_FILE_REGEX.test(testPath) && // Check if it looks like a test file path
|
|
278
|
+
!testPath.startsWith('src/addons/')
|
|
279
|
+
) {
|
|
280
|
+
const testFileName = path.basename(testPath);
|
|
281
|
+
const foundTestFile = findInAddon(testFileName, 'f');
|
|
282
|
+
if (foundTestFile) {
|
|
283
|
+
const relativePath = path.dirname(testPath);
|
|
284
|
+
if (foundTestFile.includes(relativePath)) {
|
|
285
|
+
return foundTestFile;
|
|
286
|
+
}
|
|
287
|
+
const similarFiles = findFilesWithPattern(
|
|
288
|
+
addonBasePath,
|
|
289
|
+
testFileName,
|
|
290
|
+
relativePath,
|
|
291
|
+
);
|
|
292
|
+
if (similarFiles && similarFiles.length > 0) {
|
|
293
|
+
return similarFiles[0];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (
|
|
299
|
+
!path
|
|
300
|
+
.normalize(testPath)
|
|
301
|
+
.startsWith(path.join('src', 'addons', addonName, 'src')) &&
|
|
302
|
+
!path.isAbsolute(testPath) // Use path.isAbsolute for robust check
|
|
303
|
+
) {
|
|
304
|
+
testPath = path.join(addonBasePath, testPath); // Use path.join for OS-agnostic paths
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (fs.existsSync(testPath)) {
|
|
308
|
+
return testPath;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const pathWithoutTrailingSlash = testPath.endsWith(path.sep)
|
|
312
|
+
? testPath.slice(0, -1)
|
|
313
|
+
: null;
|
|
314
|
+
if (pathWithoutTrailingSlash && fs.existsSync(pathWithoutTrailingSlash)) {
|
|
315
|
+
return pathWithoutTrailingSlash;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const pathWithTrailingSlash = !testPath.endsWith(path.sep)
|
|
319
|
+
? testPath + path.sep
|
|
320
|
+
: null;
|
|
321
|
+
if (pathWithTrailingSlash && fs.existsSync(pathWithTrailingSlash)) {
|
|
322
|
+
// Generally, return paths without trailing slashes for consistency,
|
|
323
|
+
// unless it's specifically needed for a directory that only exists with it (rare).
|
|
324
|
+
return testPath;
|
|
325
|
+
}
|
|
326
|
+
return testPath; // Return the original path if no variations exist
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Determine collectCoverageFrom patterns based on test path
|
|
331
|
+
* @returns {string[]} - Array of coverage patterns
|
|
332
|
+
*/
|
|
333
|
+
const getCoveragePatterns = () => {
|
|
334
|
+
const excludePatterns = [
|
|
335
|
+
'!src/**/*.d.ts',
|
|
336
|
+
'!**/*.test.{js,jsx,ts,tsx}',
|
|
337
|
+
'!**/*.stories.{js,jsx,ts,tsx}',
|
|
338
|
+
'!**/*.spec.{js,jsx,ts,tsx}',
|
|
339
|
+
];
|
|
340
|
+
|
|
341
|
+
const defaultPatterns = [
|
|
342
|
+
`${addonBasePath}/**/*.{js,jsx,ts,tsx}`,
|
|
343
|
+
...excludePatterns,
|
|
344
|
+
];
|
|
345
|
+
|
|
346
|
+
const ANY_SCRIPT_FILE_REGEX = /\.[jt]sx?$/;
|
|
347
|
+
|
|
348
|
+
const directoryArg = process.argv.find(
|
|
349
|
+
(arg) =>
|
|
350
|
+
!arg.includes(path.sep) &&
|
|
351
|
+
!arg.startsWith('--') &&
|
|
352
|
+
arg !== 'test' &&
|
|
353
|
+
arg !== 'node' &&
|
|
354
|
+
!ANY_SCRIPT_FILE_REGEX.test(arg) &&
|
|
355
|
+
![
|
|
356
|
+
'yarn',
|
|
357
|
+
'npm',
|
|
358
|
+
'npx',
|
|
359
|
+
'collectCoverage',
|
|
360
|
+
'CI',
|
|
361
|
+
'RAZZLE_JEST_CONFIG',
|
|
362
|
+
].some(
|
|
363
|
+
(reserved) =>
|
|
364
|
+
arg === reserved || arg.startsWith(reserved.split('=')[0] + '='),
|
|
365
|
+
) &&
|
|
366
|
+
process.argv.indexOf(arg) >
|
|
367
|
+
process.argv.findIndex((item) => item === 'test'),
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
if (directoryArg) {
|
|
371
|
+
const foundDir = findInAddon(directoryArg, 'd');
|
|
372
|
+
if (foundDir) {
|
|
373
|
+
return [`${foundDir}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
let testPath = getTestPath();
|
|
378
|
+
|
|
379
|
+
if (!testPath) {
|
|
380
|
+
return defaultPatterns;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (testPath.endsWith(path.sep)) {
|
|
384
|
+
testPath = testPath.slice(0, -1);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const stats = getStatSync(testPath);
|
|
388
|
+
|
|
389
|
+
if (stats && stats.isFile()) {
|
|
390
|
+
const implFile = findImplementationFile(testPath);
|
|
391
|
+
if (implFile) {
|
|
392
|
+
return [implFile, '!src/**/*.d.ts'];
|
|
393
|
+
}
|
|
394
|
+
const dirPath = path.dirname(testPath);
|
|
395
|
+
return [`${dirPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
396
|
+
} else if (stats && stats.isDirectory()) {
|
|
397
|
+
return [`${testPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return defaultPatterns;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const coverageConfig = getCoveragePatterns();
|
|
2
404
|
|
|
3
405
|
module.exports = {
|
|
4
406
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
5
|
-
collectCoverageFrom:
|
|
6
|
-
|
|
7
|
-
'
|
|
407
|
+
collectCoverageFrom: coverageConfig,
|
|
408
|
+
coveragePathIgnorePatterns: [
|
|
409
|
+
'/node_modules/',
|
|
410
|
+
'schema\\.[jt]s?$',
|
|
411
|
+
'index\\.[jt]s?$',
|
|
412
|
+
'config\\.[jt]sx?$',
|
|
8
413
|
],
|
|
9
414
|
moduleNameMapper: {
|
|
10
415
|
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
@@ -45,7 +450,17 @@ module.exports = {
|
|
|
45
450
|
},
|
|
46
451
|
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
47
452
|
setupFilesAfterEnv: [
|
|
48
|
-
|
|
453
|
+
fs.existsSync(
|
|
454
|
+
path.join(
|
|
455
|
+
__dirname,
|
|
456
|
+
'node_modules',
|
|
457
|
+
'@eeacms',
|
|
458
|
+
addonName,
|
|
459
|
+
'jest.setup.js',
|
|
460
|
+
),
|
|
461
|
+
)
|
|
462
|
+
? `<rootDir>/node_modules/@eeacms/${addonName}/jest.setup.js`
|
|
463
|
+
: `<rootDir>/src/addons/${addonName}/jest.setup.js`,
|
|
49
464
|
],
|
|
50
465
|
}),
|
|
51
|
-
}
|
|
466
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-website-theme",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"description": "@eeacms/volto-eea-website-theme: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@plone/scripts": "*",
|
|
38
38
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
39
39
|
"dotenv": "^16.3.2",
|
|
40
|
+
"fast-glob": "^3.1.1",
|
|
40
41
|
"husky": "^8.0.3",
|
|
41
42
|
"jsonwebtoken": "9.0.0",
|
|
42
43
|
"lint-staged": "^14.0.1",
|
|
@@ -8,6 +8,8 @@ import { getNavigation } from '@plone/volto/actions';
|
|
|
8
8
|
import { defineMessages, useIntl } from 'react-intl';
|
|
9
9
|
import config from '@plone/volto/registry';
|
|
10
10
|
|
|
11
|
+
import { numbersToMenuItemColumns } from '@eeacms/volto-eea-design-system/ui/Header/utils';
|
|
12
|
+
|
|
11
13
|
import upSVG from '@plone/volto/icons/up-key.svg';
|
|
12
14
|
import downSVG from '@plone/volto/icons/down-key.svg';
|
|
13
15
|
|
|
@@ -36,30 +38,6 @@ const defaultRouteSettings = {
|
|
|
36
38
|
// Don't include empty arrays in default settings
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
// Helper functions for menuItemColumns conversion (numbers to semantic UI format)
|
|
40
|
-
const numberToColumnString = (num) => {
|
|
41
|
-
const numbers = [
|
|
42
|
-
'',
|
|
43
|
-
'one',
|
|
44
|
-
'two',
|
|
45
|
-
'three',
|
|
46
|
-
'four',
|
|
47
|
-
'five',
|
|
48
|
-
'six',
|
|
49
|
-
'seven',
|
|
50
|
-
'eight',
|
|
51
|
-
'nine',
|
|
52
|
-
];
|
|
53
|
-
return numbers[num] ? `${numbers[num]} wide column` : '';
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const numbersToMenuItemColumns = (numbers) => {
|
|
57
|
-
if (!Array.isArray(numbers)) return [];
|
|
58
|
-
return numbers
|
|
59
|
-
.map((num) => numberToColumnString(parseInt(num)))
|
|
60
|
-
.filter((col) => col !== '');
|
|
61
|
-
};
|
|
62
|
-
|
|
63
41
|
const columnStringToNumber = (colString) => {
|
|
64
42
|
const numbers = {
|
|
65
43
|
one: 1,
|
|
@@ -78,7 +56,7 @@ const columnStringToNumber = (colString) => {
|
|
|
78
56
|
return match ? numbers[match[1]] : null;
|
|
79
57
|
};
|
|
80
58
|
|
|
81
|
-
const menuItemColumnsToNumbers = (columns) => {
|
|
59
|
+
export const menuItemColumnsToNumbers = (columns) => {
|
|
82
60
|
if (!Array.isArray(columns)) return [];
|
|
83
61
|
return columns
|
|
84
62
|
.map((col) => columnStringToNumber(col))
|
|
@@ -420,6 +398,20 @@ const NavigationBehaviorWidget = (props) => {
|
|
|
420
398
|
portal_type: ______,
|
|
421
399
|
...settings
|
|
422
400
|
} = route;
|
|
401
|
+
|
|
402
|
+
// // Convert menuItemColumns from numbers back to semantic UI format for backend storage
|
|
403
|
+
if (
|
|
404
|
+
settings.menuItemColumns !== null &&
|
|
405
|
+
settings.menuItemColumns &&
|
|
406
|
+
Array.isArray(settings.menuItemColumns)
|
|
407
|
+
) {
|
|
408
|
+
if (settings.menuItemColumns.length > 0) {
|
|
409
|
+
settings.menuItemColumns = numbersToMenuItemColumns(
|
|
410
|
+
settings.menuItemColumns,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
423
415
|
newSettings[routeId] = settings;
|
|
424
416
|
});
|
|
425
417
|
|
|
@@ -490,6 +490,120 @@ describe('NavigationBehaviorWidget', () => {
|
|
|
490
490
|
expect(screen.getByText('Test Route 2')).toBeInTheDocument();
|
|
491
491
|
});
|
|
492
492
|
|
|
493
|
+
it('handles menuItemColumns as integers from backend (develop server format)', async () => {
|
|
494
|
+
const existingSettings = {
|
|
495
|
+
'http://localhost:3000/test-route-1': {
|
|
496
|
+
hideChildrenFromNavigation: false,
|
|
497
|
+
menuItemColumns: [8, 4], // Integer format from develop server
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
render(
|
|
502
|
+
<Provider store={store}>
|
|
503
|
+
<NavigationBehaviorWidget
|
|
504
|
+
id="test"
|
|
505
|
+
value={JSON.stringify(existingSettings)}
|
|
506
|
+
onChange={mockOnChange}
|
|
507
|
+
/>
|
|
508
|
+
</Provider>,
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
const accordionTitles = screen.getAllByTestId('accordion-title');
|
|
512
|
+
fireEvent.click(accordionTitles[0]);
|
|
513
|
+
|
|
514
|
+
await waitFor(() => {
|
|
515
|
+
expect(
|
|
516
|
+
screen.getByText('Hide Children From Navigation'),
|
|
517
|
+
).toBeInTheDocument();
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// Verify the widget displays the values correctly (converted to numbers for display)
|
|
521
|
+
// The widget should handle integer input and display it properly
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('handles menuItemColumns as semantic UI strings from backend (production format)', async () => {
|
|
525
|
+
const existingSettings = {
|
|
526
|
+
'http://localhost:3000/test-route-1': {
|
|
527
|
+
hideChildrenFromNavigation: false,
|
|
528
|
+
menuItemColumns: ['eight wide column', 'four wide column'], // String format from production
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
render(
|
|
533
|
+
<Provider store={store}>
|
|
534
|
+
<NavigationBehaviorWidget
|
|
535
|
+
id="test"
|
|
536
|
+
value={JSON.stringify(existingSettings)}
|
|
537
|
+
onChange={mockOnChange}
|
|
538
|
+
/>
|
|
539
|
+
</Provider>,
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
const accordionTitles = screen.getAllByTestId('accordion-title');
|
|
543
|
+
fireEvent.click(accordionTitles[0]);
|
|
544
|
+
|
|
545
|
+
await waitFor(() => {
|
|
546
|
+
expect(
|
|
547
|
+
screen.getByText('Hide Children From Navigation'),
|
|
548
|
+
).toBeInTheDocument();
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// Verify the widget displays the values correctly (converted from strings to numbers for display)
|
|
552
|
+
// The widget should handle semantic UI string input and convert it to numbers for display
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it('converts menuItemColumns to semantic UI format when saving', async () => {
|
|
556
|
+
const existingSettings = {
|
|
557
|
+
'http://localhost:3000/test-route-1': {
|
|
558
|
+
hideChildrenFromNavigation: false,
|
|
559
|
+
menuItemColumns: [2, 3], // Numbers that should be converted to semantic UI format
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
render(
|
|
564
|
+
<Provider store={store}>
|
|
565
|
+
<NavigationBehaviorWidget
|
|
566
|
+
id="test"
|
|
567
|
+
value={JSON.stringify(existingSettings)}
|
|
568
|
+
onChange={mockOnChange}
|
|
569
|
+
/>
|
|
570
|
+
</Provider>,
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
const accordionTitles = screen.getAllByTestId('accordion-title');
|
|
574
|
+
fireEvent.click(accordionTitles[0]);
|
|
575
|
+
|
|
576
|
+
await waitFor(() => {
|
|
577
|
+
expect(
|
|
578
|
+
screen.getByText('Hide Children From Navigation'),
|
|
579
|
+
).toBeInTheDocument();
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// Simulate a change by clicking the checkbox
|
|
583
|
+
const checkboxes = screen.getAllByRole('checkbox');
|
|
584
|
+
fireEvent.click(checkboxes[0]);
|
|
585
|
+
|
|
586
|
+
await waitFor(() => {
|
|
587
|
+
expect(mockOnChange).toHaveBeenCalled();
|
|
588
|
+
const lastCallIndex = mockOnChange.mock.calls.length - 1;
|
|
589
|
+
const savedValue = JSON.parse(mockOnChange.mock.calls[lastCallIndex][1]);
|
|
590
|
+
|
|
591
|
+
// Find the route settings
|
|
592
|
+
const routeKey = Object.keys(savedValue).find((key) =>
|
|
593
|
+
key.includes('test-route-1'),
|
|
594
|
+
);
|
|
595
|
+
const route1Settings = savedValue[routeKey];
|
|
596
|
+
|
|
597
|
+
// Verify menuItemColumns are saved in semantic UI format, not as integers
|
|
598
|
+
if (route1Settings && route1Settings.menuItemColumns) {
|
|
599
|
+
route1Settings.menuItemColumns.forEach((col) => {
|
|
600
|
+
expect(typeof col).toBe('string');
|
|
601
|
+
expect(col).toMatch(/wide column$/);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
|
|
493
607
|
it('displays route paths in accordion titles', () => {
|
|
494
608
|
render(
|
|
495
609
|
<Provider store={store}>
|