From 972e5931504f2e0ab866b5c5f8d2b9e1bb5053b9 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Tue, 2 Nov 2021 12:53:29 +0200 Subject: [PATCH 1/3] Enables cypress tests -> don't wait for breadcrumbs --- Jenkinsfile | 95 +++--- README.md | 2 + cypress/support/index.js | 2 +- .../components/theme/View/DefaultView.jsx | 122 -------- .../volto/components/theme/View/View.jsx | 284 ------------------ src/index.js | 16 +- 6 files changed, 59 insertions(+), 462 deletions(-) delete mode 100644 src/customizations/volto/components/theme/View/DefaultView.jsx delete mode 100644 src/customizations/volto/components/theme/View/View.jsx diff --git a/Jenkinsfile b/Jenkinsfile index 6487e23..029912f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,52 +74,52 @@ pipeline { } } - // stage('Integration tests') { - // steps { - // parallel( - - // "Cypress": { - // node(label: 'docker') { - // script { - // try { - // sh '''docker pull plone; docker run -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg''' - // 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" plone/volto-addon-ci cypress''' - // } finally { - // try { - // sh '''rm -rf cypress-reports cypress-results cypress-coverage''' - // sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' - // coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true - // if ( coverage == 0 ) { - // publishHTML (target : [allowMissing: false, - // alwaysLinkToLastBuild: true, - // keepAll: true, - // reportDir: 'cypress-coverage/coverage/lcov-report', - // reportFiles: 'index.html', - // reportName: 'CypressCoverage', - // reportTitles: 'Integration Tests Code Coverage']) - // } - // archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: true - // stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true - // } - // finally { - // catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - // junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true - // } - // sh script: "docker stop $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true - - // } - // } - // } - // } - // } - - // ) - // } - // } + stage('Integration tests') { + steps { + parallel( + + "Cypress": { + node(label: 'docker') { + script { + try { + sh '''docker pull plone; docker run -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg''' + 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" plone/volto-addon-ci cypress''' + } finally { + try { + sh '''rm -rf cypress-reports cypress-results cypress-coverage''' + sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' + sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' + sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' + coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true + if ( coverage == 0 ) { + publishHTML (target : [allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'cypress-coverage/coverage/lcov-report', + reportFiles: 'index.html', + reportName: 'CypressCoverage', + reportTitles: 'Integration Tests Code Coverage']) + } + archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: true + stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true + } + finally { + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true + } + sh script: "docker stop $BUILD_TAG-plone", returnStatus: true + sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true + sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true + + } + } + } + } + } + + ) + } + } stage('Report to SonarQube') { // Exclude Pull-Requests @@ -138,8 +138,7 @@ pipeline { def nodeJS = tool 'NodeJS11'; withSonarQubeEnv('Sonarqube') { sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" - // sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; 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 "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; 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/README.md b/README.md index d652044..c2358a1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Demo GIF ### Try volto-industry-theme with Docker +**IMPORTANT:** make sure that you don't wait for `@breadcrumbs` request in your frontend cypress tests as this theme disables breadcrumbs. + 1. Get the latest Docker images ``` diff --git a/cypress/support/index.js b/cypress/support/index.js index a3fd935..e585436 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -39,7 +39,7 @@ export const setupBeforeEach = () => { }); cy.visit('/cypress/my-page'); cy.waitForResourceToLoad('@navigation'); - cy.waitForResourceToLoad('@breadcrumbs'); + // cy.waitForResourceToLoad('@breadcrumbs'); cy.waitForResourceToLoad('@actions'); cy.waitForResourceToLoad('@types'); cy.waitForResourceToLoad('my-page'); diff --git a/src/customizations/volto/components/theme/View/DefaultView.jsx b/src/customizations/volto/components/theme/View/DefaultView.jsx deleted file mode 100644 index 3a7b44b..0000000 --- a/src/customizations/volto/components/theme/View/DefaultView.jsx +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Document view component. - * @module components/theme/View/DefaultView - */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { defineMessages, injectIntl } from 'react-intl'; - -import { Container, Image } from 'semantic-ui-react'; -import { map } from 'lodash'; -import config from '@plone/volto/registry'; - -import { - getBlocksFieldname, - getBlocksLayoutFieldname, - hasBlocksData, - getBaseUrl, -} from '@plone/volto/helpers'; - -const messages = defineMessages({ - unknownBlock: { - id: 'Unknown Block', - defaultMessage: 'Unknown Block {block}', - }, -}); - -/** - * Component to display the default view. - * @function DefaultView - * @param {Object} content Content object. - * @returns {string} Markup of the component. - */ -const DefaultView = ({ content, intl, location }) => { - const blocksFieldname = getBlocksFieldname(content); - const blocksLayoutFieldname = getBlocksLayoutFieldname(content); - - return hasBlocksData(content) ? ( -
- {map(content[blocksLayoutFieldname].items, (block) => { - const Block = - config.blocks.blocksConfig[ - content[blocksFieldname]?.[block]?.['@type'] - ]?.['view'] || null; - return Block !== null ? ( - - ) : ( -
- {intl.formatMessage(messages.unknownBlock, { - block: content[blocksFieldname]?.[block]?.['@type'], - })} -
- ); - })} -
- ) : ( - -

{content.title}

- {content.description && ( -

{content.description}

- )} - {content.image && ( - - )} - {content.remoteUrl && ( - - The link address is: - {content.remoteUrl} - - )} - {content.text && ( -
- )} - - ); -}; - -/** - * Property types. - * @property {Object} propTypes Property types. - * @static - */ -DefaultView.propTypes = { - /** - * Content of the object - */ - content: PropTypes.shape({ - /** - * Title of the object - */ - title: PropTypes.string, - /** - * Description of the object - */ - description: PropTypes.string, - /** - * Text of the object - */ - text: PropTypes.shape({ - /** - * Data of the text of the object - */ - data: PropTypes.string, - }), - }).isRequired, -}; - -export default injectIntl(DefaultView); diff --git a/src/customizations/volto/components/theme/View/View.jsx b/src/customizations/volto/components/theme/View/View.jsx deleted file mode 100644 index 9dba5a7..0000000 --- a/src/customizations/volto/components/theme/View/View.jsx +++ /dev/null @@ -1,284 +0,0 @@ -/** - * View container. - * @module components/theme/View/View - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { compose } from 'redux'; -import { Portal } from 'react-portal'; -import { injectIntl } from 'react-intl'; -import qs from 'query-string'; - -import { - ContentMetadataTags, - Comments, - Tags, - Toolbar, -} from '@plone/volto/components'; -import { listActions, getContent } from '@plone/volto/actions'; -import { - BodyClass, - getBaseUrl, - getLayoutFieldname, -} from '@plone/volto/helpers'; - -import config from '@plone/volto/registry'; - -/** - * View container class. - * @class View - * @extends Component - */ -class View extends Component { - /** - * Property types. - * @property {Object} propTypes Property types. - * @static - */ - static propTypes = { - actions: PropTypes.shape({ - object: PropTypes.arrayOf(PropTypes.object), - object_buttons: PropTypes.arrayOf(PropTypes.object), - user: PropTypes.arrayOf(PropTypes.object), - }), - listActions: PropTypes.func.isRequired, - /** - * Action to get the content - */ - getContent: PropTypes.func.isRequired, - /** - * Pathname of the object - */ - pathname: PropTypes.string.isRequired, - location: PropTypes.shape({ - search: PropTypes.string, - pathname: PropTypes.string, - }).isRequired, - /** - * Version id of the object - */ - versionId: PropTypes.string, - /** - * Content of the object - */ - content: PropTypes.shape({ - /** - * Layout of the object - */ - layout: PropTypes.string, - /** - * Allow discussion of the object - */ - allow_discussion: PropTypes.bool, - /** - * Title of the object - */ - title: PropTypes.string, - /** - * Description of the object - */ - description: PropTypes.string, - /** - * Type of the object - */ - '@type': PropTypes.string, - /** - * Subjects of the object - */ - subjects: PropTypes.arrayOf(PropTypes.string), - is_folderish: PropTypes.bool, - }), - error: PropTypes.shape({ - /** - * Error type - */ - status: PropTypes.number, - }), - }; - - /** - * Default properties. - * @property {Object} defaultProps Default properties. - * @static - */ - static defaultProps = { - actions: null, - content: null, - versionId: null, - error: null, - }; - - state = { - hasObjectButtons: null, - isClient: false, - }; - - componentDidMount() { - this.props.listActions(getBaseUrl(this.props.pathname)); - this.props.getContent( - getBaseUrl(this.props.pathname), - this.props.versionId, - ); - this.setState({ isClient: true }); - } - - /** - * Component will receive props - * @method componentWillReceiveProps - * @param {Object} nextProps Next properties - * @returns {undefined} - */ - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.pathname !== this.props.pathname) { - this.props.listActions(getBaseUrl(nextProps.pathname)); - this.props.getContent( - getBaseUrl(nextProps.pathname), - this.props.versionId, - ); - } - - if (nextProps.actions.object_buttons) { - const objectButtons = nextProps.actions.object_buttons; - this.setState({ - hasObjectButtons: !!objectButtons.length, - }); - } - } - - /** - * Default fallback view - * @method getViewDefault - * @returns {string} Markup for component. - */ - getViewDefault = () => config.views.defaultView; - - /** - * Get view by content type - * @method getViewByType - * @returns {string} Markup for component. - */ - getViewByType = () => - config.views.contentTypesViews[this.props.content['@type']] || null; - - /** - * Get view by content layout property - * @method getViewByLayout - * @returns {string} Markup for component. - */ - getViewByLayout = () => - config.views.layoutViews[ - this.props.content[getLayoutFieldname(this.props.content)] - ] || null; - - /** - * Cleans the component displayName (specially for connected components) - * which have the Connect(componentDisplayName) - * @method cleanViewName - * @param {string} dirtyDisplayName The displayName - * @returns {string} Clean displayName (no Connect(...)). - */ - cleanViewName = (dirtyDisplayName) => - dirtyDisplayName - .replace('Connect(', '') - .replace('injectIntl(', '') - .replace(')', '') - .replace('connect(', '') - .toLowerCase(); - - /** - * Render method. - * @method render - * @returns {string} Markup for the component. - */ - render() { - const { views } = config; - if (this.props.error && !this.props.connectionRefused) { - let FoundView; - if (this.props.error.status === undefined) { - // For some reason, while development and if CORS is in place and the - // requested resource is 404, it returns undefined as status, then the - // next statement will fail - FoundView = views.errorViews.corsError; - } else { - FoundView = views.errorViews[this.props.error.status.toString()]; - } - if (!FoundView) { - FoundView = views.errorViews['404']; // default to 404 - } - return ( -
- -
- ); - } - if (!this.props.content) { - return ; - } - const RenderedView = - this.getViewByType() || this.getViewByLayout() || this.getViewDefault(); - - return ( -
- - {/* Body class if displayName in component is set */} - - - {config.settings.showTags && - this.props.content.subjects && - this.props.content.subjects.length > 0 && ( - - )} - {/* Add opt-in social sharing if required, disabled by default */} - {/* In the future this might be parameterized from the app config */} - {/* */} - {this.props.content.allow_discussion && ( - - )} - {this.state.isClient && ( - - } /> - - )} -
- ); - } -} - -export default compose( - injectIntl, - connect( - (state, props) => ({ - actions: state.actions.actions, - token: state.userSession.token, - content: state.content.data, - error: state.content.get.error, - apiError: state.apierror.error, - connectionRefused: state.apierror.connectionRefused, - pathname: props.location.pathname, - versionId: - qs.parse(props.location.search) && - qs.parse(props.location.search).version, - }), - { - listActions, - getContent, - }, - ), -)(View); diff --git a/src/index.js b/src/index.js index a4e2a31..7d5cd7f 100644 --- a/src/index.js +++ b/src/index.js @@ -97,13 +97,15 @@ const applyConfig = (config) => { ], }; - return [ - installCustomViews, - installNavigationBlock, - installEprtrSpecificBlocks, - installCustomConnectedBlocks, - installAppExtras, - ].reduce((acc, apply) => apply(acc), config); + return config; + + // return [ + // installCustomViews, + // installNavigationBlock, + // installEprtrSpecificBlocks, + // installCustomConnectedBlocks, + // installAppExtras, + // ].reduce((acc, apply) => apply(acc), config); }; export default applyConfig; From 3c681b9cb4790f37ef149efd5aa8b55ea4161656 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Tue, 2 Nov 2021 12:56:50 +0200 Subject: [PATCH 2/3] Update --- src/index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 7d5cd7f..a4e2a31 100644 --- a/src/index.js +++ b/src/index.js @@ -97,15 +97,13 @@ const applyConfig = (config) => { ], }; - return config; - - // return [ - // installCustomViews, - // installNavigationBlock, - // installEprtrSpecificBlocks, - // installCustomConnectedBlocks, - // installAppExtras, - // ].reduce((acc, apply) => apply(acc), config); + return [ + installCustomViews, + installNavigationBlock, + installEprtrSpecificBlocks, + installCustomConnectedBlocks, + installAppExtras, + ].reduce((acc, apply) => apply(acc), config); }; export default applyConfig; From 462ff592b09c63b9298115ee3e9046c39f0022f0 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Tue, 2 Nov 2021 11:32:29 +0000 Subject: [PATCH 3/3] Automated release 0.1.2 --- CHANGELOG.md | 9 ++++++++- package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5028e8f..b45b964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,19 @@ 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). +#### [0.1.2](https://github.com/eea/volto-industry-theme/compare/0.1.1...0.1.2) + +- Update [`3c681b9`](https://github.com/eea/volto-industry-theme/commit/3c681b9cb4790f37ef149efd5aa8b55ea4161656) +- Enables cypress tests -> don't wait for breadcrumbs [`972e593`](https://github.com/eea/volto-industry-theme/commit/972e5931504f2e0ab866b5c5f8d2b9e1bb5053b9) + #### [0.1.1](https://github.com/eea/volto-industry-theme/compare/0.1.0...0.1.1) +> 1 November 2021 + +- Added eprtr blocks and more [`#2`](https://github.com/eea/volto-industry-theme/pull/2) - Commented cypress [`80eb317`](https://github.com/eea/volto-industry-theme/commit/80eb317730e92feef27316f87ba4f6080e5fa7fd) - Use latest addons versions [`384cd34`](https://github.com/eea/volto-industry-theme/commit/384cd34d51b8debb1444cb241576149e4abfe432) - Stylelint fix [`19ef60c`](https://github.com/eea/volto-industry-theme/commit/19ef60c117e427fa7f1df4ced8a9686e88b19c72) -- Added eprtr blocks and more [`0ad23d2`](https://github.com/eea/volto-industry-theme/commit/0ad23d2e17fafff396137e53b5903b3b0b4b41e8) - Improved Header & Footer [`cdbedcf`](https://github.com/eea/volto-industry-theme/commit/cdbedcf4cc75f71c8c892042db2d814f210348f0) - Theme override [`c31ef7e`](https://github.com/eea/volto-industry-theme/commit/c31ef7e694b310508bace3b43a6ea2db142b7a54) - Run bootstrap [`16b42cc`](https://github.com/eea/volto-industry-theme/commit/16b42cc3b48907fb0c803f256b549c034ca90d96) diff --git a/package.json b/package.json index 6a01dec..08da083 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-industry-theme", - "version": "0.1.1", + "version": "0.1.2", "description": "@eeacms/volto-industry-theme: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team",