@eeacms/volto-slate-footnote 6.0.2 → 6.1.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ 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
+ ### [6.1.1](https://github.com/eea/volto-slate-footnote/compare/6.1.0...6.1.1) - 12 June 2023
8
+
9
+ #### :house: Internal changes
10
+
11
+ - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ded882a`](https://github.com/eea/volto-slate-footnote/commit/ded882a1ca1183c2ba74ff4246111123ee36e6cb)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`3e0749c`](https://github.com/eea/volto-slate-footnote/commit/3e0749cc5bd7f5810ac6fd7a3feee4df0435ee0a)]
16
+ - test: Add unit tests for utils - refs #253277 [ana-oprea - [`a709895`](https://github.com/eea/volto-slate-footnote/commit/a709895d9953742ef6d39f8d9673c06b2efe6a64)]
17
+ - test: Fix test config, coverage Refs #253277 [valentinab25 - [`dc4d6dc`](https://github.com/eea/volto-slate-footnote/commit/dc4d6dc9b39bfe2c892156f32c764153d1366486)]
18
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4f0ecee`](https://github.com/eea/volto-slate-footnote/commit/4f0ecee224d5d6604dfbb562556e45437edbb8ec)]
19
+ ### [6.1.0](https://github.com/eea/volto-slate-footnote/compare/6.0.2...6.1.0) - 27 March 2023
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`23959ee`](https://github.com/eea/volto-slate-footnote/commit/23959ee43d45ec5eaa483590415a75fc58faae03)]
24
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`7aa6f34`](https://github.com/eea/volto-slate-footnote/commit/7aa6f3439953cc3d8f28875eff9fbcc24084cbc7)]
25
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b117d15`](https://github.com/eea/volto-slate-footnote/commit/b117d15e51b3cf10717b9dd9dfef8304d46ad556)]
26
+ - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`97ed8fb`](https://github.com/eea/volto-slate-footnote/commit/97ed8fbd92f76c2b3128b62cdc1a77611e79410a)]
27
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`cb22f5e`](https://github.com/eea/volto-slate-footnote/commit/cb22f5e8e9d3aed0a3b4374b6d4d80c8c2bb66e1)]
28
+ - yarn 3 [Alin Voinea - [`f5bb904`](https://github.com/eea/volto-slate-footnote/commit/f5bb904eecf740ffd57dbccf9a597c99ea2dfc0c)]
29
+ - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`59cf6d3`](https://github.com/eea/volto-slate-footnote/commit/59cf6d334a460e373dda3e2e28754fcdd9fb0281)]
7
30
  ### [6.0.2](https://github.com/eea/volto-slate-footnote/compare/6.0.1...6.0.2) - 16 November 2022
8
31
 
9
32
  #### :hammer_and_wrench: Others
package/Jenkinsfile CHANGED
@@ -4,9 +4,9 @@ pipeline {
4
4
  environment {
5
5
  GIT_NAME = "volto-slate-footnote"
6
6
  NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine"
7
+ SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
8
8
  DEPENDENCIES = ""
9
- VOLTO = "alpha"
9
+ VOLTO = ""
10
10
  }
11
11
 
12
12
  stages {
@@ -41,19 +41,19 @@ pipeline {
41
41
 
42
42
  "ES lint": {
43
43
  node(label: 'docker') {
44
- sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e VOLTO=$VOLTO -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci:alpha eslint'''
44
+ sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e VOLTO=$VOLTO -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci eslint'''
45
45
  }
46
46
  },
47
47
 
48
48
  "Style lint": {
49
49
  node(label: 'docker') {
50
- sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e VOLTO=$VOLTO -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci:alpha stylelint'''
50
+ sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e VOLTO=$VOLTO -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci stylelint'''
51
51
  }
52
52
  },
53
53
 
54
54
  "Prettier": {
55
55
  node(label: 'docker') {
56
- sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e VOLTO=$VOLTO -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci:alpha prettier'''
56
+ sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e VOLTO=$VOLTO -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" plone/volto-addon-ci prettier'''
57
57
  }
58
58
  }
59
59
  )
@@ -77,8 +77,8 @@ pipeline {
77
77
  node(label: 'docker') {
78
78
  script {
79
79
  try {
80
- sh '''docker pull plone/volto-addon-ci:alpha'''
81
- sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha'''
80
+ sh '''docker pull plone/volto-addon-ci'''
81
+ sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci'''
82
82
  sh '''rm -rf xunit-reports'''
83
83
  sh '''mkdir -p xunit-reports'''
84
84
  sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
@@ -126,7 +126,7 @@ pipeline {
126
126
  script {
127
127
  try {
128
128
  sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
129
- sh '''docker pull plone/volto-addon-ci:alpha; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO="$VOLTO" plone/volto-addon-ci:alpha cypress'''
129
+ sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO="$VOLTO" plone/volto-addon-ci cypress'''
130
130
  } finally {
131
131
  try {
132
132
  sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
@@ -188,6 +188,7 @@ pipeline {
188
188
  def nodeJS = tool 'NodeJS';
189
189
  withSonarQubeEnv('Sonarqube') {
190
190
  sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
191
+ sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
191
192
  sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
192
193
  sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
193
194
  }
@@ -5,19 +5,19 @@ module.exports = {
5
5
  '!src/**/*.d.ts',
6
6
  ],
7
7
  moduleNameMapper: {
8
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
8
9
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
9
10
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
10
11
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
11
12
  '@package/(.*)$': '<rootDir>/src/$1',
12
13
  '@root/(.*)$': '<rootDir>/src/$1',
13
14
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
14
- '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
15
+ '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
15
16
  '@plone/volto-slate':
16
17
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
17
18
  '~/(.*)$': '<rootDir>/src/$1',
18
19
  'load-volto-addons':
19
20
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
20
- '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
21
21
  },
22
22
  transform: {
23
23
  '^.+\\.js(x)?$': 'babel-jest',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-slate-footnote",
3
- "version": "6.0.2",
3
+ "version": "6.1.1",
4
4
  "description": "volto-slate-footnote: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -19,10 +19,9 @@
19
19
  "url": "git@github.com:eea/volto-slate-footnote.git"
20
20
  },
21
21
  "addons": [],
22
- "dependencies": {},
23
22
  "devDependencies": {
24
- "@plone/scripts": "*",
25
23
  "@cypress/code-coverage": "^3.10.0",
24
+ "@plone/scripts": "*",
26
25
  "babel-plugin-transform-class-properties": "^6.24.1",
27
26
  "md5": "^2.3.0"
28
27
  },
@@ -0,0 +1,213 @@
1
+ import {
2
+ makeFootnote,
3
+ openAccordionIfContainsFootnoteReference,
4
+ getAllBlocksAndSlateFields,
5
+ } from './utils';
6
+ import { getAllBlocks } from '@plone/volto-slate/utils';
7
+
8
+ jest.mock('@plone/volto-slate/utils', () => ({
9
+ getAllBlocks: jest.fn(),
10
+ }));
11
+
12
+ describe('makeFootnote', () => {
13
+ it('should remove xml version string from footnote', () => {
14
+ const xmlString = '<?xml version="1.0"?>Test text';
15
+ const expectedResult = 'Test text';
16
+ expect(makeFootnote(xmlString)).toEqual(expectedResult);
17
+ });
18
+
19
+ it('should return empty string when footnote is null or undefined', () => {
20
+ expect(makeFootnote(null)).toEqual('');
21
+ expect(makeFootnote(undefined)).toEqual('');
22
+ });
23
+ });
24
+
25
+ describe('openAccordionIfContainsFootnoteReference', () => {
26
+ it('should open accordion if it contains footnote reference', () => {
27
+ document.body.innerHTML = `
28
+ <div class="accordion">
29
+ <div class="title">Accordion</div>
30
+ <div id="footnote">Footnote</div>
31
+ </div>
32
+ `;
33
+
34
+ const title = document.querySelector('.title');
35
+ title.click = jest.fn();
36
+
37
+ openAccordionIfContainsFootnoteReference('#footnote');
38
+
39
+ expect(title.click).toHaveBeenCalled();
40
+ });
41
+
42
+ it('should not do anything if accordion does not contain footnote reference', () => {
43
+ document.body.innerHTML = `
44
+ <div class="accordion">
45
+ <div class="title">Accordion</div>
46
+ </div>
47
+ `;
48
+
49
+ const title = document.querySelector('.title');
50
+ title.click = jest.fn();
51
+
52
+ openAccordionIfContainsFootnoteReference('#footnote');
53
+
54
+ expect(title.click).not.toHaveBeenCalled();
55
+ });
56
+ });
57
+
58
+ describe('getAllBlocksAndSlateFields', () => {
59
+ afterEach(() => {
60
+ jest.clearAllMocks();
61
+ });
62
+
63
+ it('handles metadataSection correctly', () => {
64
+ const properties = { '1': ['test'] };
65
+ const blocks = [
66
+ {
67
+ '@type': 'metadataSection',
68
+ fields: [
69
+ { field: { widget: 'slate', id: '1' } },
70
+ { field: { widget: 'other', id: '2' } },
71
+ ],
72
+ },
73
+ ];
74
+ getAllBlocks.mockReturnValue(blocks);
75
+
76
+ const expected = [{ '@type': 'slate', id: '1', value: ['test'] }];
77
+ const result = getAllBlocksAndSlateFields(properties);
78
+
79
+ expect(result).toEqual(expected);
80
+ });
81
+
82
+ it('handles metadataSection correctly with no properties', () => {
83
+ const properties = {};
84
+ const blocks = [
85
+ {
86
+ '@type': 'metadataSection',
87
+ fields: [
88
+ { field: { widget: 'slate', id: '1' } },
89
+ { field: { widget: 'other', id: '2' } },
90
+ ],
91
+ },
92
+ ];
93
+ getAllBlocks.mockReturnValue(blocks);
94
+
95
+ const result = getAllBlocksAndSlateFields(properties);
96
+
97
+ expect(result).toEqual([]);
98
+ });
99
+
100
+ it('handles metadata correctly', () => {
101
+ const properties = { '1': ['metadata test'] };
102
+ const blocks = [
103
+ {
104
+ '@type': 'metadata',
105
+ data: { id: '1', widget: 'slate' },
106
+ },
107
+ ];
108
+ getAllBlocks.mockReturnValue(blocks);
109
+
110
+ const expected = [{ '@type': 'slate', id: '1', value: ['metadata test'] }];
111
+ const result = getAllBlocksAndSlateFields(properties);
112
+
113
+ expect(result).toEqual(expected);
114
+ });
115
+
116
+ it('handles metadata correctly with no properties', () => {
117
+ const properties = {};
118
+ const blocks = [
119
+ {
120
+ '@type': 'metadata',
121
+ data: { id: '1', widget: 'slate' },
122
+ },
123
+ ];
124
+ getAllBlocks.mockReturnValue(blocks);
125
+
126
+ const expected = [{ '@type': 'slate', id: '1', value: null }];
127
+ const result = getAllBlocksAndSlateFields(properties);
128
+
129
+ expect(result).toEqual(expected);
130
+ });
131
+
132
+ it('handles metadata correctly with no slate widgets', () => {
133
+ const properties = {};
134
+ const blocks = [
135
+ {
136
+ '@type': 'metadata',
137
+ data: { id: '1', widget: 'test' },
138
+ },
139
+ ];
140
+ getAllBlocks.mockReturnValue(blocks);
141
+
142
+ const expected = [];
143
+ const result = getAllBlocksAndSlateFields(properties);
144
+
145
+ expect(result).toEqual(expected);
146
+ });
147
+
148
+ it('handles slateTable correctly', () => {
149
+ const properties = {};
150
+ const blocks = [
151
+ {
152
+ '@type': 'slateTable',
153
+ table: {
154
+ rows: [{ cells: [{ cell1: '1' }, { cell2: '2' }] }],
155
+ },
156
+ },
157
+ ];
158
+ getAllBlocks.mockReturnValue(blocks);
159
+
160
+ const expected = [
161
+ { '@type': 'slate', cell1: '1' },
162
+ { '@type': 'slate', cell2: '2' },
163
+ ];
164
+ const result = getAllBlocksAndSlateFields(properties);
165
+
166
+ expect(result).toEqual(expected);
167
+ });
168
+
169
+ it('handles slateTable correctly with no rows', () => {
170
+ const properties = {};
171
+ const blocks = [
172
+ {
173
+ '@type': 'slateTable',
174
+ table: {},
175
+ },
176
+ ];
177
+ getAllBlocks.mockReturnValue(blocks);
178
+
179
+ const expected = [];
180
+ const result = getAllBlocksAndSlateFields(properties);
181
+
182
+ expect(result).toEqual(expected);
183
+ });
184
+
185
+ it('handles slateTable correctly with no cells', () => {
186
+ const properties = {};
187
+ const blocks = [
188
+ {
189
+ '@type': 'slateTable',
190
+ table: {
191
+ rows: [{ cells: undefined }],
192
+ },
193
+ },
194
+ ];
195
+ getAllBlocks.mockReturnValue(blocks);
196
+
197
+ const expected = [];
198
+ const result = getAllBlocksAndSlateFields(properties);
199
+
200
+ expect(result).toEqual(expected);
201
+ });
202
+
203
+ it('handles defaultOperation correctly', () => {
204
+ const properties = {};
205
+ const blocks = [{ block: '1', '@type': 'testType' }];
206
+ getAllBlocks.mockReturnValue(blocks);
207
+
208
+ const expected = [blocks[0]];
209
+ const result = getAllBlocksAndSlateFields(properties);
210
+
211
+ expect(result).toEqual(expected);
212
+ });
213
+ });