From 6f95f833064f73ed153a8f2704713e3f921d6fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20Mart=C3=ADnez?= Date: Wed, 13 Nov 2024 16:25:37 +0100 Subject: [PATCH] Cypress: enable Test Isolation --- .gitignore | 1 + cypress/cypress.config.ts | 4 +- cypress/support.ts | 27 +++++--- cypress/support/login.ts | 21 ------ cypress/support/pages/app.ts | 2 +- cypress/tests/active-health-checks.spec.ts | 12 +--- cypress/tests/add-capacity.spec.ts | 16 +---- cypress/tests/bucket-class.spec.ts | 14 ---- cypress/tests/create-backing-store.spec.ts | 16 ----- cypress/tests/expand-pvc.spec.ts | 10 --- cypress/tests/kms-encryption-sc.spec.ts | 3 - cypress/tests/list-page.spec.ts | 9 --- .../multiple-storageclass-selection.spec.ts | 8 +-- cypress/tests/namespace-store.spec.ts | 17 ----- cypress/tests/obc-test.spec.ts | 24 +++---- .../tests/object-service-dashboards.spec.ts | 16 ++--- .../tests/persistent-dashboard-check.spec.ts | 66 ++++++++++--------- .../storage-pool-in-storageclass-form.spec.ts | 10 --- cypress/tests/storage-pool.spec.ts | 30 +-------- cypress/views/obcPage.ts | 1 - cypress/views/pvc.ts | 10 ++- 21 files changed, 92 insertions(+), 225 deletions(-) diff --git a/.gitignore b/.gitignore index 6891d3b98..398e47d78 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist .eslintcache coverage cypress/cypress-a11y-report.json +cypress/downloads gui-test-screenshots plugins/**/package.json plugins/**/dist diff --git a/cypress/cypress.config.ts b/cypress/cypress.config.ts index fb5a2895d..dbac47ec9 100644 --- a/cypress/cypress.config.ts +++ b/cypress/cypress.config.ts @@ -1,13 +1,13 @@ import { defineConfig } from 'cypress'; +import { SECOND } from './consts'; import * as setupNodeEvents from './plugin.js'; export default defineConfig({ - defaultCommandTimeout: 30000, + defaultCommandTimeout: 30 * SECOND, e2e: { setupNodeEvents, specPattern: 'cypress/tests/**/*.ts', supportFile: 'cypress/support.ts', - testIsolation: false, }, fixturesFolder: false, reporter: 'node_modules/cypress-multi-reporters', diff --git a/cypress/support.ts b/cypress/support.ts index 736623ee7..2d45a6bc9 100644 --- a/cypress/support.ts +++ b/cypress/support.ts @@ -4,18 +4,26 @@ import { STORAGE_SYSTEM_NAME, OCS_SC_STATE, ODF_OPERATOR_NAME, + SECOND, + MINUTE, } from './consts'; import './support/selectors'; import './support/login'; -before(() => { - // Disable Cypress's default behavior of logging all XMLHttpRequests and fetches. +const disableIrrelevantLogging = () => { + // Disable the default behavior of logging all XMLHttpRequests and fetches. cy.intercept({ resourceType: /xhr|fetch/ }, { log: false }); +}; + +before(() => { + disableIrrelevantLogging(); // Required as 'before' actions precede 'beforeEach' actions. }); beforeEach(() => { - // Disable Cypress's default behavior of logging all XMLHttpRequests and fetches. - cy.intercept({ resourceType: /xhr|fetch/ }, { log: false }); + disableIrrelevantLogging(); + cy.login(); + cy.visit('/'); + cy.install(); }); declare global { @@ -49,7 +57,7 @@ Cypress.Commands.add('install', () => { cy.byTestID('item-create').click(); // Wait for the StorageSystem page to load. - cy.contains('Create StorageSystem', { timeout: 10 * 1000 }).should( + cy.contains('Create StorageSystem', { timeout: 15 * SECOND }).should( 'be.visible' ); cy.get('button').contains('Next').click(); @@ -67,7 +75,7 @@ Cypress.Commands.add('install', () => { .as('Create StorageSystem Button'); cy.get('@Create StorageSystem Button').click(); // Wait for the storage system to be created. - cy.get('@Create StorageSystem Button', { timeout: 10 * 1000 }).should( + cy.get('@Create StorageSystem Button', { timeout: 10 * SECOND }).should( 'not.exist' ); @@ -76,11 +84,12 @@ Cypress.Commands.add('install', () => { cy.byLegacyTestID('horizontal-link-Storage Systems').click(); cy.byLegacyTestID('item-filter').type(STORAGE_SYSTEM_NAME); cy.get('a').contains(STORAGE_SYSTEM_NAME); - cy.get('td[id="status"]', { timeout: 5 * 60000 }).contains('Available', { - timeout: 5 * 60000, + cy.get('td[id="status"]', { timeout: 5 * MINUTE }).contains('Available', { + timeout: 5 * MINUTE, }); // Verify that the OCS SC is in READY state. - cy.exec(OCS_SC_STATE, { timeout: 25 * 60000 }); + cy.exec(OCS_SC_STATE, { timeout: 25 * MINUTE }); + cy.visit('/'); } else { cy.log( ' ocs-storagecluster-storagesystem is present, proceeding without installation.' diff --git a/cypress/support/login.ts b/cypress/support/login.ts index 119591e2d..126a87500 100644 --- a/cypress/support/login.ts +++ b/cypress/support/login.ts @@ -57,24 +57,3 @@ Cypress.Commands.add( ); } ); - -Cypress.Commands.add('logout', () => { - // Check if auth is disabled (for a local development environment). - cy.window().then((win: any) => { - if (win.SERVER_FLAGS?.authDisabled) { - cy.task( - 'log', - ' skipping logout, console is running with auth disabled' - ); - return; - } - cy.task('log', ' Logging out'); - cy.byTestID('user-dropdown').click(); - cy.byTestID('log-out').should('be.visible'); - cy.byTestID('log-out').click({ force: true }); // eslint-disable-line cypress/no-force - // Logout is flaky and fails the CI (in "after" step), even if all other test case ("it" blocks) passes. - // Login executes "cy.clearCookie('openshift-session-token')" as a fallback, which will auto logout the user. - // Therefore, commenting out the next line from this file as it is not needed. - // cy.byLegacyTestID('login').should('be.visible'); - }); -}); diff --git a/cypress/support/pages/app.ts b/cypress/support/pages/app.ts index 7ba3b9726..f3b8eb068 100644 --- a/cypress/support/pages/app.ts +++ b/cypress/support/pages/app.ts @@ -33,7 +33,7 @@ export const projectNameSpace = { // cy.testA11y('Create Project modal'); cy.byTestID('dropdown-text-filter').clear(); cy.byTestID('dropdown-text-filter').should('be.empty'); - cy.byTestID('dropdown-text-filter').type(projectName); + cy.byTestID('dropdown-text-filter').type(projectName, { delay: 0 }); cy.byTestID('dropdown-text-filter').should('have.value', projectName); cy.get('[data-test-id="namespace-bar-dropdown"] span') .first() diff --git a/cypress/tests/active-health-checks.spec.ts b/cypress/tests/active-health-checks.spec.ts index 4d3d494d3..6e5cb83d1 100644 --- a/cypress/tests/active-health-checks.spec.ts +++ b/cypress/tests/active-health-checks.spec.ts @@ -51,21 +51,11 @@ const isStorageClusterHealthy = () => { }; describe('Test Popover behaviour for different active health check cases.', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); + beforeEach(() => { ODFCommon.visitStorageDashboard(); cy.byLegacyTestID('horizontal-link-Storage Systems').first().click(); listPage.searchInList(STORAGE_SYSTEM_NAME); cy.byTestRows('resource-row').contains(STORAGE_SYSTEM_NAME).click(); - }); - - after(() => { - cy.logout(); - }); - - beforeEach(() => { isStorageClusterHealthy(); }); diff --git a/cypress/tests/add-capacity.spec.ts b/cypress/tests/add-capacity.spec.ts index bebc3393b..fdea50fa7 100644 --- a/cypress/tests/add-capacity.spec.ts +++ b/cypress/tests/add-capacity.spec.ts @@ -27,21 +27,7 @@ const ROOK_CONF_PATH = '/var/lib/rook/openshift-storage/openshift-storage.config'; describe('OCS Operator Expansion of Storage Class Test', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - beforeEach(() => { - cy.visit('/'); - }); - - after(() => { - cy.logout(); - }); - - it.only('Add additional capacity to Storage Cluster', () => { + it('Add additional capacity to Storage Cluster', () => { const initialState = { storageCluster: null, cephCluster: null, diff --git a/cypress/tests/bucket-class.spec.ts b/cypress/tests/bucket-class.spec.ts index 8931ccb62..d8c5f7af9 100644 --- a/cypress/tests/bucket-class.spec.ts +++ b/cypress/tests/bucket-class.spec.ts @@ -23,9 +23,6 @@ describe('Tests creation of Standard Bucket Class', () => { BucketClassType.STANDARD ); before(() => { - cy.login(); - cy.visit('/'); - cy.install(); config.setup(); }); @@ -40,7 +37,6 @@ describe('Tests creation of Standard Bucket Class', () => { after(() => { config.cleanup(); - cy.logout(); }); it('Create a 1 Tier(Spread) Bucket Class', () => { @@ -70,9 +66,6 @@ describe('Tests creation of Namespace Bucket Class', () => { BucketClassType.NAMESPACE ); before(() => { - cy.login(); - cy.visit('/'); - cy.install(); config.setup(); }); @@ -87,7 +80,6 @@ describe('Tests creation of Namespace Bucket Class', () => { after(() => { config.cleanup(); - cy.logout(); }); it('Create a Single Namespace Bucket Class', () => { @@ -109,12 +101,6 @@ describe('Tests creation of Namespace Bucket Class', () => { describe('Tests form validations on Bucket Class', () => { const nameFieldTestId: string = 'bucket-class-name'; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - beforeEach(() => { visitBucketClassPage(); }); diff --git a/cypress/tests/create-backing-store.spec.ts b/cypress/tests/create-backing-store.spec.ts index 989950587..4dd5e5bba 100644 --- a/cypress/tests/create-backing-store.spec.ts +++ b/cypress/tests/create-backing-store.spec.ts @@ -9,16 +9,6 @@ import { } from '../views/store'; describe('Tests creation of Backing Stores', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - afterEach(() => { cy.exec(`oc delete backingstore test-bucket -n openshift-storage`); }); @@ -39,12 +29,6 @@ describe('Tests creation of Backing Stores', () => { describe('Tests form validations on Backing Stores', () => { const nameFieldTestId: string = `${StoreType.BackingStore}-name`; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - beforeEach(() => { commonFlows.navigateToObjectStorage(); cy.byTestID('horizontal-link-Backing Store').first().click(); diff --git a/cypress/tests/expand-pvc.spec.ts b/cypress/tests/expand-pvc.spec.ts index 5f7fe1040..bfff87bb2 100644 --- a/cypress/tests/expand-pvc.spec.ts +++ b/cypress/tests/expand-pvc.spec.ts @@ -1,16 +1,6 @@ import { pvc } from '../views/pvc'; describe('Tests Expansion of a PVC', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - beforeEach(() => { cy.clickNavLink(['Storage', 'PersistentVolumeClaims']); }); diff --git a/cypress/tests/kms-encryption-sc.spec.ts b/cypress/tests/kms-encryption-sc.spec.ts index 0ac84d925..10d739851 100644 --- a/cypress/tests/kms-encryption-sc.spec.ts +++ b/cypress/tests/kms-encryption-sc.spec.ts @@ -15,9 +15,6 @@ describe('Test Ceph pool creation', () => { before(() => { configureVault(); - cy.login(); - cy.visit('/'); - cy.install(); }); after(() => { diff --git a/cypress/tests/list-page.spec.ts b/cypress/tests/list-page.spec.ts index 1f67ee290..68161fe9e 100644 --- a/cypress/tests/list-page.spec.ts +++ b/cypress/tests/list-page.spec.ts @@ -13,15 +13,6 @@ const checkKebabMenuItem = (itemText: string) => { }; describe('Tests storage system list page', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - after(() => { - cy.logout(); - }); - beforeEach(() => { ODFCommon.visitStorageDashboard(); }); diff --git a/cypress/tests/multiple-storageclass-selection.spec.ts b/cypress/tests/multiple-storageclass-selection.spec.ts index 8a411bc95..73e982d77 100644 --- a/cypress/tests/multiple-storageclass-selection.spec.ts +++ b/cypress/tests/multiple-storageclass-selection.spec.ts @@ -24,9 +24,6 @@ describe('Add capacity using multiple storage classes', () => { }; before(() => { - cy.login(); - cy.visit('/'); - cy.install(); cy.exec(`echo '${JSON.stringify(testEbsSC)}' | kubectl apply -f -`); cy.exec( `echo '${JSON.stringify(testNoProvisionerSC)}' | kubectl apply -f -` @@ -43,11 +40,11 @@ describe('Add capacity using multiple storage classes', () => { ); }); }); - cy.clickNavLink(['Storage', 'Data Foundation']); - cy.byLegacyTestID('horizontal-link-Storage Systems').click(); }); beforeEach(() => { + cy.clickNavLink(['Storage', 'Data Foundation']); + cy.byLegacyTestID('horizontal-link-Storage Systems').click(); fetchStorageClusterJson().then((res) => { const json: K8sResourceKind = JSON.parse(res.stdout); beforeCapacityAddition.deviceSets = json.spec.storageDeviceSets; @@ -72,7 +69,6 @@ describe('Add capacity using multiple storage classes', () => { ); }); }); - cy.logout(); }); it('Add capacity with a new storage class having EBS as provisioner', () => { diff --git a/cypress/tests/namespace-store.spec.ts b/cypress/tests/namespace-store.spec.ts index 8cd850096..82960dc7d 100644 --- a/cypress/tests/namespace-store.spec.ts +++ b/cypress/tests/namespace-store.spec.ts @@ -10,16 +10,6 @@ import { } from '../views/store'; describe('Tests creation of Namespace Stores', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - afterEach(() => { cy.byTestID('kebab-button').click(); cy.log('Deleting namespace store'); @@ -72,14 +62,7 @@ describe('Tests creation of Namespace Stores', () => { describe('Tests form validations on Namespace Stores', () => { const nameFieldTestId: string = `${StoreType.NamespaceStore}-name`; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - beforeEach(() => { - cy.visit('/'); commonFlows.navigateToObjectStorage(); cy.byTestID('horizontal-link-Namespace Store').first().click(); cy.byTestID('item-create').click(); diff --git a/cypress/tests/obc-test.spec.ts b/cypress/tests/obc-test.spec.ts index f1eee78e4..828e9bda2 100644 --- a/cypress/tests/obc-test.spec.ts +++ b/cypress/tests/obc-test.spec.ts @@ -1,6 +1,6 @@ import { fieldValidationOnFormsTests } from '../helpers/formValidations'; import { deployment } from '../mocks/deploymentData'; -import { app } from '../support/pages/app'; +import { app, projectNameSpace } from '../support/pages/app'; import { ACCESS_KEY, BOUND, @@ -19,23 +19,32 @@ import { listPage } from '../views/list-page'; import { CreateOBCHandler, obcNavigate } from '../views/obcPage'; describe('Test Object Bucket Claim resource', () => { - let obcHandler; + const obcHandler = new CreateOBCHandler( + OBC_NAME, + testName, + OBC_STORAGE_CLASS + ); before(() => { cy.login(); cy.visit('/'); cy.install(); - obcHandler = new CreateOBCHandler(OBC_NAME, testName, OBC_STORAGE_CLASS); obcHandler.createBucketClaim(); }); + beforeEach(() => { + obcNavigate.navigateToOBC(); + projectNameSpace.selectOrCreateProject(testName); + }); + after(() => { obcHandler.deleteBucketClaim(); - cy.logout(); }); it('Test if Object Bucket Claim details page is rendered correctly', () => { cy.log('Test if OBC is bound'); + listPage.searchInList(OBC_NAME); + cy.byTestID(`resource-link-${OBC_NAME}`).click(); cy.byTestID('resource-status').contains(BOUND, { timeout: MINUTE }); cy.log('Test if secret data is masked'); @@ -104,7 +113,6 @@ describe('Test Object Bucket Claim resource', () => { deployment )}' | kubectl create -n ${testName} -f -` ); - obcNavigate.navigateToOBC(); listPage.rows.shouldBeLoaded(); listPage.rows.clickKebabAction(OBC_NAME, 'Attach to Deployment'); cy.byTestID('loading-indicator').should('not.exist'); @@ -128,12 +136,6 @@ describe('Tests form validations on Object Bucket Claim', () => { cy.contains('openshift-storage.noobaa.io').click(); }; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - beforeEach(() => { obcNavigate.navigateToOBC(); cy.byTestID('item-create').click(); diff --git a/cypress/tests/object-service-dashboards.spec.ts b/cypress/tests/object-service-dashboards.spec.ts index 756285f9a..717725f2b 100644 --- a/cypress/tests/object-service-dashboards.spec.ts +++ b/cypress/tests/object-service-dashboards.spec.ts @@ -1,19 +1,17 @@ -import { testBucket } from '../utils/consts'; +import { SECOND, testBucket } from '../utils/consts'; import { ODFCommon } from '../views/odf-common'; describe('Tests Buckets, Status, Object Storage Efficiency, and Resource Providers Cards', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - beforeEach(() => { ODFCommon.visitStorageDashboard(); cy.byLegacyTestID('horizontal-link-Storage Systems').first().click(); cy.byLegacyTestID('item-filter').type('ocs-storagecluster-storagesystem'); - cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting - cy.byTestRows('resource-row').get('td a').first().click(); + cy.byTestRows('resource-row') + .get('td a', { + timeout: 5 * SECOND, + }) + .first() + .click(); cy.byTestID('horizontal-link-Object').click(); }); diff --git a/cypress/tests/persistent-dashboard-check.spec.ts b/cypress/tests/persistent-dashboard-check.spec.ts index 782ed9253..6307645d1 100644 --- a/cypress/tests/persistent-dashboard-check.spec.ts +++ b/cypress/tests/persistent-dashboard-check.spec.ts @@ -1,25 +1,23 @@ -import { STORAGE_SYSTEM_NAME } from '../consts'; +import { SECOND, STORAGE_SYSTEM_NAME } from '../consts'; import { getPVCJSON } from '../helpers/pvc'; import { ODFCommon } from '../views/odf-common'; import { deletePVCFromCLI } from '../views/pvc'; -describe('Check Persistent Dashboard', () => { - let initialPVC; - let initialPV; +const extractNumbersFromText = (text: string): string => { + const matches = text.match(/\d+/g); + return matches ? matches.join('') : ''; +}; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); +describe('Check Persistent Dashboard', () => { + beforeEach(() => { + ODFCommon.visitStorageDashboard(); }); after(() => { deletePVCFromCLI('dummy-pvc', 'openshift-storage'); - cy.logout(); }); - it('Check Status Card is in Healthy', () => { - ODFCommon.visitStorageDashboard(); + it('Check Status Card is healthy', () => { cy.log('Check if Data Foundation is Healthy'); cy.byTestID('success-icon').first().should('be.visible'); cy.log('Check if Storage System is Healthy'); @@ -34,6 +32,9 @@ describe('Check Persistent Dashboard', () => { }); it('Check Details card is correct', () => { + cy.byLegacyTestID('horizontal-link-Storage Systems').first().click(); + cy.byLegacyTestID('item-filter').type(STORAGE_SYSTEM_NAME); + cy.byTestRows('resource-row').get('td a').first().click(); cy.byTestID('ocs-link').contains('Data Foundation').scrollIntoView(); cy.byTestID('ocs-link').should('be.visible'); cy.byTestID('detail-item-value') @@ -49,36 +50,37 @@ describe('Check Persistent Dashboard', () => { }); it('Check Inventory card is correct', () => { - ODFCommon.visitStorageDashboard(); cy.byLegacyTestID('horizontal-link-Storage Systems').first().click(); cy.byLegacyTestID('item-filter').type(STORAGE_SYSTEM_NAME); cy.byTestRows('resource-row').get('td a').first().click(); cy.log('Check the total number of OCS nodes'); cy.get('.skeleton-activity').should('not.exist'); // eslint-disable-line cypress/require-data-selectors - cy.byTestID('inventory-nodes') - .invoke('text') - .then((text) => { - cy.exec( - `oc get nodes -l cluster.ocs.openshift.io/openshift-storage -o json | jq '.items | length'` - ).then(({ stdout }) => { - expect(text).to.equal(`${stdout.trim()} Nodes`); - }); - }); + cy.exec( + `oc get nodes -l cluster.ocs.openshift.io/openshift-storage -o json | jq '.items | length'` + ).then(({ stdout }) => { + cy.byTestID('inventory-nodes').should( + 'have.text', + `${stdout.trim()} Nodes`, + { timeout: 3 * SECOND } + ); + }); cy.log( - 'Check that number of PVCs and PVs is updated after sucessful PVC creation' + 'Check that number of PVCs and PVs is updated after successful PVC creation' ); + let initialPVC: number; + let initialPV: number; cy.byTestID('inventory-pvc') .invoke('text') .then((pvcText) => { - const [numberPVC] = pvcText.split(' '); - initialPVC = Number(numberPVC); + initialPVC = Number(extractNumbersFromText(pvcText)); + cy.log(`Initial number of PVCs: ${initialPVC}`); }); cy.byTestID('inventory-pv') .invoke('text') .then((pvText) => { - const [numberPV] = pvText.split(' '); - initialPV = Number(numberPV); + initialPV = Number(extractNumbersFromText(pvText)); + cy.log(`Initial number of PVs: ${initialPV}`); }); cy.exec( ` echo '${JSON.stringify( @@ -90,11 +92,15 @@ describe('Check Persistent Dashboard', () => { ) )}' | oc create -f -` ).then(() => { - cy.byTestID('inventory-pvc').contains( - `${(initialPVC + 1).toString()} PersistentVolumeClaims` + cy.byTestID('inventory-pvc').should( + 'have.text', + `${initialPVC + 1} PersistentVolumeClaims`, + { timeout: 3 * SECOND } ); - cy.byTestID('inventory-pv').contains( - `${(initialPV + 1).toString()} PersistentVolumes` + cy.byTestID('inventory-pv').should( + 'have.text', + `${initialPV + 1} PersistentVolumes`, + { timeout: 3 * SECOND } ); }); }); diff --git a/cypress/tests/storage-pool-in-storageclass-form.spec.ts b/cypress/tests/storage-pool-in-storageclass-form.spec.ts index 640750500..6abe7e204 100644 --- a/cypress/tests/storage-pool-in-storageclass-form.spec.ts +++ b/cypress/tests/storage-pool-in-storageclass-form.spec.ts @@ -12,16 +12,6 @@ import { } from '../views/storage-pool'; describe('Test storage pool creation when creating a new StorageClass', () => { - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - it(`Creates a new ${POOL_TYPE.BLOCK} pool`, () => { const poolName = 'sc-block-name'; diff --git a/cypress/tests/storage-pool.spec.ts b/cypress/tests/storage-pool.spec.ts index f6d3326c8..8d1527bfa 100644 --- a/cypress/tests/storage-pool.spec.ts +++ b/cypress/tests/storage-pool.spec.ts @@ -25,16 +25,6 @@ describe('Block pool on ODF UI', () => { const poolName = 'block-name'; const pvcName: string = 'testing-pvc'; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - beforeEach(() => { navigateToStoragePoolList(); }); @@ -109,18 +99,12 @@ describe('Block pool on ODF UI', () => { describe('Tests form validations on block pool', () => { const nameFieldTestId: string = 'new-pool-name-textbox'; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); + + beforeEach(() => { navigateToStoragePoolList(); cy.byTestID('item-create').click(); }); - after(() => { - cy.logout(); - }); - fieldValidationOnWizardFormsTests(nameFieldTestId, 'Create', () => fillStoragePoolForm(POOL_TYPE.BLOCK, 'test-name') ); @@ -130,16 +114,6 @@ describe('Filesystem pool on ODF UI', () => { const poolName = 'fs-name'; const poolFullName = `${CEPH_DEFAULT_FS_POOL_PREFIX}-${poolName}`; - before(() => { - cy.login(); - cy.visit('/'); - cy.install(); - }); - - after(() => { - cy.logout(); - }); - beforeEach(() => { navigateToStoragePoolList(); }); diff --git a/cypress/views/obcPage.ts b/cypress/views/obcPage.ts index fe0d06e6e..c6cf4d551 100644 --- a/cypress/views/obcPage.ts +++ b/cypress/views/obcPage.ts @@ -29,7 +29,6 @@ export class CreateOBCHandler { cy.get('#page-sidebar').contains('Data Foundation'); // eslint-disable-line cypress/require-data-selectors obcNavigate.navigateToOBC(); projectNameSpace.selectOrCreateProject(this.namespace); - obcNavigate.navigateToOBC(); cy.byLegacyTestID('namespace-bar-dropdown').contains('Project').click(); cy.contains(this.namespace); cy.byTestID('item-create').click(); diff --git a/cypress/views/pvc.ts b/cypress/views/pvc.ts index 25fdcc5b5..47b654f51 100644 --- a/cypress/views/pvc.ts +++ b/cypress/views/pvc.ts @@ -29,6 +29,12 @@ export const pvc = { }; export const deletePVCFromCLI = (pvcName: string, ns = 'default') => { - cy.log('Deleting a PVC'); - cy.exec(`oc delete pvc ${pvcName} -n ${ns}`); + cy.log('Deleting the PVC'); + cy.exec(`oc delete pvc ${pvcName} -n ${ns}`, { + failOnNonZeroExit: false, + }).then((result) => { + if (result.code !== 0 && !result.stderr.includes('not found')) { + throw new Error(`PVC deletion failed: ${result.stderr}`); + } + }); };