diff --git a/cypress/pageobjects/volume.po.ts b/cypress/pageobjects/volume.po.ts index dd99047e0..9ef06397b 100755 --- a/cypress/pageobjects/volume.po.ts +++ b/cypress/pageobjects/volume.po.ts @@ -48,7 +48,7 @@ export class VolumePage extends CruResourcePo { checkSnapshotCount(volumeName: string, count: number, namespace: string = 'default') { this.goToList(); - this.censorInColumn(volumeName, 3, namespace, 4, count, 7); + this.censorInColumn(volumeName, 3, namespace, 4, count, 8); } clickVolumeSnapshotAction(name: string, snapshotName: string) { diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 805b356db..9746c0553 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -4,6 +4,7 @@ const fs = require("fs"); const yaml = require('js-yaml'); const { isFileExist, findFiles } = require('cy-verify-downloads'); const AdmZip = require("adm-zip"); +const path = require('path') let globalVar = {}; // *********************************************************** @@ -121,5 +122,19 @@ module.exports = (on, config) => { return launchOptions; }); + // on('after:screenshot', (details) => { + // const fileName = path.basename(details.path) + + // const newPath = `cypress/results/mochawesome-report/assets/${details.specName}-${fileName}` + + // return new Promise((resolve, reject) => { + // fs.rename(details.path, newPath, (err) => { + // if (err) return reject(err) + + // resolve({ path: newPath }) + // }) + // }) + // }) + return config; } diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 15233ce09..7cf13bfca 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -2,6 +2,9 @@ import cookie from 'cookie'; import addContext from "mochawesome/addContext"; import { Constants } from '../constants/constants' + +const path = require('path') + const constants = new Constants(); require('cy-verify-downloads').addCustomCommand(); @@ -60,8 +63,29 @@ Cypress.on('uncaught:exception', (err, runable) => { }) Cypress.on("test:after:run", (test, runnable) => { - if (test.state === "failed") { - const screenshot =`assets/${Cypress.spec.name}/${runnable.parent.title} -- ${test.title} (failed).png`; + if (test.state === "failed") { + const dir = Cypress.spec.relative + const specDir = dir.split('/').slice(1, -1).join('/') + + let describe = '' + let context = '' + let it = test.title + + let fileName = '' + + if (runnable.parent?.parent?.title) { + describe = runnable.parent.parent.title + context = runnable.parent.title + + fileName = `${describe} -- ${context} -- ${it} (failed).png` + } else { + describe = runnable.parent.title + + fileName = `${runnable.parent.title} -- ${test.title} (failed).png` + } + + const screenshot =`assets/${specDir}/${Cypress.spec.name}/${fileName}`; + addContext({ test }, screenshot); } }); diff --git a/cypress/testcases/virtualmachines/advanced.spec.ts b/cypress/testcases/virtualmachines/advanced.spec.ts index 333820c92..7ea54b12b 100644 --- a/cypress/testcases/virtualmachines/advanced.spec.ts +++ b/cypress/testcases/virtualmachines/advanced.spec.ts @@ -179,19 +179,20 @@ sshpwauth: True vms.save() - cy.wait('@createVM').then(res => { - expect(res.response?.statusCode, 'Check create VM').to.equal(201); - - expect(res.response?.body?.spec?.template?.spec?.domain?.resources?.limits?.cpu).to.equal('1') - expect(res.response?.body?.spec?.template?.spec?.domain?.resources?.limits?.memory).to.equal('1Gi') - }) - - cy.wait('@createSecret').then(res => { - expect(res.response?.statusCode, 'Check create secret').to.equal(201); - - const userDataYAML = base64Decode(res.response?.body?.data?.userdata) - expect(userDataYAML, 'Check user data').to.equal(userData) - }) + for( let i=0; i<3; i++) { + cy.wait('@createVM').then(res => { + expect(res.response?.statusCode, 'Check create VM').to.equal(201); + + expect(res.response?.body?.spec?.template?.spec?.domain?.resources?.limits?.cpu).to.equal('1') + expect(res.response?.body?.spec?.template?.spec?.domain?.resources?.limits?.memory).to.equal('1Gi') + }) + cy.wait('@createSecret').then(res => { + expect(res.response?.statusCode, 'Check create secret').to.equal(201); + + const userDataYAML = base64Decode(res.response?.body?.data?.userdata) + expect(userDataYAML, 'Check user data').to.equal(userData) + }) + } vms.goToList() cy.get('.search').type(namePrefix)