diff --git a/e2e-cypress/Jenkinsfile.template b/e2e-cypress/Jenkinsfile.template index 584d8839..2932b9e1 100644 --- a/e2e-cypress/Jenkinsfile.template +++ b/e2e-cypress/Jenkinsfile.template @@ -92,6 +92,7 @@ def stageTest(def context) { // making sure to include in the secret names the environment name in lowercase (e.g., e2e-user-dev, e2e-user-test, // etc.), in case of using different secrets for different environments. // Secrets in OpenShift need to be created with the credential.sync.jenkins.openshift.io=true label to be available in Jenkins. + // These are examples for loading credentials from the testing user for logging into your application. withCredentials([ // usernamePassword(credentialsId: "${context.projectId}-cd-e2e-user", passwordVariable: 'CYPRESS_PASSWORD', usernameVariable: 'CYPRESS_USERNAME'), // string(credentialsId: "${context.projectId}-cd-otp-secret", variable: 'OTP_SECRET') @@ -119,18 +120,9 @@ def stageTest(def context) { stash(name: "acceptance-test-reports-junit-xml-${context.componentId}-${context.buildNumber}", includes: 'build/test-results/acceptance-junit.xml', allowEmpty: true) } - publishHTML (target : [ - allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true, - reportDir: 'build/test-results', - reportFiles: '**/*.html', - reportName: 'Cypress Reports' - ]) - sh 'npm run generate:pdf' zip zipFile: 'cypress/pdf.zip', archive: false, dir: 'build/test-results/mochawesome/pdf' - archiveArtifacts artifacts: 'cypress/pdf.zip', fingerprint: true, daysToKeep: 2, numToKeep: 3 + archiveArtifacts artifacts: 'cypress/pdf.zip', fingerprint: true if (fileExists('cypress/videos')) { zip zipFile: 'cypress/videos.zip', archive: false, dir: 'cypress/videos' @@ -138,7 +130,6 @@ def stageTest(def context) { if (fileExists('build/test-results/screenshots')) { zip zipFile: 'cypress/screenshots.zip', archive: false, dir: 'build/test-results/screenshots' - archiveArtifacts artifacts: 'cypress/screenshots.zip', fingerprint: true, daysToKeep: 2, numToKeep: 3 } if (status != 0) { diff --git a/e2e-cypress/files/README.md b/e2e-cypress/files/README.md index 89367eb3..0ef5758d 100644 --- a/e2e-cypress/files/README.md +++ b/e2e-cypress/files/README.md @@ -10,29 +10,12 @@ Please note that each stage is executed with its own Cypress configuration file ## Running end-to-end tests -Run `npm run e2e` to execute all end-to-end tests via [Cypress](https://www.cypress.io) against the test instance of the front end. +Run `npm run e2e` to execute all end-to-end tests via [Cypress](https://www.cypress.io) against the test instance of the front end. In order to run the tests against different environments for releases, you can define the base URLs of each environment in a config map in OpenShift, and import them as environment variables in the `Jenkinsfile`. See an example on how to do this using `context.environment` in the `Jenkinsfile`. ## Local development Run `npm start` to develop the e2e tests. The tests will automatically rebuild and run, if you change any of the source files. Ideally the test will run against a local instance of the front end, e.g. `http://localhost:4200` for an Angular app. This destination is configurable in the `cypress.config.ts` file. -## How to upload images or videos to Nexus - -Screenshots are only taken when test fails. - 1. Open the Jenkinsfile - 2. Replace `stageTest(context)` by the following lines: - ``` - def status = stageTest(context) - if (status != 0) { - odsComponentStageUploadToNexus(context, - [ - distributionFile: 'tests/screenshots.zip', - repository: 'leva-documentation', - repositoryType: 'raw', - targetDirectory: "${targetDirectory}"]) - } - ``` - ## Reports From [Merging reports across spec files](https://docs.cypress.io/guides/tooling/reporters#Merging-reports-across-spec-files): each spec file is processed completely separately during each cypress run execution. Thus each spec run overwrites the previous report file. To preserve unique reports for each spec file, use the `[hash]` in the `mochaFile` filename. @@ -40,8 +23,10 @@ In order to generate one xml report per test type (installation, integration and ## E2e test user authentication -With Cypress 12 version is now available `cy.origin()` that allows you to handle redirections. This funcionality eases the login handling. -See `./support/e2e.ts` for a generic login example. +With Cypress 12 version is now available `cy.origin()` that allows you to handle redirections. This functionality eases the login handling. +See `./support/login-functions.ts` for a generic login example. + +In order to load your testing user's credentials for this login with SSO, you need to create a secret in OpenShift with the label `credential.sync.jenkins.openshift.io=true` and import them as environment variables using the withCredentials block to keep them secure. Find an example on how to do this in the `Jenkinsfile`. ## Cypress Cloud diff --git a/e2e-cypress/files/cypress.config.ts b/e2e-cypress/files/cypress.config.ts index e02d663f..dfd361f6 100644 --- a/e2e-cypress/files/cypress.config.ts +++ b/e2e-cypress/files/cypress.config.ts @@ -26,7 +26,7 @@ export default defineConfig({ viewportWidth: 1280, viewportHeight: 720, experimentalModifyObstructiveThirdPartyCode: true, - video: true, + video: false, async setupNodeEvents(on, config) { return (await import('./plugins/index')).default(on, config); },