Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cypress step #71

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 45 additions & 37 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,50 @@ pipeline {

stage('Integration tests') {
parallel {
// stage('Cypress') {
// allOf {
// when {
// environment name: 'CHANGE_ID', value: ''
// not { branch 'master' }
// not { changelog '.*^Automated release [0-9\\.]+$' }
// not { buildingTag() }
// }
// }
// 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('Cypress') {
when {
anyOf {
allOf {
not { environment name: 'CHANGE_ID', value: '' }
environment name: 'CHANGE_TARGET', value: 'develop'
}
allOf {
environment name: 'CHANGE_ID', value: ''
anyOf {
not { changelog '.*^Automated release [0-9\\.]+$' }
branch 'master'
branch 'develop'
}
}
}
}
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 {
Expand Down Expand Up @@ -222,4 +230,4 @@ pipeline {
}
}
}
}
}
18 changes: 16 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
viewportWidth: 1280,
defaultCommandTimeout: 15000,
chromeWebSecurity: false,

reporter: 'junit',
video: true,
reporterOptions: {
mochaFile: 'cypress/reports/cypress-[hash].xml',
jenkinsMode: true,
toConsole: true,
},
e2e: {
setupNodeEvents(on, config) {
// e2e testing node events setup code

return config;
},
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/tests/**/*.cy.{js,jsx}',
},
});
31 changes: 31 additions & 0 deletions cypress/e2e/01-block-basics.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { slateBeforeEach, slateAfterEach } from '../support/e2e';

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

it('Add Block: Empty', () => {
// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('My Add-on Page');

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

cy.getSlate().click({ force: true });

// Add block
cy.get('.ui.basic.icon.button.block-add-button')
.first()
.click({ force: true });
cy.get('.blocks-chooser .title').contains('Media').click();
cy.get('.content.active.media .button.image').contains('Image').click();

// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');

// then the page view should contain our changes
cy.contains('My Add-on Page');
cy.get('.block.image');
});
});
60 changes: 60 additions & 0 deletions cypress/e2e/01-block-columns.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { slateBeforeEach, slateAfterEach } from '../support/e2e';

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

it('Add Block: Empty', () => {
// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('My Add-on Page');

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

cy.getSlate().click({ force: true });

// Add block
cy.get('.ui.basic.icon.button.block-add-button')
.first()
.click({ force: true });
cy.get('.blocks-chooser .title').contains('Common').click();
cy.get('.content.active.common .button.columnsBlock')
.contains('Columns')
.click({ force: true });

cy.get('.columns-block .ui.card').eq(2).click({ force: true });
cy.get('.field-wrapper-title #field-title').last().type('Column test');
cy.get('.field-wrapper-data .columns-area button').last().click();

cy.get('.columns-area .drag.handle.wrapper')
.first()
.trigger('mousedown', { which: 1 }, { force: true })
.trigger('mousemove', 0, 60, { force: true })
.trigger('mouseup');

cy.get('.field-wrapper-gridCols #field-gridCols').click();
cy.get('.react-select__menu').contains('25').click();

cy.get('[contenteditable=true]').first().focus().click();
cy.get('.columns-block [contenteditable=true]')
.eq(0)
.focus()
.click()
.type('First');
cy.get('.columns-block [contenteditable=true]')
.eq(1)
.focus()
.click()
.type('Second');

// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');

// then the page view should contain our changes
cy.contains('My Add-on Page');
cy.contains('First');
cy.contains('Second');
cy.get('.columns-view');
});
});
Loading