Skip to content

Commit

Permalink
Merge pull request #41 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea authored Jun 12, 2023
2 parents df668c8 + 79112be commit 6680fbc
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 5 deletions.
32 changes: 31 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [6.1.1](https://github.com/eea/volto-slate-footnote/compare/6.1.0...6.1.1) - 12 June 2023

#### :house: Internal changes

- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ded882a`](https://github.com/eea/volto-slate-footnote/commit/ded882a1ca1183c2ba74ff4246111123ee36e6cb)]

#### :hammer_and_wrench: Others

- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`3e0749c`](https://github.com/eea/volto-slate-footnote/commit/3e0749cc5bd7f5810ac6fd7a3feee4df0435ee0a)]
- test: Add unit tests for utils - refs #253277 [ana-oprea - [`a709895`](https://github.com/eea/volto-slate-footnote/commit/a709895d9953742ef6d39f8d9673c06b2efe6a64)]
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`dc4d6dc`](https://github.com/eea/volto-slate-footnote/commit/dc4d6dc9b39bfe2c892156f32c764153d1366486)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4f0ecee`](https://github.com/eea/volto-slate-footnote/commit/4f0ecee224d5d6604dfbb562556e45437edbb8ec)]
### [6.1.0](https://github.com/eea/volto-slate-footnote/compare/6.0.2...6.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Release 6.2.0 [Alin Voinea - [`d676d92`](https://github.com/eea/volto-slate-footnote/commit/d676d9229212cb61e2db9fb412f11646ba9272ca)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`23959ee`](https://github.com/eea/volto-slate-footnote/commit/23959ee43d45ec5eaa483590415a75fc58faae03)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`7aa6f34`](https://github.com/eea/volto-slate-footnote/commit/7aa6f3439953cc3d8f28875eff9fbcc24084cbc7)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b117d15`](https://github.com/eea/volto-slate-footnote/commit/b117d15e51b3cf10717b9dd9dfef8304d46ad556)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`97ed8fb`](https://github.com/eea/volto-slate-footnote/commit/97ed8fbd92f76c2b3128b62cdc1a77611e79410a)]
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`cb22f5e`](https://github.com/eea/volto-slate-footnote/commit/cb22f5e8e9d3aed0a3b4374b6d4d80c8c2bb66e1)]
- yarn 3 [Alin Voinea - [`f5bb904`](https://github.com/eea/volto-slate-footnote/commit/f5bb904eecf740ffd57dbccf9a597c99ea2dfc0c)]
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`59cf6d3`](https://github.com/eea/volto-slate-footnote/commit/59cf6d334a460e373dda3e2e28754fcdd9fb0281)]
### [6.0.2](https://github.com/eea/volto-slate-footnote/compare/6.0.1...6.0.2) - 16 November 2022

#### :hammer_and_wrench: Others
Expand All @@ -25,34 +42,45 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`dc3c7de`](https://github.com/eea/volto-slate-footnote/commit/dc3c7deaa8c692689ea0cec66cf019f05f9c4e22)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`133969a`](https://github.com/eea/volto-slate-footnote/commit/133969a37a6153a19af121d2f6031a70bc67cc9d)]
### [5.0.1](https://github.com/eea/volto-slate-footnote/compare/5.0.0...5.0.1) - 30 June 2022

#### :hammer_and_wrench: Others

- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4d5af13`](https://github.com/eea/volto-slate-footnote/commit/4d5af1345aad9071c031f7f00efd6bc5da04541f)]
## [5.0.0](https://github.com/eea/volto-slate-footnote/compare/4.0.5...5.0.0) - 19 May 2022

### [4.0.5](https://github.com/eea/volto-slate-footnote/compare/4.0.4...4.0.5) - 17 May 2022

#### :hammer_and_wrench: Others

- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`85a16ee`](https://github.com/eea/volto-slate-footnote/commit/85a16ee73d21d696282dc24933169d3c31383027)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`418349c`](https://github.com/eea/volto-slate-footnote/commit/418349ce22d98bf5dee58130d6f1cb9f45bbaa46)]
### [4.0.4](https://github.com/eea/volto-slate-footnote/compare/4.0.3...4.0.4) - 3 January 2022

### [4.0.3](https://github.com/eea/volto-slate-footnote/compare/4.0.2...4.0.3) - 18 December 2021

#### :hammer_and_wrench: Others

- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`ad06940`](https://github.com/eea/volto-slate-footnote/commit/ad0694074a06eb56ec1891256b262e9854c0303d)]
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`1081079`](https://github.com/eea/volto-slate-footnote/commit/1081079444f5ac806e9d56765c4ccf0b9e415a73)]
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`307687b`](https://github.com/eea/volto-slate-footnote/commit/307687b93d966e0df5c4a3f813dbb19442d2e169)]
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`0460e2a`](https://github.com/eea/volto-slate-footnote/commit/0460e2a73a4c8ede00b0c1fc3f05624eaa345a33)]
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`8aecee9`](https://github.com/eea/volto-slate-footnote/commit/8aecee99f11387e4ce31825209798772d7fee060)]
### [4.0.2](https://github.com/eea/volto-slate-footnote/compare/4.0.1...4.0.2) - 30 September 2021

#### :hammer_and_wrench: Others

- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`cf33efe`](https://github.com/eea/volto-slate-footnote/commit/cf33efec91b4b8d13562b8c8f660e7a78191d9e0)]
- Remove :asDefault dependency from volto-slate [Alin Voinea - [`13dad5e`](https://github.com/eea/volto-slate-footnote/commit/13dad5ed23043fa7a24682e1ac6addc86632bfe0)]
### [4.0.1](https://github.com/eea/volto-slate-footnote/compare/4.0.0...4.0.1) - 29 September 2021

## [4.0.0](https://github.com/eea/volto-slate-footnote/compare/3.2.0...4.0.0) - 24 September 2021

#### :hammer_and_wrench: Others

- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`80a159b`](https://github.com/eea/volto-slate-footnote/commit/80a159bb67698cddedadc494e7ae2da32a96faea)]
### [3.2.0](https://github.com/eea/volto-slate-footnote/compare/3.1.1...3.2.0) - 13 September 2021

#### :hammer_and_wrench: Others
Expand All @@ -65,6 +93,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Remove console.log [Alin Voinea - [`b5d83e7`](https://github.com/eea/volto-slate-footnote/commit/b5d83e7c13240151f602d122ecf09ba9b8e335f3)]
- Fix slate json field default value in DX layout [Alin Voinea - [`f2805bb`](https://github.com/eea/volto-slate-footnote/commit/f2805bbc15c51ebd914ee5f4eb9dd34ef32e095b)]
- Fix cypress api_url [Alin Voinea - [`6a4966a`](https://github.com/eea/volto-slate-footnote/commit/6a4966a2f92e932e1d0df35351989cda535f15c8)]
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`aed3984`](https://github.com/eea/volto-slate-footnote/commit/aed39840ecd467689eaf0adb352bd00ce95bdbbe)]
### [3.1.0](https://github.com/eea/volto-slate-footnote/compare/3.0.0...3.1.0) - 9 September 2021

#### :hammer_and_wrench: Others
Expand All @@ -85,6 +114,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Bump version to 2.4.0 [Alin Voinea - [`bef0d34`](https://github.com/eea/volto-slate-footnote/commit/bef0d34c2b9c20915578ffaefb4fd30cbf42f0a1)]
- Fix Slate point from DOM crash [Alin Voinea - [`c852f79`](https://github.com/eea/volto-slate-footnote/commit/c852f7987ffe8db433235b70792002d40ade690f)]
- Fix crash on copy&paste beforeInsert condition [Alin Voinea - [`85172cf`](https://github.com/eea/volto-slate-footnote/commit/85172cff3e2ea95a86d4b4fb452f3c0287b80e8f)]
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`b471c41`](https://github.com/eea/volto-slate-footnote/commit/b471c418d198b1bde95acfe0b256f642bacc6865)]
### [2.3.1](https://github.com/eea/volto-slate-footnote/compare/2.3.0...2.3.1) - 25 June 2021

### [2.3.0](https://github.com/eea/volto-slate-footnote/compare/2.2.2...2.3.0) - 12 June 2021
Expand Down
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
environment {
GIT_NAME = "volto-slate-footnote"
NAMESPACE = "@eeacms"
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,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
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"
DEPENDENCIES = ""
VOLTO = ""
}
Expand Down Expand Up @@ -188,6 +188,7 @@ pipeline {
def nodeJS = tool 'NodeJS';
withSonarQubeEnv('Sonarqube') {
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
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"
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'''
}
Expand Down
4 changes: 2 additions & 2 deletions jest-addon.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module.exports = {
'!src/**/*.d.ts',
],
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
'@package/(.*)$': '<rootDir>/src/$1',
'@root/(.*)$': '<rootDir>/src/$1',
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
'@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
'@plone/volto-slate':
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
'~/(.*)$': '<rootDir>/src/$1',
'load-volto-addons':
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
},
transform: {
'^.+\\.js(x)?$': 'babel-jest',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-slate-footnote",
"version": "6.1.0",
"version": "6.1.1",
"description": "volto-slate-footnote: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
213 changes: 213 additions & 0 deletions src/editor/utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import {
makeFootnote,
openAccordionIfContainsFootnoteReference,
getAllBlocksAndSlateFields,
} from './utils';
import { getAllBlocks } from '@plone/volto-slate/utils';

jest.mock('@plone/volto-slate/utils', () => ({
getAllBlocks: jest.fn(),
}));

describe('makeFootnote', () => {
it('should remove xml version string from footnote', () => {
const xmlString = '<?xml version="1.0"?>Test text';
const expectedResult = 'Test text';
expect(makeFootnote(xmlString)).toEqual(expectedResult);
});

it('should return empty string when footnote is null or undefined', () => {
expect(makeFootnote(null)).toEqual('');
expect(makeFootnote(undefined)).toEqual('');
});
});

describe('openAccordionIfContainsFootnoteReference', () => {
it('should open accordion if it contains footnote reference', () => {
document.body.innerHTML = `
<div class="accordion">
<div class="title">Accordion</div>
<div id="footnote">Footnote</div>
</div>
`;

const title = document.querySelector('.title');
title.click = jest.fn();

openAccordionIfContainsFootnoteReference('#footnote');

expect(title.click).toHaveBeenCalled();
});

it('should not do anything if accordion does not contain footnote reference', () => {
document.body.innerHTML = `
<div class="accordion">
<div class="title">Accordion</div>
</div>
`;

const title = document.querySelector('.title');
title.click = jest.fn();

openAccordionIfContainsFootnoteReference('#footnote');

expect(title.click).not.toHaveBeenCalled();
});
});

describe('getAllBlocksAndSlateFields', () => {
afterEach(() => {
jest.clearAllMocks();
});

it('handles metadataSection correctly', () => {
const properties = { '1': ['test'] };
const blocks = [
{
'@type': 'metadataSection',
fields: [
{ field: { widget: 'slate', id: '1' } },
{ field: { widget: 'other', id: '2' } },
],
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [{ '@type': 'slate', id: '1', value: ['test'] }];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles metadataSection correctly with no properties', () => {
const properties = {};
const blocks = [
{
'@type': 'metadataSection',
fields: [
{ field: { widget: 'slate', id: '1' } },
{ field: { widget: 'other', id: '2' } },
],
},
];
getAllBlocks.mockReturnValue(blocks);

const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual([]);
});

it('handles metadata correctly', () => {
const properties = { '1': ['metadata test'] };
const blocks = [
{
'@type': 'metadata',
data: { id: '1', widget: 'slate' },
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [{ '@type': 'slate', id: '1', value: ['metadata test'] }];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles metadata correctly with no properties', () => {
const properties = {};
const blocks = [
{
'@type': 'metadata',
data: { id: '1', widget: 'slate' },
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [{ '@type': 'slate', id: '1', value: null }];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles metadata correctly with no slate widgets', () => {
const properties = {};
const blocks = [
{
'@type': 'metadata',
data: { id: '1', widget: 'test' },
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles slateTable correctly', () => {
const properties = {};
const blocks = [
{
'@type': 'slateTable',
table: {
rows: [{ cells: [{ cell1: '1' }, { cell2: '2' }] }],
},
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [
{ '@type': 'slate', cell1: '1' },
{ '@type': 'slate', cell2: '2' },
];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles slateTable correctly with no rows', () => {
const properties = {};
const blocks = [
{
'@type': 'slateTable',
table: {},
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles slateTable correctly with no cells', () => {
const properties = {};
const blocks = [
{
'@type': 'slateTable',
table: {
rows: [{ cells: undefined }],
},
},
];
getAllBlocks.mockReturnValue(blocks);

const expected = [];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});

it('handles defaultOperation correctly', () => {
const properties = {};
const blocks = [{ block: '1', '@type': 'testType' }];
getAllBlocks.mockReturnValue(blocks);

const expected = [blocks[0]];
const result = getAllBlocksAndSlateFields(properties);

expect(result).toEqual(expected);
});
});

0 comments on commit 6680fbc

Please sign in to comment.