Skip to content

Commit

Permalink
test(jest): Re-enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Oct 28, 2022
1 parent b15b416 commit 6ad5fca
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 62 deletions.
100 changes: 50 additions & 50 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,53 +60,53 @@ pipeline {
}
}

// stage('Tests') {
// when {
// allOf {
// environment name: 'CHANGE_ID', value: ''
// anyOf {
// not { changelog '.*^Automated release [0-9\\.]+$' }
// branch 'master'
// }
// }
// }
// steps {
// parallel(

// "Volto": {
// node(label: 'docker') {
// script {
// try {
// sh '''docker pull plone/volto-addon-ci:alpha'''
// 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'''
// sh '''rm -rf xunit-reports'''
// sh '''mkdir -p xunit-reports'''
// sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
// sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/'''
// sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/'''
// stash name: "xunit-reports", includes: "xunit-reports/**"
// archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true
// publishHTML (target : [
// allowMissing: false,
// alwaysLinkToLastBuild: true,
// keepAll: true,
// reportDir: 'xunit-reports/coverage/lcov-report',
// reportFiles: 'index.html',
// reportName: 'UTCoverage',
// reportTitles: 'Unit Tests Code Coverage'
// ])
// } finally {
// catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
// junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
// }
// sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true
// }
// }
// }
// }
// )
// }
// }
stage('Tests') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
anyOf {
not { changelog '.*^Automated release [0-9\\.]+$' }
branch 'master'
}
}
}
steps {
parallel(

"Volto": {
node(label: 'docker') {
script {
try {
sh '''docker pull plone/volto-addon-ci:alpha'''
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'''
sh '''rm -rf xunit-reports'''
sh '''mkdir -p xunit-reports'''
sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/'''
sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/'''
stash name: "xunit-reports", includes: "xunit-reports/**"
archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true
publishHTML (target : [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'xunit-reports/coverage/lcov-report',
reportFiles: 'index.html',
reportName: 'UTCoverage',
reportTitles: 'Unit Tests Code Coverage'
])
} finally {
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
}
sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true
}
}
}
}
)
}
}

stage('Integration tests') {
when {
Expand Down Expand Up @@ -182,13 +182,13 @@ pipeline {
node(label: 'swarm') {
script{
checkout scm
// unstash "xunit-reports"
unstash "xunit-reports"
unstash "cypress-coverage"
def scannerHome = tool 'SonarQubeScanner';
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 "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 '''sed -i "s#/opt/frontend/my-volto-project/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 "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./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
1 change: 0 additions & 1 deletion __mocks__/styleMock.js

This file was deleted.

7 changes: 3 additions & 4 deletions jest-addon.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ module.exports = {
'~/(.*)$': '<rootDir>/src/$1',
'load-volto-addons':
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
'\\.(css|less|scss|sass)$':
'<rootDir>/src/addons/volto-columns-block/__mocks__/styleMock.js',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
},
transform: {
'^.+\\.js(x)?$': 'babel-jest',
'^.+\\.(png)$': 'jest-file',
'^.+\\.(jpg)$': 'jest-file',
'^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'jest-file',
},
coverageThreshold: {
global: {
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnsBlock/ColumnsBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { makeStyleSchema, getStyle } from '../Styles';
import tuneSVG from '@plone/volto/icons/column.svg';
import upSVG from '@plone/volto/icons/up.svg';

import '@eeacms/volto-columns-block/less/columns.less';
import '../less/columns.less';

const messages = defineMessages({
labelColumn: {
Expand Down
8 changes: 2 additions & 6 deletions src/ColumnsBlock/__snapshots__/ColumnsBlockView.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ exports[`renders 2 columns 1`] = `
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper"
>
<div>
<div>
left marker
</div>
left marker
</div>
</div>
<div
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper"
>
<div>
<div>
right
</div>
right
</div>
</div>
</div>
Expand Down

0 comments on commit 6ad5fca

Please sign in to comment.