Skip to content

Commit

Permalink
Commented cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Nov 1, 2021
1 parent 384cd34 commit 80eb317
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 62 deletions.
97 changes: 49 additions & 48 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -133,12 +133,13 @@ pipeline {
script{
checkout scm
unstash "xunit-reports"
unstash "cypress-coverage"
// unstash "cypress-coverage"
def scannerHome = tool 'SonarQubeScanner';
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,./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 -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'''
}
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
"@eeacms/volto-tableau",
"@eeacms/volto-datablocks",
"@eeacms/volto-openlayers-map",
"@eeacms/volto-columns-block"
"@eeacms/volto-columns-block",
"@eeacms/volto-matomo"
],
"dependencies": {
"@cypress/code-coverage": "^3.9.5",
"@eeacms/volto-tableau": "^1.2.4",
"@eeacms/volto-datablocks": "^2.0.15",
"@eeacms/volto-openlayers-map": "^0.1.3",
"@eeacms/volto-columns-block": "^4.4.6",
"@eeacms/volto-matomo": "^2.0.3",
"tableau-api-js": "github:eea/tableau-api-js#1.1.1",
"axios": "0.24.0",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand Down
19 changes: 18 additions & 1 deletion src/components/manage/Blocks/FiltersBlock/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { compose } from 'redux';
import { connect } from 'react-redux';
import { cloneDeep } from 'lodash';
import { Modal, Checkbox } from 'semantic-ui-react';
import { trackSiteSearch } from '@eeacms/volto-matomo/utils';
import { setQuery } from '@eeacms/volto-industry-theme/actions';
import { inputsKeys, permitTypes } from './dictionary';
import SelectWrapper from './SelectWrapper';
Expand Down Expand Up @@ -111,14 +112,30 @@ const ModalView = ({
}, [query]);

const applyFilters = React.useCallback(() => {
setQuery({
const newQuery = {
...inputs,
filter_change: {
counter: (query['filter_change']?.counter || 0) + 1,
type: 'advanced-filter',
},
filter_search: null,
filter_search_value: '',
};
setQuery(newQuery);
trackSiteSearch({
category: `Map/Table advanced-filter`,
keyword: JSON.stringify({
...Object.keys(newQuery)
.filter(
(key) =>
inputsKeys.includes(key) &&
newQuery[key]?.filter((value) => value)?.length,
)
.reduce((obj, key) => {
obj[key] = newQuery[key]?.filter((value) => value);
return obj;
}, {}),
}),
});
setOpen(false);
/* eslint-disable-next-line */
Expand Down
8 changes: 8 additions & 0 deletions src/components/manage/Blocks/FiltersBlock/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Input, List } from 'semantic-ui-react';
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
import Highlighter from 'react-highlight-words';
import config from '@plone/volto/registry';
import { trackSiteSearch } from '@eeacms/volto-matomo/utils';
import { setQuery } from '@eeacms/volto-industry-theme/actions';
import { getEncodedQueryString } from '@eeacms/volto-industry-theme/helpers';
import { inputsKeys } from './dictionary';
Expand Down Expand Up @@ -141,6 +142,13 @@ const Search = ({ data, providers_data, query, setQuery, ...props }) => {
type: value && type ? `search-${type}` : 'clear',
},
});

if (value && type) {
trackSiteSearch({
category: `Map/Table search-${type}`,
keyword: value,
});
}
},
[query, onChange, setQuery],
);
Expand Down
37 changes: 26 additions & 11 deletions src/components/manage/Blocks/IndustryMap/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cs from 'classnames';
import { Dropdown, Checkbox } from 'semantic-ui-react';
import { Icon } from '@plone/volto/components';
import { BodyClass } from '@plone/volto/helpers';
import { trackSiteSearch } from '@eeacms/volto-matomo/utils';
import { setQuery } from '@eeacms/volto-industry-theme/actions';
import {
getOptions,
Expand Down Expand Up @@ -67,18 +68,32 @@ class Sidebar extends React.Component {
inputsKeys.forEach((key) => {
newInputs[key] = query[key] || [];
});
this.props.dispatch(
setQuery({
...newInputs,
...filters,
filter_change: {
counter: (query['filter_change']?.counter || 0) + 1,
type: 'simple-filter',
},
filter_search: null,
filter_search_value: '',
const newQuery = {
...newInputs,
...filters,
filter_change: {
counter: (query['filter_change']?.counter || 0) + 1,
type: 'simple-filter',
},
filter_search: null,
filter_search_value: '',
};
this.props.dispatch(setQuery(newQuery));
trackSiteSearch({
category: `Map/Table simple-filter`,
keyword: JSON.stringify({
...Object.keys(newQuery)
.filter(
(key) =>
inputsKeys.includes(key) &&
newQuery[key]?.filter((value) => value)?.length,
)
.reduce((obj, key) => {
obj[key] = newQuery[key]?.filter((value) => value);
return obj;
}, {}),
}),
);
});
}

clearFilters() {
Expand Down
6 changes: 5 additions & 1 deletion src/components/manage/Blocks/IndustryMap/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
@element: custom;

.industry-map {
height: 600px;
min-height: 600px;
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.08);

.privacy-protection {
.wrapper {
width: 100%;

.overlay .wrapped {
opacity: 1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const View = (props) => {
});
setFacilities(newFacilities);
}
/* eslint-disable-next-line */
}, [provider_data, provider_data?.euregReportingYear, siteReportingYear]);

return props.mode === 'edit' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const View = (props) => {
),
);
}
/* eslint-disable-next-line */
}, [provider_data, provider_data?.euregReportingYear, siteReportingYear]);

return props.mode === 'edit' ? (
Expand Down
12 changes: 12 additions & 0 deletions src/components/manage/Blocks/SiteLocationMap/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@
height: 400px;
min-height: 400px;
}

.site-location-map .privacy-protection {
width: 100%;
}

.site-location-map .privacy-protection .overlay {
position: relative;
}

.site-location-map .privacy-protection .overlay .wrapped {
opacity: 1;
}
4 changes: 4 additions & 0 deletions src/theme/site/globals/site.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
}
}

.__react_component_tooltip {
max-width: 320px;
}

div#view .ui.container > * {
margin-bottom: 1.5rem;
}
Expand Down

0 comments on commit 80eb317

Please sign in to comment.