@eeacms/volto-cca-policy 0.3.131 → 1.0.1

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 (181) hide show
  1. package/.eslintrc.js +7 -7
  2. package/CHANGELOG.md +44 -14
  3. package/docker-compose.yml +16 -16
  4. package/jest-addon.config.js +25 -420
  5. package/package.json +1 -2
  6. package/src/components/MigrationButtons.jsx +5 -1
  7. package/src/components/manage/Blocks/ASTNavigation/ASTNavigationEdit.jsx +2 -1
  8. package/src/components/manage/Blocks/ASTNavigation/ASTNavigationView.jsx +10 -4
  9. package/src/components/manage/Blocks/ASTNavigation/ASTNavigationView.test.jsx +87 -35
  10. package/src/components/manage/Blocks/C3SIndicatorsGlossaryBlock/C3SIndicatorsGlossaryBlockEdit.jsx +1 -1
  11. package/src/components/manage/Blocks/C3SIndicatorsGlossaryBlock/C3SIndicatorsGlossaryBlockView.test.jsx +1 -1
  12. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockEdit.jsx +1 -1
  13. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockView.jsx +1 -1
  14. package/src/components/manage/Blocks/C3SIndicatorsListingBlock/C3SIndicatorsListingBlockView.test.jsx +1 -1
  15. package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/C3SIndicatorsOverviewBlockEdit.jsx +1 -1
  16. package/src/components/manage/Blocks/C3SIndicatorsOverviewBlock/schema.js +0 -20
  17. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerEdit.test.jsx +1 -1
  18. package/src/components/manage/Blocks/CaseStudyExplorer/{CaseStudyExplorerView.js → CaseStudyExplorerView.jsx} +1 -1
  19. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.test.jsx +2 -2
  20. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.test.jsx +1 -1
  21. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.test.jsx +1 -1
  22. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.jsx +2 -1
  23. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.test.jsx +1 -1
  24. package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +0 -4
  25. package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +0 -30
  26. package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsEdit.jsx +1 -1
  27. package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.jsx +3 -2
  28. package/src/components/manage/Blocks/CollectionStatistics/CollectionStatsView.test.jsx +1 -1
  29. package/src/components/manage/Blocks/ContentLinks/ContentLinksEdit.jsx +1 -1
  30. package/src/components/manage/Blocks/ContentLinks/ContentLinksView.jsx +1 -1
  31. package/src/components/manage/Blocks/ContentLinks/ContentLinksView.test.jsx +1 -1
  32. package/src/components/manage/Blocks/ContentLinks/DropdownListView.jsx +1 -1
  33. package/src/components/manage/Blocks/ContentLinks/DropdownListView.test.jsx +1 -1
  34. package/src/components/manage/Blocks/CountryMapHeatIndex/Filter.test.jsx +1 -1
  35. package/src/components/manage/Blocks/CountryMapHeatIndex/{View.js → View.jsx} +14 -10
  36. package/src/components/manage/Blocks/CountryMapHeatIndex/mapstyle.js +1 -3
  37. package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryEdit.jsx +2 -1
  38. package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryOLView.jsx +4 -3
  39. package/src/components/manage/Blocks/CountryMapProfile/Filter.test.jsx +1 -1
  40. package/src/components/manage/Blocks/CountryMapProfile/OLView.jsx +5 -12
  41. package/src/components/manage/Blocks/CountryProfileDetail/{CountryTabPane.js → CountryTabPane.jsx} +11 -4
  42. package/src/components/manage/Blocks/CountryProfileDetail/CountryTabPane.test.jsx +1 -1
  43. package/src/components/manage/Blocks/CountryProfileDetail/{View.js → View.jsx} +20 -15
  44. package/src/components/manage/Blocks/CountryProfileDetail/View.test.jsx +134 -20
  45. package/src/components/manage/Blocks/CountryProfileDetail/index.js +0 -1
  46. package/src/components/manage/Blocks/DataConnectedEmbedBlock/index.js +0 -2
  47. package/src/components/manage/Blocks/ECDEIndicators/ECDEIndicatorsView.jsx +1 -1
  48. package/src/components/manage/Blocks/FilterAceContent/FilterAceContentEdit.jsx +3 -3
  49. package/src/components/manage/Blocks/FilterAceContent/FilterAceContentView.jsx +2 -2
  50. package/src/components/manage/Blocks/FilterAceContent/FilterAceContentView.test.jsx +1 -1
  51. package/src/components/manage/Blocks/FlourishEmbedBlock/FlourishEmbedBlockEdit.jsx +1 -1
  52. package/src/components/manage/Blocks/Listing/DropdownListingView.jsx +1 -1
  53. package/src/components/manage/Blocks/Listing/EventAccordionListingView.jsx +1 -1
  54. package/src/components/manage/Blocks/Listing/EventAccordionListingView.test.jsx +5 -3
  55. package/src/components/manage/Blocks/Listing/EventCardsListingView.jsx +2 -1
  56. package/src/components/manage/Blocks/Listing/EventCardsListingView.test.jsx +10 -4
  57. package/src/components/manage/Blocks/Listing/IndicatorCardsListingView.jsx +2 -2
  58. package/src/components/manage/Blocks/Listing/OrganisationCardsListingView.jsx +3 -1
  59. package/src/components/manage/Blocks/Listing/SimpleCardsListingView.jsx +1 -1
  60. package/src/components/manage/Blocks/Listing/SimpleCardsListingView.test.jsx +5 -3
  61. package/src/components/manage/Blocks/Listing/SimpleItemListingView.jsx +2 -2
  62. package/src/components/manage/Blocks/Listing/SimpleItemListingView.test.jsx +6 -4
  63. package/src/components/manage/Blocks/RASTBlock/ContextNavigation.jsx +0 -1
  64. package/src/components/manage/Blocks/RASTBlock/RASTAccordion.jsx +1 -1
  65. package/src/components/manage/Blocks/RASTBlock/RASTAccordion.test.jsx +1 -1
  66. package/src/components/manage/Blocks/RASTBlock/RASTAccordionContent.jsx +2 -2
  67. package/src/components/manage/Blocks/RASTBlock/RASTEdit.jsx +1 -1
  68. package/src/components/manage/Blocks/RASTBlock/RASTMap.jsx +1 -1
  69. package/src/components/manage/Blocks/RASTBlock/RASTMap.test.jsx +1 -1
  70. package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +1 -1
  71. package/src/components/manage/Blocks/ReadMore/ReadMoreEdit.jsx +1 -1
  72. package/src/components/manage/Blocks/ReadMore/ReadMoreView.jsx +1 -1
  73. package/src/components/manage/Blocks/ReadMore/ReadMoreView.test.jsx +1 -1
  74. package/src/components/manage/Blocks/RedirectBlock/{RedirectBlock.test.js → RedirectBlock.test.jsx} +1 -1
  75. package/src/components/manage/Blocks/RedirectBlock/RedirectBlockEdit.jsx +2 -1
  76. package/src/components/manage/Blocks/RedirectBlock/RedirectBlockView.jsx +2 -2
  77. package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentEdit.jsx +1 -1
  78. package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentView.jsx +1 -1
  79. package/src/components/manage/Blocks/RelevantAceContent/RelevantAceContentView.test.jsx +1 -1
  80. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentEdit.jsx +1 -1
  81. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.jsx +1 -1
  82. package/src/components/manage/Blocks/SearchAceContent/SearchAceContentView.test.jsx +1 -1
  83. package/src/components/manage/Blocks/TabsBlock/Spotlight.jsx +2 -2
  84. package/src/components/manage/Blocks/TabsBlock/Spotlight.test.jsx +7 -1
  85. package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectEdit.jsx +1 -1
  86. package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectView.jsx +1 -1
  87. package/src/components/manage/Blocks/TransRegionSelect/TransRegionSelectView.test.jsx +1 -1
  88. package/src/components/manage/CreateArchivedCopyButton/CreateArchivedCopyButton.jsx +5 -2
  89. package/src/components/manage/CreateArchivedCopyButton/CreateArchivedCopyButton.test.jsx +3 -6
  90. package/src/components/manage/Workflow/WorkflowLinkIntegrityModal.jsx +1 -1
  91. package/src/components/manage/Workflow/WorkflowLinkIntegrityModal.test.jsx +1 -1
  92. package/src/components/theme/ASTNavigation/ASTAccordion.test.jsx +1 -1
  93. package/src/components/theme/ASTNavigation/ASTLogoMap.jsx +1 -1
  94. package/src/components/theme/ASTNavigation/ASTLogoMap.test.jsx +1 -1
  95. package/src/components/theme/ASTNavigation/ASTNavigation.jsx +9 -5
  96. package/src/components/theme/ASTNavigation/ASTNavigation.test.jsx +323 -0
  97. package/src/components/theme/ASTNavigation/{utils.js → LinkWrap.jsx} +4 -9
  98. package/src/components/theme/ASTNavigation/UASTLogoMap.jsx +1 -1
  99. package/src/components/theme/ASTNavigation/UASTLogoMap.test.jsx +1 -1
  100. package/src/components/theme/Header/Header.jsx +5 -5
  101. package/src/components/theme/Header/LanguageSwitch.jsx +5 -5
  102. package/src/components/theme/MissionSignatoryProfile/MissionSignatoryProfileView.jsx +1 -1
  103. package/src/components/theme/TranslationDisclaimer/TranslationDisclaimer.jsx +1 -1
  104. package/src/components/theme/TranslationDisclaimer/TranslationInfo.jsx +1 -1
  105. package/src/components/theme/Views/AdaptationOptionView.jsx +1 -1
  106. package/src/components/theme/Views/AdaptationOptionView.test.jsx +5 -3
  107. package/src/components/theme/Views/ArchivedVersionListing.jsx +1 -1
  108. package/src/components/theme/Views/ArchivedVersionListing.test.jsx +2 -2
  109. package/src/components/theme/Views/ArchivedVersionNotice.jsx +1 -1
  110. package/src/components/theme/Views/ArchivedVersionNotice.test.jsx +1 -1
  111. package/src/components/theme/Views/BrokenLinks.jsx +1 -1
  112. package/src/components/theme/Views/BrokenLinks.test.jsx +1 -1
  113. package/src/components/theme/Views/CaseStudyView.test.jsx +1 -1
  114. package/src/components/theme/Views/DatabaseItemView.test.jsx +1 -1
  115. package/src/components/theme/Views/NewsItemView.jsx +1 -1
  116. package/src/components/theme/Views/ProjectView.test.jsx +1 -1
  117. package/src/components/theme/Views/VersionsGroup.jsx +1 -1
  118. package/src/components/theme/Views/VersionsGroup.test.jsx +1 -1
  119. package/src/components/theme/Widgets/GeocharsWidget.jsx +1 -1
  120. package/src/components/theme/Widgets/GeolocationWidget.jsx +1 -1
  121. package/src/components/theme/Widgets/GeolocationWidget.test.jsx +1 -1
  122. package/src/components/theme/Widgets/ImageWidget.jsx +29 -13
  123. package/src/components/theme/Widgets/ImageWidget.test.jsx +1 -1
  124. package/src/components/theme/Widgets/PromotionalImageWidget.jsx +6 -4
  125. package/src/components/theme/Widgets/utils.js +1 -1
  126. package/src/constants.js +539 -2
  127. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/Header.jsx +1 -1
  128. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderMenuPopUp.js +52 -24
  129. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderSearchPopUp.js +1 -0
  130. package/src/customizations/@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground.jsx +2 -1
  131. package/src/customizations/@eeacms/volto-listing-block/blocks/Listing/item-templates/SimpleItemTemplates.jsx +2 -2
  132. package/src/customizations/@eeacms/volto-listing-block/components/UniversalCard/fragments/CardTitle.jsx +1 -1
  133. package/src/customizations/@plone/volto-slate/blocks/Table/TableBlockView.jsx +3 -3
  134. package/src/customizations/@plone/volto-slate/blocks/Text/{index.js → index.jsx} +2 -21
  135. package/src/customizations/@plone/volto-slate/editor/extensions/normalizeNode.js +1 -1
  136. package/src/customizations/@plone/volto-slate/utils/blocks.js +11 -8
  137. package/src/customizations/@plone/volto-slate/utils/volto-blocks.js +2 -2
  138. package/src/customizations/@plone/volto-slate/widgets/HtmlSlateWidget.jsx +2 -2
  139. package/src/customizations/@plone-collective/volto-authomatic/components/Login/Login.jsx +7 -4
  140. package/src/customizations/@plone-collective/volto-rss-provider/components/RSSFeedView.jsx +5 -8
  141. package/src/customizations/@plone-collective/volto-rss-provider/express-middleware.js +2 -1
  142. package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +3 -3
  143. package/src/customizations/volto/components/manage/Blocks/Grid/templates.js +1 -1
  144. package/src/customizations/volto/components/manage/Contents/ContentsBreadcrumbs.jsx +1 -1
  145. package/src/customizations/volto/components/manage/Controlpanels/ContentTypeLayout.jsx +12 -14
  146. package/src/customizations/volto/components/manage/Display/Display.jsx +10 -5
  147. package/src/customizations/volto/components/manage/Multilingual/TranslationObject.jsx +7 -6
  148. package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.jsx +4 -1
  149. package/src/customizations/volto/components/manage/Workflow/Workflow.jsx +12 -8
  150. package/src/customizations/volto/components/theme/App/App.jsx +16 -23
  151. package/src/customizations/volto/components/theme/Sitemap/Sitemap.jsx +3 -2
  152. package/src/customizations/volto/components/theme/View/DefaultView.jsx +5 -4
  153. package/src/customizations/volto/components/theme/View/LinkView.jsx +2 -2
  154. package/src/customizations/volto/components/theme/View/View.jsx +10 -11
  155. package/src/customizations/volto/helpers/Url/Url-old.js +2 -1
  156. package/src/customizations/volto/middleware/api.js +6 -4
  157. package/src/customizations/volto/reducers/actions/actions.js +2 -5
  158. package/src/customizations/volto/reducers/breadcrumbs/breadcrumbs.js +3 -6
  159. package/src/customizations/volto/reducers/navigation/navigation.js +3 -6
  160. package/src/customizations/volto/server.jsx +9 -8
  161. package/src/express-middleware.js +1 -1
  162. package/src/helpers/ContentMetadata.jsx +4 -4
  163. package/src/helpers/Utils.jsx +5 -5
  164. package/src/helpers/index.js +1 -8
  165. package/src/hocs/index.js +2 -0
  166. package/src/index.js +9 -7
  167. package/src/search/common.js +4 -41
  168. package/src/search/utils.test.js +1 -1
  169. package/src/search/vocabulary.js +2 -2
  170. package/src/store/reducers/physical-breadcrumbs.js +2 -2
  171. package/src/utils.js +1 -1
  172. package/src/helpers/Constants.jsx +0 -535
  173. package/theme/assets/images/administrative_support_service.png +0 -0
  174. /package/src/components/manage/Blocks/CaseStudyExplorer/{CaseStudyExplorerEdit.js → CaseStudyExplorerEdit.jsx} +0 -0
  175. /package/src/components/manage/Blocks/CountryMapHeatIndex/{Edit.js → Edit.jsx} +0 -0
  176. /package/src/components/manage/Blocks/CountryMapProfile/{Edit.js → Edit.jsx} +0 -0
  177. /package/src/components/manage/Blocks/CountryProfileDetail/{Edit.js → Edit.jsx} +0 -0
  178. /package/src/components/manage/Blocks/ReadMore/{schema.js → schema.jsx} +0 -0
  179. /package/src/helpers/{clientOnly.js → clientOnly.jsx} +0 -0
  180. /package/src/{components/manage/Blocks/withResponsiveContainer.js → hocs/withResponsiveContainer.jsx} +0 -0
  181. /package/src/{components/manage/Blocks → hocs}/withVisibilitySensor.jsx +0 -0
@@ -1,418 +1,35 @@
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
1
  require('dotenv').config({ path: __dirname + '/.env' });
17
2
 
18
- const path = require('path');
19
3
  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
- : 'volto-listing-block'; // Fallback addon 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
- '!**/*.spec.{js,jsx,ts,tsx}',
338
- ];
339
-
340
- const defaultPatterns = [
341
- `${addonBasePath}/**/*.{js,jsx,ts,tsx}`,
342
- ...excludePatterns,
343
- ];
344
-
345
- const ANY_SCRIPT_FILE_REGEX = /\.[jt]sx?$/;
346
-
347
- const directoryArg = process.argv.find(
348
- (arg) =>
349
- !arg.includes(path.sep) &&
350
- !arg.startsWith('--') &&
351
- arg !== 'test' &&
352
- arg !== 'node' &&
353
- !ANY_SCRIPT_FILE_REGEX.test(arg) &&
354
- ![
355
- 'yarn',
356
- 'npm',
357
- 'npx',
358
- 'collectCoverage',
359
- 'CI',
360
- 'RAZZLE_JEST_CONFIG',
361
- ].some(
362
- (reserved) =>
363
- arg === reserved || arg.startsWith(reserved.split('=')[0] + '='),
364
- ) &&
365
- process.argv.indexOf(arg) >
366
- process.argv.findIndex((item) => item === 'test'),
367
- );
368
-
369
- if (directoryArg) {
370
- const foundDir = findInAddon(directoryArg, 'd');
371
- if (foundDir) {
372
- return [`${foundDir}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
373
- }
374
- }
375
-
376
- let testPath = getTestPath();
377
-
378
- if (!testPath) {
379
- return defaultPatterns;
380
- }
381
-
382
- if (testPath.endsWith(path.sep)) {
383
- testPath = testPath.slice(0, -1);
384
- }
385
-
386
- const stats = getStatSync(testPath);
387
-
388
- if (stats && stats.isFile()) {
389
- const implFile = findImplementationFile(testPath);
390
- if (implFile) {
391
- return [implFile, '!src/**/*.d.ts'];
392
- }
393
- const dirPath = path.dirname(testPath);
394
- return [`${dirPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
395
- } else if (stats && stats.isDirectory()) {
396
- return [`${testPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
397
- }
398
-
399
- return defaultPatterns;
400
- };
4
+ const path = require('path');
401
5
 
402
- const coverageConfig = getCoveragePatterns();
6
+ // Volto 18 exposes @plone/volto-slate as a top-level package.
7
+ const voltoSlatePath = fs.existsSync(
8
+ path.join(
9
+ __dirname,
10
+ '..',
11
+ '..',
12
+ '..',
13
+ 'node_modules',
14
+ '@plone',
15
+ 'volto-slate',
16
+ 'src',
17
+ ),
18
+ )
19
+ ? '<rootDir>/node_modules/@plone/volto-slate/src'
20
+ : '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src';
403
21
 
404
22
  module.exports = {
405
23
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
406
- collectCoverageFrom: coverageConfig,
407
- coveragePathIgnorePatterns: [
408
- '/node_modules/',
409
- 'schema\\.[jt]s?$',
410
- 'index\\.[jt]s?$',
411
- 'config\\.[jt]sx?$',
24
+ collectCoverageFrom: [
25
+ 'src/addons/**/src/**/*.{js,jsx,ts,tsx}',
26
+ '!src/**/*.d.ts',
412
27
  ],
413
28
  moduleNameMapper: {
414
29
  '^node:crypto$': '<rootDir>/src/addons/volto-cca-policy/jest-node-crypto-mock.js',
415
30
  '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
31
+ '@plone-collective/volto-authomatic/(.*)$':
32
+ '<rootDir>/node_modules/@plone-collective/volto-authomatic/src/$1',
416
33
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
417
34
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
418
35
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
@@ -422,16 +39,14 @@ module.exports = {
422
39
  '@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
423
40
  '@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
424
41
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
425
- '@plone/volto-slate$':
426
- '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
427
- '@plone/volto-slate/(.*)$':
428
- '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
42
+ '@plone/volto-slate$': voltoSlatePath,
43
+ '@plone/volto-slate/(.*)$': `${voltoSlatePath}/$1`,
429
44
  '~/(.*)$': '<rootDir>/src/$1',
430
45
  'load-volto-addons':
431
46
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
432
47
  },
433
48
  transformIgnorePatterns: [
434
- '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
49
+ '/node_modules/(?!(@plone|@root|@package|@eeacms|@plone-collective)/).*/',
435
50
  ],
436
51
  transform: {
437
52
  '^.+\\.js(x)?$': 'babel-jest',
@@ -450,17 +65,7 @@ module.exports = {
450
65
  },
451
66
  ...(process.env.JEST_USE_SETUP === 'ON' && {
452
67
  setupFilesAfterEnv: [
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`,
68
+ '<rootDir>/node_modules/@eeacms/volto-eea-website-policy/jest.setup.js',
464
69
  ],
465
70
  }),
466
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.131",
3
+ "version": "1.0.1",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -23,7 +23,6 @@
23
23
  "@eeacms/volto-eea-design-system",
24
24
  "@eeacms/volto-eea-website-theme",
25
25
  "@eeacms/volto-tabs-block",
26
- "@eeacms/volto-datablocks",
27
26
  "@eeacms/volto-embed",
28
27
  "@eeacms/volto-globalsearch",
29
28
  "@plone-collective/volto-authomatic"
@@ -1,5 +1,9 @@
1
1
  import { Plug } from '@plone/volto/components/manage/Pluggable';
2
- import { getBaseUrl, toPublicURL, addAppURL } from '@plone/volto/helpers';
2
+ import {
3
+ getBaseUrl,
4
+ toPublicURL,
5
+ addAppURL,
6
+ } from '@plone/volto/helpers/Url/Url';
3
7
 
4
8
  const button = (id, title, label, destination) => (
5
9
  <button
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
3
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
4
+ import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
4
5
 
5
6
  import ASTNavigationView from './ASTNavigationView';
6
7
  import schema from './schema';
@@ -1,10 +1,16 @@
1
1
  import loadable from '@loadable/component';
2
2
 
3
- const ASTLogoMap = loadable(() =>
4
- import('@eeacms/volto-cca-policy/components/theme/ASTNavigation/ASTLogoMap'),
3
+ const ASTLogoMap = loadable(
4
+ () =>
5
+ import(
6
+ '@eeacms/volto-cca-policy/components/theme/ASTNavigation/ASTLogoMap'
7
+ ),
5
8
  );
6
- const UASTLogoMap = loadable(() =>
7
- import('@eeacms/volto-cca-policy/components/theme/ASTNavigation/UASTLogoMap'),
9
+ const UASTLogoMap = loadable(
10
+ () =>
11
+ import(
12
+ '@eeacms/volto-cca-policy/components/theme/ASTNavigation/UASTLogoMap'
13
+ ),
8
14
  );
9
15
 
10
16
  export default function ASTNavigationView(props) {
@@ -1,48 +1,100 @@
1
1
  import React from 'react';
2
- import '@testing-library/jest-dom/extend-expect';
3
- import { MemoryRouter } from 'react-router-dom';
4
- import configureStore from 'redux-mock-store';
5
- import { render } from '@testing-library/react';
6
- import { Provider } from 'react-intl-redux';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
7
4
  import ASTNavigationView from './ASTNavigationView';
8
5
 
9
- const mockStore = configureStore();
6
+ jest.mock('@loadable/component', () => {
7
+ let callCount = 0;
10
8
 
11
- describe('ASTLogoMap', () => {
12
- it('should render the component', () => {
9
+ return () => {
10
+ callCount += 1;
11
+ const componentName = callCount === 1 ? 'ASTLogoMap' : 'UASTLogoMap';
12
+
13
+ return ({ items, pathname, href }) => (
14
+ <div
15
+ data-testid={componentName}
16
+ data-items={JSON.stringify(items)}
17
+ data-pathname={pathname}
18
+ data-href={href}
19
+ >
20
+ {componentName}
21
+ </div>
22
+ );
23
+ };
24
+ });
25
+
26
+ describe('ASTNavigationView', () => {
27
+ const makeItems = () =>
28
+ Array.from({ length: 6 }, (_, index) => ({
29
+ href: [`/en/source-${index + 1}`],
30
+ title: `Source ${index + 1}`,
31
+ }));
32
+
33
+ it('renders an incomplete source warning when items length is not 6', () => {
34
+ const data = {
35
+ items: [],
36
+ image_type: 'ast',
37
+ href: ['/en/ast-nav'],
38
+ };
39
+
40
+ const { container } = render(
41
+ <ASTNavigationView path="/en/ast-nav" data={data} />,
42
+ );
43
+
44
+ expect(container).toHaveTextContent('Incomplete number of sources');
45
+ });
46
+
47
+ it('renders ASTLogoMap when image_type is ast and items length is 6', () => {
13
48
  const data = {
14
- items: {
15
- 'step-0': {
16
- '@id': '/en/knowledge/tools/adaptation-support-tool',
17
- title: 'Preparing the ground for adaptation',
18
- items: [
19
- {
20
- '@id': '/en/knowledge/tools/adaptation-support-tool/step-1-1',
21
- title:
22
- '1.1 Obtaining high-level political support for adaptation',
23
- },
24
- ],
25
- },
26
- },
27
- pathname: '/en/knowledge/tools/adaptation-support-tool',
49
+ items: makeItems(),
28
50
  image_type: 'ast',
51
+ href: ['/en/ast-nav'],
29
52
  };
30
53
 
31
- const store = mockStore({
32
- userSession: { token: '1234' },
33
- intl: {
34
- locale: 'en',
35
- messages: {},
36
- },
37
- });
54
+ render(<ASTNavigationView path="/en/ast-nav" data={data} />);
55
+
56
+ const astLogoMap = screen.getByTestId('ASTLogoMap');
57
+ expect(astLogoMap).toBeInTheDocument();
58
+ expect(astLogoMap.dataset.pathname).toBe('/en/ast-nav');
59
+ expect(astLogoMap.dataset.href).toBe('/en/ast-nav');
60
+ expect(astLogoMap.dataset.items).toBe(
61
+ JSON.stringify({
62
+ 'step-1': '/en/source-1',
63
+ 'step-2': '/en/source-2',
64
+ 'step-3': '/en/source-3',
65
+ 'step-4': '/en/source-4',
66
+ 'step-5': '/en/source-5',
67
+ 'step-6': '/en/source-6',
68
+ }),
69
+ );
70
+ });
71
+
72
+ it('renders UASTLogoMap when image_type is uast and items length is 6', () => {
73
+ const data = {
74
+ items: makeItems(),
75
+ image_type: 'uast',
76
+ href: ['/en/ast-nav'],
77
+ };
78
+
79
+ render(<ASTNavigationView path="/en/ast-nav" data={data} />);
80
+
81
+ const uastLogoMap = screen.getByTestId('UASTLogoMap');
82
+ expect(uastLogoMap).toBeInTheDocument();
83
+ expect(uastLogoMap.dataset.pathname).toBe('/en/ast-nav');
84
+ expect(uastLogoMap.dataset.href).toBe('/en/ast-nav');
85
+ });
86
+
87
+ it('renders nothing when image_type is unsupported and items length is 6', () => {
88
+ const data = {
89
+ items: makeItems(),
90
+ image_type: 'unsupported',
91
+ href: ['/en/ast-nav'],
92
+ };
38
93
 
39
94
  const { container } = render(
40
- <Provider store={store}>
41
- <MemoryRouter>
42
- <ASTNavigationView path="/en/ast-nav" data={data} />
43
- </MemoryRouter>
44
- </Provider>,
95
+ <ASTNavigationView path="/en/ast-nav" data={data} />,
45
96
  );
46
- expect(container).toBeTruthy();
97
+
98
+ expect(container).toBeEmptyDOMElement();
47
99
  });
48
100
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { SidebarPortal } from '@plone/volto/components';
3
+ import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
4
4
  import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
5
 
6
6
  import C3SIndicatorsGlossaryBlockView from './C3SIndicatorsGlossaryBlockView';
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { MemoryRouter } from 'react-router-dom';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { render } from '@testing-library/react';
5
- import '@testing-library/jest-dom/extend-expect';
5
+ import '@testing-library/jest-dom';
6
6
  import { Provider } from 'react-intl-redux';
7
7
  import C3SIndicatorsGlossaryBlockView from './C3SIndicatorsGlossaryBlockView';
8
8