From f47542590409f2dd7311d7a73af11b13c3a49d81 Mon Sep 17 00:00:00 2001 From: Julien ADAMEK Date: Thu, 1 Dec 2022 15:52:22 +0100 Subject: [PATCH] Delete OS version and channel in e2e UI tests (#549) --- .../unit_tests/machine_registration.spec.ts | 2 +- cypress/e2e/unit_tests/upgrade.spec.ts | 19 ++++++++++++++++++- cypress/support/e2e.ts | 2 +- cypress/support/functions.ts | 16 ++++++++-------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/unit_tests/machine_registration.spec.ts b/cypress/e2e/unit_tests/machine_registration.spec.ts index ad3b157ee..4ace4d236 100644 --- a/cypress/e2e/unit_tests/machine_registration.spec.ts +++ b/cypress/e2e/unit_tests/machine_registration.spec.ts @@ -31,7 +31,7 @@ describe('Machine registration testing', () => { cy.get('.outlet > header').contains('Registration Endpoints'); cy.get('body').then(($body) => { if (!$body.text().includes('There are no rows to show.')) { - cy.deleteAllMachReg(); + cy.deleteAllResources(); }; }); }); diff --git a/cypress/e2e/unit_tests/upgrade.spec.ts b/cypress/e2e/unit_tests/upgrade.spec.ts index d530049dc..c3d0eaf63 100644 --- a/cypress/e2e/unit_tests/upgrade.spec.ts +++ b/cypress/e2e/unit_tests/upgrade.spec.ts @@ -20,7 +20,6 @@ describe('Upgrade tests', () => { // Click on the Elemental's icon elemental.accessElementalMenu(); - }); it('Create an OS Version Channels', () => { @@ -48,6 +47,24 @@ describe('Upgrade tests', () => { cy.contains('Active teal-5.3'); }); + it('Delete OS Versions', () => { + cy.get('.nav').contains('Advanced').click(); + cy.get('.nav').contains('OS Versions').click(); + cy.contains('teal-5.2').parent().parent().click(); + cy.clickButton('Delete'); + cy.confirmDelete(); + cy.contains('teal-5.2').should('not.exist'); + }); + + it('Delete OS Versions Channels', () => { + cy.get('.nav').contains('Advanced').click(); + cy.get('.nav').contains('OS Version Channels').click(); + cy.deleteAllResources(); + cy.get('.nav').contains('Advanced').click(); + cy.get('.nav').contains('OS Versions').click(); + cy.contains('There are no rows to show'); + }); + it('Upgrade one node with OS Image Upgrades', () => { // Create ManagedOSImage resource cy.get('.nav').contains('Advanced').click(); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 49cf02628..b79426785 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -17,7 +17,7 @@ declare global { getDetail(name: string, type: string, namespace?: string): Chainable; createMachReg(machRegName: string, namespace?: string, checkLabels?: boolean, checkAnnotations?: boolean, customCloudConfig?: string, checkDefaultCloudConfig?: boolean): Chainable; deleteMachReg(machRegName: string): Chainable; - deleteAllMachReg():Chainable; + deleteAllResources():Chainable; addMachRegLabel(labelName: string, labelValue: string):Chainable; checkMachRegLabel(machRegName: string, labelName: string, labelValue: string):Chainable; checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable; diff --git a/cypress/support/functions.ts b/cypress/support/functions.ts index 5056738ec..3859ad957 100644 --- a/cypress/support/functions.ts +++ b/cypress/support/functions.ts @@ -116,6 +116,14 @@ Cypress.Commands.add('addHelmRepo', ({repoName, repoUrl, repoType}) => { cy.clickButton('Create'); }); +// Delete all resources from a page +Cypress.Commands.add('deleteAllResources', () => { + cy.get('[width="30"] > .checkbox-outer-container').click(); + cy.clickButton('Delete'); + cy.confirmDelete(); + cy.contains('There are no rows to show'); +}); + // Machine registration functions // Create a machine registration @@ -278,14 +286,6 @@ Cypress.Commands.add('deleteMachReg', ({machRegName}) => { cy.contains(machRegName).should('not.exist') }); -// Delete all machine registrations -Cypress.Commands.add('deleteAllMachReg', () => { - cy.get('[width="30"] > .checkbox-outer-container').click(); - cy.clickButton('Delete'); - cy.confirmDelete(); - cy.contains('There are no rows to show'); -}); - // Machine Inventory functions // Import machine inventory