From 0205321ff1f52d20bcb4e0a0d17393a1b0298cf1 Mon Sep 17 00:00:00 2001 From: Julien Adamek Date: Fri, 9 Feb 2024 09:02:49 +0100 Subject: [PATCH] ci/ui: clean code for 1.3.0 UI --- .../unit_tests/upgrade-ui-extension.spec.ts | 8 +++-- tests/cypress/latest/support/commands.ts | 32 ++++++------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/tests/cypress/latest/e2e/unit_tests/upgrade-ui-extension.spec.ts b/tests/cypress/latest/e2e/unit_tests/upgrade-ui-extension.spec.ts index 91617b9df..c3f267976 100644 --- a/tests/cypress/latest/e2e/unit_tests/upgrade-ui-extension.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/upgrade-ui-extension.spec.ts @@ -52,8 +52,12 @@ describe('UI extension upgrade tests', () => { .click(); cy.getBySel('install-ext-modal-install-btn') .click(); - cy.contains('Extensions changed - reload required', {timeout: 100000}); - cy.clickButton('Reload'); + // Sometimes the reload button is not displayed and it breaks the test... + // Adding a sleep command waiting a more elegant solution + //cy.contains('Extensions changed - reload required', {timeout: 100000}); + //cy.clickButton('Reload'); + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(120000); cy.reload(); cy.getBySel('extension-card-uninstall-btn-elemental') }) diff --git a/tests/cypress/latest/support/commands.ts b/tests/cypress/latest/support/commands.ts index eebe77ee2..0fa19ce94 100644 --- a/tests/cypress/latest/support/commands.ts +++ b/tests/cypress/latest/support/commands.ts @@ -67,7 +67,6 @@ Cypress.Commands.add('createMachReg', ( checkIsoBuilding=false, customCloudConfig='', checkDefaultCloudConfig=true ) => { - let selector cy.clickNavMenu(["Dashboard"]); cy.getBySel('button-create-registration-endpoint') .click(); @@ -118,14 +117,8 @@ Cypress.Commands.add('createMachReg', ( // cy.getBySel('select-os-version-build-media') // .click(); //} - // Next if condition will be removed once ui extension 1.3.0 is released - if (utils.isUIVersion('stable')) { - cy.getBySel('select-os-version-build-iso') - .click(); - } else { - cy.getBySel('select-os-version-build-media') - .click(); - } + cy.getBySel('select-os-version-build-media') + .click(); // Never build from dev ISO in upgrade scenario if (utils.isCypressTag('upgrade')) { // Stable operator version is hardcoded for now @@ -148,20 +141,19 @@ Cypress.Commands.add('createMachReg', ( cy.contains('ISO x86_64 (unstable)') .click(); } - utils.isUIVersion('stable') ? selector="iso" : selector="media"; - cy.getBySel(`build-${selector}-btn`) + cy.getBySel(`build-media-btn`) .click(); - cy.getBySel(`build-${selector}-btn`) + cy.getBySel(`build-media-btn`) .get('.icon-spin'); // Download button is disabled while ISO is building - cy.getBySel(`download-${selector}-btn`).should(($input) => { + cy.getBySel(`download-media-btn`).should(($input) => { expect($input).to.have.attr('disabled') }) // Download button is enabled once ISO building done - cy.getBySel(`download-${selector}-btn`, { timeout: 600000 }).should(($input) => { + cy.getBySel(`download-media-btn`, { timeout: 600000 }).should(($input) => { expect($input).to.not.have.attr('disabled') }) - cy.getBySel(`download-${selector}-btn`) + cy.getBySel(`download-media-btn`) .click() cy.verifyDownload('.iso', { contains:true, timeout: 180000, interval: 5000 }); } @@ -238,14 +230,8 @@ Cypress.Commands.add('addMachInvLabel', (labelName, labelValue, useHardwareLabel cy.get('[data-testid="add-label-mach-inv"] > .footer > .btn') .click(); cy.get(`[data-testid="add-label-mach-inv"] > .kv-container > :nth-child(${nthChildIndex}) > input`).type(key); - // Following condition could be removed when we will release next Elemental UI (> 1.2.0) - if (utils.isUIVersion('dev')) { - cy.get(`[data-testid="add-label-mach-inv"] > .kv-container > :nth-child(${nthChildIndex + 1}) - > .value-container > [data-testid="text-area-auto-grow"]`).type(hwLabels[key], {parseSpecialCharSequences: false}); - } else { - cy.get(`[data-testid="add-label-mach-inv"] > .kv-container > :nth-child(${nthChildIndex + 1}) - > .no-resize`).type(hwLabels[key], {parseSpecialCharSequences: false}); - }; + cy.get(`[data-testid="add-label-mach-inv"] > .kv-container > :nth-child(${nthChildIndex + 1}) + > .value-container > [data-testid="text-area-auto-grow"]`).type(hwLabels[key], {parseSpecialCharSequences: false}); nthChildIndex += 3; }; };