Skip to content

Commit

Permalink
test: add tests from volto-industry-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinab25 committed Dec 22, 2022
1 parent a42da1d commit 0ffe999
Show file tree
Hide file tree
Showing 13 changed files with 768 additions and 211 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ logs
*.log
npm-debug.log*
.DS_Store

cache
.nyc_output/
coverage
cypress/videos
cypress/reports
node_modules
build
.env.local
Expand All @@ -16,4 +19,4 @@ data
omelette

src/addons
src/develop
src/develop
164 changes: 82 additions & 82 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,70 @@ pipeline {

stages {

// stage('Integration tests') {
// parallel {
// stage('Integration with Cypress') {
// when {
// environment name: 'CHANGE_ID', value: ''
// }
// steps {
// 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 eeacms/volto-project-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/volto-project-ci cypress'''
// } finally {
// try {
// sh '''rm -rf cypress-reports cypress-results'''
// sh '''mkdir -p cypress-reports cypress-results'''
// sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/cypress/videos cypress-reports/'''
// sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/cypress/reports cypress-results/'''
// archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: 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("Docker test build") {
// when {
// not {
// environment name: 'CHANGE_ID', value: ''
// }
// not {
// buildingTag()
// }
// environment name: 'CHANGE_TARGET', value: 'master'
// }
// environment {
// IMAGE_NAME = BUILD_TAG.toLowerCase()
// }
// steps {
// node(label: 'docker-host') {
// script {
// checkout scm
// try {
// dockerImage = docker.build("${IMAGE_NAME}", "--no-cache .")
// } finally {
// sh script: "docker rmi ${IMAGE_NAME}", returnStatus: true
// }
// }
// }
// }
// }


// }
// }
stage('Integration tests') {
parallel {
stage('Integration with Cypress') {
when {
environment name: 'CHANGE_ID', value: ''
}
steps {
node(label: 'docker') {
script {
try {
sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
sh '''docker pull eeacms/volto-project-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/volto-project-ci cypress'''
} finally {
try {
sh '''rm -rf cypress-reports cypress-results'''
sh '''mkdir -p cypress-reports cypress-results'''
sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/cypress/videos cypress-reports/'''
sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/cypress/reports cypress-results/'''
archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: 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("Docker test build") {
when {
not {
environment name: 'CHANGE_ID', value: ''
}
not {
buildingTag()
}
environment name: 'CHANGE_TARGET', value: 'master'
}
environment {
IMAGE_NAME = BUILD_TAG.toLowerCase()
}
steps {
node(label: 'docker-host') {
script {
checkout scm
try {
dockerImage = docker.build("${IMAGE_NAME}", "--no-cache .")
} finally {
sh script: "docker rmi ${IMAGE_NAME}", returnStatus: true
}
}
}
}
}


}
}


stage('Pull Request') {
Expand Down Expand Up @@ -174,24 +174,24 @@ pipeline {
}
}

// stage('Update SonarQube Tags') {
// when {
// not {
// environment name: 'SONARQUBE_TAG', value: ''
// }
// buildingTag()
// }
// steps{
// node(label: 'docker') {
// withSonarQubeEnv('Sonarqube') {
// withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GIT_TOKEN')]) {
// sh '''docker pull eeacms/gitflow'''
// sh '''docker run -i --rm --name="${BUILD_TAG}-sonar" -e GIT_NAME=${GIT_NAME} -e GIT_TOKEN="${GIT_TOKEN}" -e SONARQUBE_TAG=${SONARQUBE_TAG} -e SONARQUBE_TOKEN=${SONAR_AUTH_TOKEN} -e SONAR_HOST_URL=${SONAR_HOST_URL} eeacms/gitflow /update_sonarqube_tags.sh'''
// }
// }
// }
// }
// }
stage('Update SonarQube Tags') {
when {
not {
environment name: 'SONARQUBE_TAG', value: ''
}
buildingTag()
}
steps{
node(label: 'docker') {
withSonarQubeEnv('Sonarqube') {
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GIT_TOKEN')]) {
sh '''docker pull eeacms/gitflow'''
sh '''docker run -i --rm --name="${BUILD_TAG}-sonar" -e GIT_NAME=${GIT_NAME} -e GIT_TOKEN="${GIT_TOKEN}" -e SONARQUBE_TAG=${SONARQUBE_TAG} -e SONARQUBE_TOKEN=${SONAR_AUTH_TOKEN} -e SONAR_HOST_URL=${SONAR_HOST_URL} eeacms/gitflow /update_sonarqube_tags.sh'''
}
}
}
}
}
}


Expand Down
27 changes: 27 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
viewportWidth: 1280,
defaultCommandTimeout: 8888,
chromeWebSecurity: false,
reporter: 'junit',
video: true,
retries: {
runMode: 8,
openMode: 0,
},
reporterOptions: {
mochaFile: 'cypress/reports/cypress-[hash].xml',
jenkinsMode: true,
toConsole: true,
},
e2e: {
setupNodeEvents(on, config) {
// e2e testing node events setup code
require('@cypress/code-coverage/task')(on, config);
require('cypress-fail-fast/plugin')(on, config);
return config;
},
baseUrl: 'http://localhost:3000',
},
});
12 changes: 0 additions & 12 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { setupBeforeEach, tearDownAfterEach } from '../support';
import { slateBeforeEach, slateAfterEach } from '../support/e2e';

import 'cypress-fail-fast';

describe('Blocks Tests', () => {
beforeEach(setupBeforeEach);
afterEach(tearDownAfterEach);
beforeEach(slateBeforeEach);
afterEach(slateAfterEach);

it('Add Block: Empty', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);
cy.get('[contenteditable=true]').first().clear();

cy.get('[contenteditable=true]').first().type('My Add-on Page');

cy.get('.documentFirstHeading').contains('My Add-on Page');

cy.get('[contenteditable=true]').first().type('{enter}');

// Add block
cy.get('.ui.basic.icon.button.block-add-button').first().click();
Expand Down
26 changes: 0 additions & 26 deletions cypress/plugins/index.js

This file was deleted.

Loading

0 comments on commit 0ffe999

Please sign in to comment.