@eeacms/volto-datahub 1.0.33 → 2.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/.eslintrc.js +32 -25
- package/CHANGELOG.md +8 -14
- package/jest-addon.config.js +16 -3
- package/jest.setup.js +65 -0
- package/package.json +2 -1
- package/src/components/ItemView/Datasets/DatasetEsri.jsx +1 -1
- package/src/components/ItemView/Datasets/DatasetEsri.test.jsx +32 -19
- package/src/components/ItemView/Datasets/DatasetHttpLinks.jsx +25 -40
- package/src/components/ItemView/Datasets/DatasetHttpLinks.test.jsx +67 -26
- package/src/components/ItemView/Datasets/DatasetItemDownloadList.test.jsx +52 -17
- package/src/components/ItemView/Datasets/DatasetLinks.test.jsx +41 -19
- package/src/components/ItemView/Datasets/DatasetUrls.test.jsx +43 -17
- package/src/components/ItemView/Datasets/DatasetsView.jsx +2 -4
- package/src/components/ItemView/MetadataSection.jsx +2 -0
- package/src/components/ItemView/MetadataSection.test.jsx +64 -10
- package/src/components/ItemView/MoreLikeThis.test.jsx +62 -7
- package/src/components/ItemView/utils.test.js +2 -20
- package/src/config/facets.js +3 -1
- package/src/config/filters.js +3 -1
- package/src/config/views.js +3 -1
- package/src/config/vocabulary.js +3 -1
- package/src/utils.js +7 -8
package/.eslintrc.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const projectRootPath = fs.existsSync('./project')
|
|
5
|
-
? fs.realpathSync('./project')
|
|
6
|
-
: fs.realpathSync('./../../../');
|
|
7
|
-
const packageJson = require(path.join(projectRootPath, 'package.json'));
|
|
8
|
-
const jsConfig = require(path.join(
|
|
9
|
-
projectRootPath,
|
|
10
|
-
'jsconfig.json',
|
|
11
|
-
)).compilerOptions;
|
|
12
|
-
|
|
13
|
-
const pathsConfig = jsConfig.paths;
|
|
3
|
+
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
|
|
14
4
|
|
|
15
5
|
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
6
|
+
let configFile;
|
|
7
|
+
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
|
|
8
|
+
configFile = `${projectRootPath}/tsconfig.json`;
|
|
9
|
+
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
|
|
10
|
+
configFile = `${projectRootPath}/jsconfig.json`;
|
|
11
|
+
|
|
12
|
+
if (configFile) {
|
|
13
|
+
const jsConfig = require(configFile).compilerOptions;
|
|
14
|
+
const pathsConfig = jsConfig.paths;
|
|
15
|
+
if (pathsConfig['@plone/volto'])
|
|
16
|
+
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
|
|
17
|
+
}
|
|
16
18
|
|
|
17
|
-
Object.keys(pathsConfig).forEach((pkg) => {
|
|
18
|
-
if (pkg === '@plone/volto') {
|
|
19
|
-
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
19
|
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
23
20
|
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
24
21
|
|
|
@@ -28,21 +25,19 @@ const addonAliases = Object.keys(reg.packages).map((o) => [
|
|
|
28
25
|
reg.packages[o].modulePath,
|
|
29
26
|
]);
|
|
30
27
|
|
|
31
|
-
const
|
|
32
|
-
reg.packages['@eeacms/volto-searchlib'].modulePath,
|
|
33
|
-
);
|
|
34
|
-
const searchlibPath = path.resolve(`${voltoSearchlibPath}/searchlib`);
|
|
28
|
+
const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
extends: `${
|
|
30
|
+
const defaultConfig = {
|
|
31
|
+
extends: `${voltoPath}/.eslintrc`,
|
|
38
32
|
settings: {
|
|
39
33
|
'import/resolver': {
|
|
40
34
|
alias: {
|
|
41
35
|
map: [
|
|
42
36
|
['@plone/volto', '@plone/volto/src'],
|
|
37
|
+
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
|
|
43
38
|
...addonAliases,
|
|
44
|
-
['@eeacms/search', searchlibPath],
|
|
45
39
|
['@package', `${__dirname}/src`],
|
|
40
|
+
['@root', `${__dirname}/src`],
|
|
46
41
|
['~', `${__dirname}/src`],
|
|
47
42
|
],
|
|
48
43
|
extensions: ['.js', '.jsx', '.json'],
|
|
@@ -53,6 +48,18 @@ module.exports = {
|
|
|
53
48
|
},
|
|
54
49
|
},
|
|
55
50
|
rules: {
|
|
56
|
-
'react/jsx-no-target-blank':
|
|
57
|
-
|
|
51
|
+
'react/jsx-no-target-blank': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
allowReferrer: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
}
|
|
58
58
|
};
|
|
59
|
+
|
|
60
|
+
const config = addonExtenders.reduce(
|
|
61
|
+
(acc, extender) => extender.modify(acc),
|
|
62
|
+
defaultConfig,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
module.exports = config;
|
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,14 @@ 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
|
-
### [
|
|
7
|
+
### [2.0.0](https://github.com/eea/volto-datahub/compare/1.0.33...2.0.0) - 22 April 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: Release 2.0.0 - Volto 17 support [alin - [`1ea48ae`](https://github.com/eea/volto-datahub/commit/1ea48ae306f13cea5729ba55a5b77f79fe0d8716)]
|
|
12
|
+
- feat: Volto 17 support - refs #264527 [EEA Jenkins - [`309c256`](https://github.com/eea/volto-datahub/commit/309c256a62ce3807dd272520ff931bf3cff7f724)]
|
|
13
|
+
|
|
14
|
+
### [1.0.33](https://github.com/eea/volto-datahub/compare/1.0.32...1.0.33) - 13 March 2024
|
|
8
15
|
|
|
9
16
|
#### :boom: Breaking Change
|
|
10
17
|
|
|
@@ -12,7 +19,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
12
19
|
|
|
13
20
|
#### :house: Internal changes
|
|
14
21
|
|
|
15
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`8438e52`](https://github.com/eea/volto-datahub/commit/8438e52e811c46aa542a601b75f4198b214b5ffd)]
|
|
16
22
|
- chore: husky, lint-staged use fixed versions [valentinab25 - [`da129fb`](https://github.com/eea/volto-datahub/commit/da129fb1259a26c87259f380a37db688281b192d)]
|
|
17
23
|
|
|
18
24
|
#### :hammer_and_wrench: Others
|
|
@@ -22,11 +28,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
22
28
|
- remove eslint file from ignoring [Teodor - [`39f6633`](https://github.com/eea/volto-datahub/commit/39f66338f2f7d1797343b88aa20dea9425f37014)]
|
|
23
29
|
- change eslint rule [Teodor - [`73e4bc2`](https://github.com/eea/volto-datahub/commit/73e4bc217e9aa9804f0f57cf9e3488cb2e1e85b8)]
|
|
24
30
|
- Ref #263008 [Teodor - [`9d58c52`](https://github.com/eea/volto-datahub/commit/9d58c52b6bc207c5c622c0428be39ae18875cf64)]
|
|
25
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`524fcc6`](https://github.com/eea/volto-datahub/commit/524fcc6a40e1437dac449543607089b4ba4feb21)]
|
|
26
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`98c01ac`](https://github.com/eea/volto-datahub/commit/98c01ac599087cf5a9011d3384483d023a4d12bb)]
|
|
27
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`bdcc59c`](https://github.com/eea/volto-datahub/commit/bdcc59c2d4cfd8beba4386d6f23f220c777f0513)]
|
|
28
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`5d12d14`](https://github.com/eea/volto-datahub/commit/5d12d1428a547b8628231dc38110a55b806edebb)]
|
|
29
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`dba984e`](https://github.com/eea/volto-datahub/commit/dba984e6b840c451b8de15d40de0e49c1dd09a9b)]
|
|
30
31
|
### [1.0.32](https://github.com/eea/volto-datahub/compare/1.0.31...1.0.32) - 11 October 2023
|
|
31
32
|
|
|
32
33
|
#### :house: Internal changes
|
|
@@ -72,7 +73,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
72
73
|
- Fix content type for rss feed [Tiberiu Ichim - [`65b73a7`](https://github.com/eea/volto-datahub/commit/65b73a79d73e626f652716305e80d9a2b017c85c)]
|
|
73
74
|
- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`ead1c04`](https://github.com/eea/volto-datahub/commit/ead1c042d1358b385c19ec66ec84d7c736574b1d)]
|
|
74
75
|
- Added 'DOI' links to datahub [Zoltan Szabo - [`b33a657`](https://github.com/eea/volto-datahub/commit/b33a657096eaec4caa641379e69e941a3b2c1583)]
|
|
75
|
-
- test: Fix eslint and yarn i18n [Alin Voinea - [`39a4a69`](https://github.com/eea/volto-datahub/commit/39a4a695733514890075886753b9d7b91d853646)]
|
|
76
76
|
- i18n: Add en [Alin Voinea - [`cdb303f`](https://github.com/eea/volto-datahub/commit/cdb303f2ac5e1f9eb22eda46bb58087c62af6ba5)]
|
|
77
77
|
### [1.0.27](https://github.com/eea/volto-datahub/compare/1.0.26...1.0.27) - 25 August 2023
|
|
78
78
|
|
|
@@ -120,7 +120,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
120
120
|
|
|
121
121
|
#### :house: Internal changes
|
|
122
122
|
|
|
123
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`e5933ce`](https://github.com/eea/volto-datahub/commit/e5933ce8879d98aabe0bab56980dbd50ce856a36)]
|
|
124
123
|
|
|
125
124
|
#### :hammer_and_wrench: Others
|
|
126
125
|
|
|
@@ -175,7 +174,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
175
174
|
- added utils.js [Zoltan Szabo - [`fdb33c3`](https://github.com/eea/volto-datahub/commit/fdb33c37e1af2fe071dbe8f4f5dcd2b82932edc8)]
|
|
176
175
|
- Show 'Obsolete' info in the metadata section in the banner [Zoltan Szabo - [`fddfd2a`](https://github.com/eea/volto-datahub/commit/fddfd2aea63d1a1d1567c163ab29dd7119781117)]
|
|
177
176
|
- Show 'More information' section only if it's not empty [Zoltan Szabo - [`612f035`](https://github.com/eea/volto-datahub/commit/612f03509c6adf143631ae6dee5ca2bd48a501c3)]
|
|
178
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b9100f6`](https://github.com/eea/volto-datahub/commit/b9100f6b2b2e9e9a26b9c11708c8fda94137cecc)]
|
|
179
177
|
### [1.0.15](https://github.com/eea/volto-datahub/compare/1.0.14...1.0.15) - 1 March 2023
|
|
180
178
|
|
|
181
179
|
### [1.0.14](https://github.com/eea/volto-datahub/compare/1.0.13...1.0.14) - 1 March 2023
|
|
@@ -268,11 +266,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
268
266
|
#### :hammer_and_wrench: Others
|
|
269
267
|
|
|
270
268
|
- Fix eslintrc: add @eeacms/search [kreafox - [`465816f`](https://github.com/eea/volto-datahub/commit/465816feb8f58095ab4b5b3168cd29ebede3a10c)]
|
|
271
|
-
- Use latest Volto before yarn 3 [Tiberiu Ichim - [`69f5859`](https://github.com/eea/volto-datahub/commit/69f585980fd9a38ff99d0c7875704671857720f7)]
|
|
272
269
|
- Reorder sections on landing page [kreafox - [`46fac8d`](https://github.com/eea/volto-datahub/commit/46fac8d821cf93fe1b2c380380719de130c3f1cb)]
|
|
273
270
|
- Fix project eslintrc [kreafox - [`5baa150`](https://github.com/eea/volto-datahub/commit/5baa1505ec38ed313269f5608c186c6a6a8bbfc4)]
|
|
274
271
|
- Open dataset links in new tab [kreafox - [`bbed914`](https://github.com/eea/volto-datahub/commit/bbed914dc2edf6c749d1d73d93a423bc642e680c)]
|
|
275
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`380a2a9`](https://github.com/eea/volto-datahub/commit/380a2a9625c6f799df7a7c343fad3f3b3d959f96)]
|
|
276
272
|
## [1.0.0](https://github.com/eea/volto-datahub/compare/0.1.12...1.0.0) - 28 October 2022
|
|
277
273
|
|
|
278
274
|
#### :nail_care: Enhancements
|
|
@@ -297,7 +293,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
297
293
|
#### :hammer_and_wrench: Others
|
|
298
294
|
|
|
299
295
|
- fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
|
|
300
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
|
|
301
296
|
### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
|
|
302
297
|
|
|
303
298
|
#### :hammer_and_wrench: Others
|
|
@@ -386,7 +381,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
386
381
|
#### :hammer_and_wrench: Others
|
|
387
382
|
|
|
388
383
|
- Hide questions & fix landing page [kreafox - [`a1ef303`](https://github.com/eea/volto-datahub/commit/a1ef3033df0e84f3a72dd0f984c8717dff2a771c)]
|
|
389
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`910688e`](https://github.com/eea/volto-datahub/commit/910688e3ddf2f8cda4f941595ae9a6ee0ec0ea3b)]
|
|
390
384
|
### [0.1.1](https://github.com/eea/volto-datahub/compare/0.1.0...0.1.1) - 10 June 2022
|
|
391
385
|
|
|
392
386
|
### [0.1.0](https://github.com/eea/volto-datahub/compare/0.0.1...0.1.0) - 9 June 2022
|
package/jest-addon.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require('dotenv').config({ path: __dirname + '/.env' });
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
3
5
|
collectCoverageFrom: [
|
|
@@ -9,19 +11,25 @@ module.exports = {
|
|
|
9
11
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
10
12
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
11
13
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
12
|
-
'@package/(.*)$': '<rootDir>/src/$1',
|
|
13
|
-
'@root/(.*)$': '<rootDir>/src/$1',
|
|
14
|
+
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
15
|
+
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
14
16
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
15
17
|
'@eeacms/search': '<rootDir>/node_modules/@eeacms/volto-searchlib/src',
|
|
16
18
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
17
|
-
'@plone/volto-slate':
|
|
19
|
+
'@plone/volto-slate$':
|
|
18
20
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
21
|
+
'@plone/volto-slate/(.*)$':
|
|
22
|
+
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
19
23
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
20
24
|
'load-volto-addons':
|
|
21
25
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
22
26
|
},
|
|
27
|
+
transformIgnorePatterns: [
|
|
28
|
+
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
|
|
29
|
+
],
|
|
23
30
|
transform: {
|
|
24
31
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
32
|
+
'^.+\\.ts(x)?$': 'babel-jest',
|
|
25
33
|
'^.+\\.(png)$': 'jest-file',
|
|
26
34
|
'^.+\\.(jpg)$': 'jest-file',
|
|
27
35
|
'^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
|
|
@@ -34,4 +42,9 @@ module.exports = {
|
|
|
34
42
|
statements: 5,
|
|
35
43
|
},
|
|
36
44
|
},
|
|
45
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
46
|
+
setupFilesAfterEnv: [
|
|
47
|
+
'<rootDir>/node_modules/@eeacms/volto-datahub/jest.setup.js',
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
37
50
|
};
|
package/jest.setup.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import configureStore from 'redux-mock-store';
|
|
3
|
+
import thunk from 'redux-thunk';
|
|
4
|
+
import { blocksConfig } from '@plone/volto/config/Blocks';
|
|
5
|
+
import installSlate from '@plone/volto-slate/index';
|
|
6
|
+
|
|
7
|
+
var mockSemanticComponents = jest.requireActual('semantic-ui-react');
|
|
8
|
+
var mockComponents = jest.requireActual('@plone/volto/components');
|
|
9
|
+
var config = jest.requireActual('@plone/volto/registry').default;
|
|
10
|
+
|
|
11
|
+
config.blocks.blocksConfig = {
|
|
12
|
+
...blocksConfig,
|
|
13
|
+
...config.blocks.blocksConfig,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
jest.doMock('semantic-ui-react', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
...mockSemanticComponents,
|
|
19
|
+
Popup: ({ content, trigger }) => {
|
|
20
|
+
return (
|
|
21
|
+
<div className="popup">
|
|
22
|
+
<div className="trigger">{trigger}</div>
|
|
23
|
+
<div className="content">{content}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.doMock('@plone/volto/components', () => {
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
...mockComponents,
|
|
33
|
+
SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
jest.doMock('@plone/volto/registry', () =>
|
|
38
|
+
[installSlate].reduce((acc, apply) => apply(acc), config),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const mockStore = configureStore([thunk]);
|
|
42
|
+
|
|
43
|
+
global.fetch = jest.fn(() =>
|
|
44
|
+
Promise.resolve({
|
|
45
|
+
json: () => Promise.resolve({}),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
global.store = mockStore({
|
|
50
|
+
intl: {
|
|
51
|
+
locale: 'en',
|
|
52
|
+
messages: {},
|
|
53
|
+
formatMessage: jest.fn(),
|
|
54
|
+
},
|
|
55
|
+
content: {
|
|
56
|
+
create: {},
|
|
57
|
+
subrequests: [],
|
|
58
|
+
},
|
|
59
|
+
connected_data_parameters: {},
|
|
60
|
+
screen: {
|
|
61
|
+
page: {
|
|
62
|
+
width: 768,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-datahub",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "@eeacms/volto-datahub: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@cypress/code-coverage": "^3.10.0",
|
|
27
27
|
"@plone/scripts": "*",
|
|
28
28
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
29
|
+
"dotenv": "^16.3.2",
|
|
29
30
|
"husky": "^8.0.3",
|
|
30
31
|
"lint-staged": "^14.0.1",
|
|
31
32
|
"md5": "^2.3.0"
|
|
@@ -10,7 +10,7 @@ const ItemLink = ({ item }) => (
|
|
|
10
10
|
<List.Content>
|
|
11
11
|
<div className="dataset-item">
|
|
12
12
|
<SVGIcon name={servicesSVG} size="20px" />
|
|
13
|
-
<a className="item-link" href={item.url} target="_blank">
|
|
13
|
+
<a className="item-link" href={item.url} target="_blank" rel="noopener">
|
|
14
14
|
{item.protocol} {item.name || item.description}
|
|
15
15
|
</a>
|
|
16
16
|
{isInternalURL(item.url) ? (
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
4
|
|
|
4
5
|
import DatasetEsri from './DatasetEsri';
|
|
5
6
|
|
|
6
|
-
jest.mock('
|
|
7
|
-
runRequest: jest.fn(),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
const dataset = {
|
|
11
|
-
'ESRI:REST': [
|
|
12
|
-
{
|
|
13
|
-
id: 1,
|
|
14
|
-
url: 'https://example.org/1',
|
|
15
|
-
protocol: 'https',
|
|
16
|
-
name: 'First',
|
|
17
|
-
description: 'Something here',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
7
|
+
jest.mock('remixicon/icons/System/lock-line.svg', () => 'MockLockIcon');
|
|
21
8
|
|
|
22
9
|
describe('DatasetEsri', () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
const dataset = {
|
|
11
|
+
'ESRI:REST': [
|
|
12
|
+
{
|
|
13
|
+
id: 1,
|
|
14
|
+
url: 'https://example.org/1',
|
|
15
|
+
protocol: 'https',
|
|
16
|
+
name: 'First',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
it('renders services section when ESRI:REST data exists', () => {
|
|
22
|
+
render(<DatasetEsri dataset={dataset} />);
|
|
23
|
+
|
|
24
|
+
expect(screen.getByText('Services:')).toBeInTheDocument();
|
|
25
|
+
expect(screen.getByText('https First')).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders services section when OGC:WMS data exists', () => {
|
|
29
|
+
render(<DatasetEsri dataset={{ 'OGC:WMS': dataset['ESRI:REST'] }} />);
|
|
30
|
+
|
|
31
|
+
expect(screen.getByText('Services:')).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('https First')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('does not render services section when no data exists', () => {
|
|
36
|
+
render(<DatasetEsri dataset={{}} />);
|
|
37
|
+
|
|
38
|
+
expect(screen.queryByText('Services:')).not.toBeInTheDocument();
|
|
26
39
|
});
|
|
27
40
|
});
|
|
@@ -4,51 +4,36 @@ import { SVGIcon } from '../utils.js';
|
|
|
4
4
|
|
|
5
5
|
import lockSVG from 'remixicon/icons/System/lock-line.svg';
|
|
6
6
|
|
|
7
|
+
const renderListItem = (item, index, iconClass) => (
|
|
8
|
+
<List.Item key={index}>
|
|
9
|
+
<List.Content>
|
|
10
|
+
<div className="dataset-item">
|
|
11
|
+
<Icon className={iconClass} />
|
|
12
|
+
<a href={item.url} className="item-link" target="_blank" rel="noopener">
|
|
13
|
+
<span>{item.name || item.url}</span>
|
|
14
|
+
</a>
|
|
15
|
+
{isInternalURL(item.url) ? (
|
|
16
|
+
<SVGIcon name={lockSVG} size="20px" />
|
|
17
|
+
) : null}
|
|
18
|
+
</div>
|
|
19
|
+
</List.Content>
|
|
20
|
+
{item.description ? (
|
|
21
|
+
<span className="item-description">{item.description}</span>
|
|
22
|
+
) : null}
|
|
23
|
+
</List.Item>
|
|
24
|
+
);
|
|
25
|
+
|
|
7
26
|
export default function DatasetHttpLinks({ dataset }) {
|
|
8
27
|
return dataset['WWW:LINK-1.0-http--link'] || dataset['DOI'] ? (
|
|
9
28
|
<>
|
|
10
29
|
<h5>Links:</h5>
|
|
11
30
|
<List divided relaxed>
|
|
12
|
-
{(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<a href={item.url} className="item-link" target="_blank">
|
|
19
|
-
<span>{item.name || item.url}</span>
|
|
20
|
-
</a>
|
|
21
|
-
{isInternalURL(item.url) ? (
|
|
22
|
-
<SVGIcon name={lockSVG} size="20px" />
|
|
23
|
-
) : null}
|
|
24
|
-
</div>
|
|
25
|
-
</List.Content>
|
|
26
|
-
{item.description ? (
|
|
27
|
-
<span className="item-description">{item.description}</span>
|
|
28
|
-
) : null}
|
|
29
|
-
</List.Item>
|
|
30
|
-
);
|
|
31
|
-
})}
|
|
32
|
-
{(dataset['DOI'] || []).map((item, i) => {
|
|
33
|
-
return (
|
|
34
|
-
<List.Item key={i}>
|
|
35
|
-
<List.Content>
|
|
36
|
-
<div className="dataset-item">
|
|
37
|
-
<Icon className="info circle" />
|
|
38
|
-
<a href={item.url} className="item-link" target="_blank">
|
|
39
|
-
<span>{item.name || item.url}</span>
|
|
40
|
-
</a>
|
|
41
|
-
{isInternalURL(item.url) ? (
|
|
42
|
-
<SVGIcon name={lockSVG} size="20px" />
|
|
43
|
-
) : null}
|
|
44
|
-
</div>
|
|
45
|
-
</List.Content>
|
|
46
|
-
{item.description ? (
|
|
47
|
-
<span className="item-description">{item.description}</span>
|
|
48
|
-
) : null}
|
|
49
|
-
</List.Item>
|
|
50
|
-
);
|
|
51
|
-
})}
|
|
31
|
+
{(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) =>
|
|
32
|
+
renderListItem(item, i, 'linkify'),
|
|
33
|
+
)}
|
|
34
|
+
{(dataset['DOI'] || []).map((item, i) =>
|
|
35
|
+
renderListItem(item, i, 'info circle'),
|
|
36
|
+
)}
|
|
52
37
|
</List>
|
|
53
38
|
</>
|
|
54
39
|
) : null;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { isInternalURL } from '@eeacms/volto-datahub/utils';
|
|
3
5
|
|
|
4
6
|
import DatasetHttpLinks from './DatasetHttpLinks';
|
|
5
7
|
|
|
@@ -7,32 +9,71 @@ jest.mock('@eeacms/search', () => ({
|
|
|
7
9
|
runRequest: jest.fn(),
|
|
8
10
|
}));
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
protocol: 'https',
|
|
16
|
-
name: 'First',
|
|
17
|
-
description: 'Something here',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
DOI: [
|
|
21
|
-
{
|
|
22
|
-
id: 1,
|
|
23
|
-
url: 'https://example.org/1',
|
|
24
|
-
protocol: 'https',
|
|
25
|
-
name: 'First',
|
|
26
|
-
description: 'Something here',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
12
|
+
jest.mock('@eeacms/volto-datahub/utils', () => ({
|
|
13
|
+
isInternalURL: jest.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock('remixicon/icons/System/lock-line.svg', () => 'MockLockIcon');
|
|
30
17
|
|
|
31
18
|
describe('DatasetHttpLinks', () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
const dataset = {
|
|
20
|
+
'WWW:LINK-1.0-http--link': [
|
|
21
|
+
{
|
|
22
|
+
url: 'https://example.org/1',
|
|
23
|
+
name: 'Example Link',
|
|
24
|
+
description: 'This is an example link',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
DOI: [
|
|
28
|
+
{
|
|
29
|
+
url: 'https://doi.org/example',
|
|
30
|
+
name: 'Example DOI',
|
|
31
|
+
description: 'This is an example DOI',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
it('renders links section when dataset has WWW:LINK-1.0-http--link or DOI', () => {
|
|
37
|
+
render(<DatasetHttpLinks dataset={dataset} />);
|
|
38
|
+
|
|
39
|
+
expect(screen.getByText('Links:')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('does not render links section when dataset has no WWW:LINK-1.0-http--link or DOI', () => {
|
|
43
|
+
render(<DatasetHttpLinks dataset={{}} />);
|
|
44
|
+
|
|
45
|
+
expect(screen.queryByText('Links:')).not.toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('renders WWW:LINK-1.0-http--link items', () => {
|
|
49
|
+
render(<DatasetHttpLinks dataset={dataset} />);
|
|
50
|
+
|
|
51
|
+
expect(screen.getByText('Example Link')).toBeInTheDocument();
|
|
52
|
+
expect(screen.getByText('This is an example link')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('renders DOI items', () => {
|
|
56
|
+
render(<DatasetHttpLinks dataset={dataset} />);
|
|
57
|
+
|
|
58
|
+
expect(screen.getByText('Example DOI')).toBeInTheDocument();
|
|
59
|
+
expect(screen.getByText('This is an example DOI')).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('renders lock icon for internal URLs', () => {
|
|
63
|
+
isInternalURL.mockReturnValue(true);
|
|
64
|
+
const internalDataset = {
|
|
65
|
+
'WWW:LINK-1.0-http--link': [
|
|
66
|
+
{
|
|
67
|
+
url: 'https://internal.com',
|
|
68
|
+
name: 'Internal Link',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const { container } = render(
|
|
74
|
+
<DatasetHttpLinks dataset={internalDataset} />,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(container.querySelector('svg.icon')).toBeInTheDocument();
|
|
37
78
|
});
|
|
38
79
|
});
|
|
@@ -1,28 +1,63 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { groupBy } from '@eeacms/volto-datahub/utils';
|
|
4
|
+
import DatasetUrls from './DatasetUrls';
|
|
5
|
+
import DatasetLinks from './DatasetLinks';
|
|
6
|
+
import DatasetEsri from './DatasetEsri';
|
|
7
|
+
import DatasetHttpLinks from './DatasetHttpLinks';
|
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
9
|
|
|
4
10
|
import DatasetItemDownloadList from './DatasetItemDownloadList';
|
|
5
11
|
|
|
6
12
|
jest.mock('@eeacms/search', () => ({
|
|
7
13
|
runRequest: jest.fn(),
|
|
8
14
|
}));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mimeType: '',
|
|
14
|
-
protocol: 'WWW:URL',
|
|
15
|
-
url: 'https://example.org/1',
|
|
16
|
-
name: 'Direct download',
|
|
17
|
-
group: 0,
|
|
18
|
-
},
|
|
19
|
-
];
|
|
15
|
+
jest.mock('./DatasetUrls', () => jest.fn(() => null));
|
|
16
|
+
jest.mock('./DatasetLinks', () => jest.fn(() => null));
|
|
17
|
+
jest.mock('./DatasetEsri', () => jest.fn(() => null));
|
|
18
|
+
jest.mock('./DatasetHttpLinks', () => jest.fn(() => null));
|
|
20
19
|
|
|
21
20
|
describe('DatasetItemDownloadList', () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const link = [
|
|
22
|
+
{
|
|
23
|
+
function: 'download',
|
|
24
|
+
mimeType: '',
|
|
25
|
+
protocol: 'WWW:URL',
|
|
26
|
+
url: 'https://example.org/1',
|
|
27
|
+
name: 'Direct download',
|
|
28
|
+
group: 0,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
it('renders download section when dataset has WWW:URL, WWW:LINK, EEA:FILEPATH, or EEA:FOLDERPATH', () => {
|
|
33
|
+
const dataset = groupBy(link, 'protocol');
|
|
34
|
+
render(<DatasetItemDownloadList link={link} />);
|
|
35
|
+
|
|
36
|
+
expect(screen.getByText('Download:')).toBeInTheDocument();
|
|
37
|
+
expect(DatasetUrls).toHaveBeenCalledWith({ dataset }, expect.anything());
|
|
38
|
+
expect(DatasetLinks).toHaveBeenCalledWith({ dataset }, expect.anything());
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('does not render download section when dataset has no WWW:URL, WWW:LINK, EEA:FILEPATH, or EEA:FOLDERPATH', () => {
|
|
42
|
+
render(<DatasetItemDownloadList link={[]} />);
|
|
43
|
+
|
|
44
|
+
expect(screen.queryByText('Download:')).not.toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders DatasetEsri component', () => {
|
|
48
|
+
const dataset = groupBy(link, 'protocol');
|
|
49
|
+
render(<DatasetItemDownloadList link={link} />);
|
|
50
|
+
|
|
51
|
+
expect(DatasetEsri).toHaveBeenCalledWith({ dataset }, expect.anything());
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('renders DatasetHttpLinks component', () => {
|
|
55
|
+
const dataset = groupBy(link, 'protocol');
|
|
56
|
+
render(<DatasetItemDownloadList link={link} />);
|
|
57
|
+
|
|
58
|
+
expect(DatasetHttpLinks).toHaveBeenCalledWith(
|
|
59
|
+
{ dataset },
|
|
60
|
+
expect.anything(),
|
|
61
|
+
);
|
|
27
62
|
});
|
|
28
63
|
});
|
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { isInternalURL } from '@eeacms/volto-datahub/utils';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
5
|
|
|
4
6
|
import DatasetLinks from './DatasetLinks';
|
|
5
7
|
|
|
6
|
-
jest.mock('
|
|
7
|
-
|
|
8
|
+
jest.mock('remixicon/icons/System/lock-line.svg', () => 'MockLockIcon');
|
|
9
|
+
jest.mock('@eeacms/volto-datahub/utils', () => ({
|
|
10
|
+
isInternalURL: jest.fn(),
|
|
8
11
|
}));
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
describe('DatasetLinks', () => {
|
|
14
|
+
const dataset = {
|
|
15
|
+
'WWW:LINK': [
|
|
16
|
+
{
|
|
17
|
+
url: 'https://example.com/link1',
|
|
18
|
+
name: 'Link 1',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
url: 'https://example.com/link2',
|
|
22
|
+
name: '',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
it('renders links from the dataset', () => {
|
|
28
|
+
render(<DatasetLinks dataset={dataset} />);
|
|
29
|
+
|
|
30
|
+
expect(screen.getByText('Link 1')).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByText('Download link')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('renders lock icon for internal URLs', () => {
|
|
35
|
+
isInternalURL.mockReturnValue(true);
|
|
36
|
+
|
|
37
|
+
const { container } = render(<DatasetLinks dataset={dataset} />);
|
|
38
|
+
|
|
39
|
+
expect(container.querySelector('svg.icon')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('does not render lock icon for external URLs', () => {
|
|
43
|
+
isInternalURL.mockReturnValue(false);
|
|
44
|
+
|
|
45
|
+
const { container } = render(<DatasetLinks dataset={dataset} />);
|
|
46
|
+
|
|
47
|
+
expect(container.querySelector('svg.icon')).not.toBeInTheDocument();
|
|
26
48
|
});
|
|
27
49
|
});
|
|
@@ -1,25 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { isInternalURL } from '@eeacms/volto-datahub/utils';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
5
|
|
|
4
6
|
import DatasetUrls from './DatasetUrls';
|
|
5
7
|
|
|
6
|
-
jest.mock('
|
|
7
|
-
|
|
8
|
+
jest.mock('remixicon/icons/System/lock-line.svg', () => 'MockLockIcon');
|
|
9
|
+
jest.mock('@eeacms/volto-datahub/utils', () => ({
|
|
10
|
+
isInternalURL: jest.fn(),
|
|
8
11
|
}));
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
describe('DatasetUrls', () => {
|
|
14
|
+
const dataset = {
|
|
15
|
+
'WWW:URL': [
|
|
16
|
+
{
|
|
17
|
+
url: 'https://example.com/url1',
|
|
18
|
+
name: 'Direct download',
|
|
19
|
+
description: 'Download link description',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
url: 'https://example.com/url2',
|
|
23
|
+
name: '',
|
|
24
|
+
description: '',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it('renders URLs from the dataset', () => {
|
|
30
|
+
render(<DatasetUrls dataset={dataset} />);
|
|
31
|
+
|
|
32
|
+
expect(screen.getByText('Direct download')).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByTitle('Download link description')).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('renders lock icon for internal URLs', () => {
|
|
37
|
+
isInternalURL.mockReturnValue(true);
|
|
38
|
+
|
|
39
|
+
const { container } = render(<DatasetUrls dataset={dataset} />);
|
|
40
|
+
|
|
41
|
+
expect(container.querySelector('svg.icon')).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('does not render lock icon for external URLs', () => {
|
|
45
|
+
isInternalURL.mockReturnValue(false);
|
|
46
|
+
|
|
47
|
+
const { container } = render(<DatasetUrls dataset={dataset} />);
|
|
48
|
+
|
|
49
|
+
expect(container.querySelector('svg.icon')).not.toBeInTheDocument();
|
|
24
50
|
});
|
|
25
51
|
});
|
|
@@ -5,10 +5,8 @@ import { parseDatasets } from '@eeacms/volto-datahub/utils';
|
|
|
5
5
|
const DatasetsView = (props) => {
|
|
6
6
|
const { item, appConfig } = props;
|
|
7
7
|
const { children } = item?.raw_value?.raw || {};
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
groupedByArchivedOrRestricted,
|
|
11
|
-
} = parseDatasets(children);
|
|
8
|
+
const { groupedByTemporalCoverage, groupedByArchivedOrRestricted } =
|
|
9
|
+
parseDatasets(children);
|
|
12
10
|
|
|
13
11
|
return (
|
|
14
12
|
<>
|
|
@@ -84,6 +84,7 @@ const MetadataSection = (props) => {
|
|
|
84
84
|
`${appConfig.indexBaseUrl}/catalogue/datahub/api/records/` +
|
|
85
85
|
`${docid}/formatters/xsl-view?output=pdf&language=eng&approved=true`
|
|
86
86
|
}
|
|
87
|
+
rel="noopener"
|
|
87
88
|
>
|
|
88
89
|
Metadata Factsheet
|
|
89
90
|
</a>
|
|
@@ -94,6 +95,7 @@ const MetadataSection = (props) => {
|
|
|
94
95
|
<a
|
|
95
96
|
target="_blank"
|
|
96
97
|
href={`${appConfig.indexBaseUrl}/catalogue/srv/eng/catalog.search#/metadata/${docid}`}
|
|
98
|
+
rel="noopener"
|
|
97
99
|
>
|
|
98
100
|
Metadata catalogue
|
|
99
101
|
</a>
|
|
@@ -1,18 +1,72 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import MetadataSection from './MetadataSection';
|
|
5
5
|
|
|
6
|
-
describe('MetadataSection
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
describe('MetadataSection', () => {
|
|
7
|
+
const appConfig = {
|
|
8
|
+
indexBaseUrl: 'https://example.com',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const docid = '123';
|
|
12
|
+
|
|
13
|
+
it('renders metadata section when rod, organisations, or merged_time_coverage_range are available', () => {
|
|
14
|
+
const item = {
|
|
15
|
+
raw_value: {
|
|
16
|
+
raw: {
|
|
17
|
+
merged_time_coverage_range: [
|
|
18
|
+
{ start: '2020-01-01', end: '2020-12-31' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
organisation: {
|
|
23
|
+
raw: ['Organisation 1', 'Organisation 2'],
|
|
24
|
+
},
|
|
25
|
+
rod: {
|
|
26
|
+
raw: ['ROD 1', 'ROD 2'],
|
|
27
|
+
},
|
|
10
28
|
};
|
|
11
29
|
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
render(<MetadataSection item={item} appConfig={appConfig} docid={docid} />);
|
|
31
|
+
|
|
32
|
+
expect(screen.getByText('More information')).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByText('Reporting obligations (ROD)')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('ROD 1')).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByText('ROD 2')).toBeInTheDocument();
|
|
36
|
+
expect(screen.getByText('Organisation:')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByText('Organisation 1')).toBeInTheDocument();
|
|
38
|
+
expect(screen.getByText('Organisation 2')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Temporal coverage:')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByText('2020-01-01 - 2020-12-31')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not render metadata section when rod, organisations, and merged_time_coverage_range are not available', () => {
|
|
44
|
+
const item = {
|
|
45
|
+
raw_value: {
|
|
46
|
+
raw: {},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
render(<MetadataSection item={item} appConfig={appConfig} docid={docid} />);
|
|
51
|
+
|
|
52
|
+
expect(screen.queryByText('More information')).not.toBeInTheDocument();
|
|
53
|
+
expect(
|
|
54
|
+
screen.queryByText('Reporting obligations (ROD)'),
|
|
55
|
+
).not.toBeInTheDocument();
|
|
56
|
+
expect(screen.queryByText('Organisation:')).not.toBeInTheDocument();
|
|
57
|
+
expect(screen.queryByText('Temporal coverage:')).not.toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders metadata factsheet and catalogue links', () => {
|
|
61
|
+
render(<MetadataSection appConfig={appConfig} docid={docid} />);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByText('Metadata Factsheet')).toHaveAttribute(
|
|
64
|
+
'href',
|
|
65
|
+
`${appConfig.indexBaseUrl}/catalogue/datahub/api/records/${docid}/formatters/xsl-view?output=pdf&language=eng&approved=true`,
|
|
66
|
+
);
|
|
67
|
+
expect(screen.getByText('Metadata catalogue')).toHaveAttribute(
|
|
68
|
+
'href',
|
|
69
|
+
`${appConfig.indexBaseUrl}/catalogue/srv/eng/catalog.search#/metadata/${docid}`,
|
|
14
70
|
);
|
|
15
|
-
const json = component.toJSON();
|
|
16
|
-
expect(json).toMatchSnapshot();
|
|
17
71
|
});
|
|
18
72
|
});
|
|
@@ -1,15 +1,70 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { runRequest } from '@eeacms/search';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
5
|
|
|
4
6
|
import MoreLikeThis from './MoreLikeThis';
|
|
5
7
|
|
|
6
|
-
jest.mock('@eeacms/search', () =>
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
jest.mock('@eeacms/search', () => {
|
|
9
|
+
return {
|
|
10
|
+
runRequest: jest.fn(),
|
|
11
|
+
firstWords: jest.fn((word, length) =>
|
|
12
|
+
word.split(' ').slice(0, length).join(' '),
|
|
13
|
+
),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
9
16
|
|
|
10
17
|
describe('MoreLikeThis', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
const title = 'Test title';
|
|
19
|
+
const docid = '123';
|
|
20
|
+
const appConfig = {
|
|
21
|
+
index_name: 'test_index',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it('renders similar content section when data is returned', async () => {
|
|
25
|
+
runRequest.mockResolvedValueOnce({
|
|
26
|
+
body: {
|
|
27
|
+
hits: {
|
|
28
|
+
hits: [
|
|
29
|
+
{
|
|
30
|
+
_source: {
|
|
31
|
+
about: '456',
|
|
32
|
+
label: 'Similar item 1',
|
|
33
|
+
description: 'Description 1',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
_source: {
|
|
38
|
+
about: '789',
|
|
39
|
+
label: 'Similar item 2',
|
|
40
|
+
description: 'Description 2',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
render(<MoreLikeThis title={title} docid={docid} appConfig={appConfig} />);
|
|
49
|
+
|
|
50
|
+
expect(screen.queryByText('Similar content')).not.toBeInTheDocument();
|
|
51
|
+
|
|
52
|
+
await waitFor(() => {
|
|
53
|
+
expect(screen.getByText('Similar content')).toBeInTheDocument();
|
|
54
|
+
expect(screen.getByText('Similar item 1')).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText('Description 1')).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByText('Similar item 2')).toBeInTheDocument();
|
|
57
|
+
expect(screen.getByText('Description 2')).toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('does not render similar content section when no data is returned', async () => {
|
|
62
|
+
runRequest.mockResolvedValueOnce({ body: { hits: { hits: [] } } });
|
|
63
|
+
|
|
64
|
+
render(<MoreLikeThis title={title} docid={docid} appConfig={appConfig} />);
|
|
65
|
+
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
expect(screen.queryByText('Similar content')).not.toBeInTheDocument();
|
|
68
|
+
});
|
|
14
69
|
});
|
|
15
70
|
});
|
|
@@ -77,11 +77,11 @@ describe('groupBy', () => {
|
|
|
77
77
|
{ id: 1, name: 'test3' },
|
|
78
78
|
];
|
|
79
79
|
expect(groupBy(arr, 'id')).toEqual({
|
|
80
|
-
|
|
80
|
+
1: [
|
|
81
81
|
{ id: 1, name: 'test1' },
|
|
82
82
|
{ id: 1, name: 'test3' },
|
|
83
83
|
],
|
|
84
|
-
|
|
84
|
+
2: [{ id: 2, name: 'test2' }],
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -89,24 +89,6 @@ describe('groupBy', () => {
|
|
|
89
89
|
describe('SVGIcon', () => {
|
|
90
90
|
afterEach(cleanup);
|
|
91
91
|
|
|
92
|
-
it('should render SVGIcon correctly', () => {
|
|
93
|
-
const { container } = render(
|
|
94
|
-
<SVGIcon
|
|
95
|
-
name={{
|
|
96
|
-
attributes: {
|
|
97
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
98
|
-
viewBox: '0 0 32 32',
|
|
99
|
-
},
|
|
100
|
-
content: '<path d="M2 9h28l-14 14L2 9z"></path>',
|
|
101
|
-
}}
|
|
102
|
-
className={'test'}
|
|
103
|
-
title={'test title'}
|
|
104
|
-
size="32px"
|
|
105
|
-
/>,
|
|
106
|
-
);
|
|
107
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
92
|
it('should call onClick when clicked', () => {
|
|
111
93
|
const onClick = jest.fn();
|
|
112
94
|
const { container } = render(
|
package/src/config/facets.js
CHANGED
|
@@ -194,10 +194,12 @@ const facets = [
|
|
|
194
194
|
}),
|
|
195
195
|
];
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
const facetsWrapper = {
|
|
198
198
|
facets,
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
+
export default facetsWrapper;
|
|
202
|
+
|
|
201
203
|
// wrapper: 'ModalFacetWrapper',
|
|
202
204
|
// factory: 'MultiTermListFacet',
|
|
203
205
|
// histogramFacet({
|
package/src/config/filters.js
CHANGED
package/src/config/views.js
CHANGED
package/src/config/vocabulary.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -83,14 +83,13 @@ export function parseDatasets(children) {
|
|
|
83
83
|
const groupDatasets = (items) => {
|
|
84
84
|
const datasetsByCoverage = groupBy(items, 'temporalDateRange');
|
|
85
85
|
|
|
86
|
-
const sortedDatasets = Object.keys(datasetsByCoverage).sort(
|
|
87
|
-
a,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
86
|
+
const sortedDatasets = Object.keys(datasetsByCoverage).sort(
|
|
87
|
+
function (a, b) {
|
|
88
|
+
a = Math.max(...a.split('-'));
|
|
89
|
+
b = Math.max(...b.split('-'));
|
|
90
|
+
return b - a;
|
|
91
|
+
},
|
|
92
|
+
);
|
|
94
93
|
|
|
95
94
|
const groupedDatasets = sortedDatasets.map((v, i) => {
|
|
96
95
|
return { id: i, date: v, children: datasetsByCoverage[v] };
|