diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d10bb..99d4e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,22 @@ 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.2](https://github.com/eea/volto-block-divider/compare/6.1.1...6.1.2) - 12 June 2023 + +#### :house: Internal changes + +- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`025726b`](https://github.com/eea/volto-block-divider/commit/025726b23acb6069d001e533ac6f168d36a212a3)] + +#### :hammer_and_wrench: Others + +- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`628e909`](https://github.com/eea/volto-block-divider/commit/628e909d54d08ec5cd3678ea7da4286ff6859db9)] +- test: Add unit tests for View - refs #253277 [ana-oprea - [`9ed24a5`](https://github.com/eea/volto-block-divider/commit/9ed24a5b962dc8e87f1958130edb06c8d81685de)] +- test: Fix test config, coverage Refs #253277 [valentinab25 - [`a09cfca`](https://github.com/eea/volto-block-divider/commit/a09cfca3a3ad812807f2b1b1e54f4ae11e312a87)] ### [6.1.1](https://github.com/eea/volto-block-divider/compare/6.1.0...6.1.1) - 5 April 2023 #### :bug: Bug Fixes +- fix(divider): short width option #21 from eea/develop [ichim-david - [`f59a309`](https://github.com/eea/volto-block-divider/commit/f59a309fd8862ce0d736fc84be42da9b34c3ab72)] - fix(divider): short option width difference on view render #20 from eea/divider-short-fix [ichim-david - [`d3c10f0`](https://github.com/eea/volto-block-divider/commit/d3c10f077bd8845360a40a01a6af51bb7f5b0fe9)] #### :nail_care: Enhancements diff --git a/Jenkinsfile b/Jenkinsfile index 59ac686..7df0c9a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { GIT_NAME = "volto-block-divider" 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,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" DEPENDENCIES = "" VOLTO = "" } @@ -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''' } diff --git a/jest-addon.config.js b/jest-addon.config.js index da38318..3c86610 100644 --- a/jest-addon.config.js +++ b/jest-addon.config.js @@ -5,19 +5,19 @@ module.exports = { '!src/**/*.d.ts', ], moduleNameMapper: { + '\\.(css|less|scss|sass)$': 'identity-obj-proxy', '@plone/volto/cypress': '/node_modules/@plone/volto/cypress', '@plone/volto/babel': '/node_modules/@plone/volto/babel', '@plone/volto/(.*)$': '/node_modules/@plone/volto/src/$1', '@package/(.*)$': '/src/$1', '@root/(.*)$': '/src/$1', '@plone/volto-quanta/(.*)$': '/src/addons/volto-quanta/src/$1', - '@eeacms/(.*?)/(.*)$': '/src/addons/$1/src/$2', + '@eeacms/(.*?)/(.*)$': '/node_modules/@eeacms/$1/src/$2', '@plone/volto-slate': '/node_modules/@plone/volto/packages/volto-slate/src', '~/(.*)$': '/src/$1', 'load-volto-addons': '/node_modules/@plone/volto/jest-addons-loader.js', - '\\.(css|less|scss|sass)$': 'identity-obj-proxy', }, transform: { '^.+\\.js(x)?$': 'babel-jest', diff --git a/package.json b/package.json index 095990a..ac0e0c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-block-divider", - "version": "6.1.1", + "version": "6.1.2", "description": "volto-block-divider: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", diff --git a/src/components/Divider/View.test.jsx b/src/components/Divider/View.test.jsx new file mode 100644 index 0000000..5e33916 --- /dev/null +++ b/src/components/Divider/View.test.jsx @@ -0,0 +1,103 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import View from './View'; + +describe('View', () => { + it('should render the component', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + }); + + it('should render the component with prop hidden', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('hidden'); + }); + + it('should render the component with prop section', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('section'); + }); + + it('should render the component with prop fitted', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('fitted'); + }); + + it('should render the component with prop text', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('horizontal'); + }); + + it('should render the component with prop styles with theme', () => { + const component = renderer.create( + , + ); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.props.className).toContain('test'); + expect(json.props.className).toContain('inverted'); + }); + + it('should render the component with prop styles, with no theme', () => { + const component = renderer.create( + , + ); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('inverted'); + }); + + it('should render the component with short', () => { + const component = renderer.create(); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('short'); + }); + + it('should render the component with all props with no theme', () => { + const component = renderer.create( + , + ); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.children[0].props.className).toContain('hidden'); + expect(json.children[0].props.className).toContain('fitted'); + expect(json.children[0].props.className).toContain('inverted'); + expect(json.children[0].props.className).toContain('horizontal'); + }); + + it('should render the component with all props with theme', () => { + const component = renderer.create( + , + ); + const json = component.toJSON(); + expect(json).toMatchSnapshot(); + expect(json.props.className).toContain('hidden'); + expect(json.props.className).toContain('fitted'); + expect(json.props.className).toContain('inverted'); + expect(json.props.className).toContain('horizontal'); + }); +}); diff --git a/src/components/Divider/__snapshots__/View.test.jsx.snap b/src/components/Divider/__snapshots__/View.test.jsx.snap new file mode 100644 index 0000000..9d98cdf --- /dev/null +++ b/src/components/Divider/__snapshots__/View.test.jsx.snap @@ -0,0 +1,119 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`View should render the component 1`] = ` +
+
+ +
+
+`; + +exports[`View should render the component with all props with no theme 1`] = ` +
+
+
+ test test +
+
+
+`; + +exports[`View should render the component with all props with theme 1`] = ` +
+
+ test test +
+
+`; + +exports[`View should render the component with prop fitted 1`] = ` +
+
+ +
+
+`; + +exports[`View should render the component with prop hidden 1`] = ` +
+
+ +
+
+`; + +exports[`View should render the component with prop section 1`] = ` +
+
+ +
+
+`; + +exports[`View should render the component with prop styles with theme 1`] = ` +
+ +
+`; + +exports[`View should render the component with prop styles, with no theme 1`] = ` +
+
+ +
+
+`; + +exports[`View should render the component with prop text 1`] = ` +
+
+
+ test test +
+
+
+`; + +exports[`View should render the component with short 1`] = ` +
+
+ +
+
+`;