From 6bbe084be405cd9034b4d583d2f4b0b841cc93ab Mon Sep 17 00:00:00 2001 From: Julien Adamek Date: Fri, 1 Sep 2023 00:21:09 +0200 Subject: [PATCH] ci/ui: fix how staging is tagged in UI --- .github/workflows/master-e2e.yaml | 1 + .../unit_tests/machine_registration.spec.ts | 4 +--- .../latest/e2e/unit_tests/upgrade.spec.ts | 19 +++++-------------- tests/cypress/latest/support/commands.ts | 10 ++++++++-- tests/cypress/latest/support/utils.ts | 5 +++++ 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/master-e2e.yaml b/.github/workflows/master-e2e.yaml index 0994bc722..b7b3ad222 100644 --- a/.github/workflows/master-e2e.yaml +++ b/.github/workflows/master-e2e.yaml @@ -356,6 +356,7 @@ jobs: /workdir/e2e/unit_tests/machine_registration.spec.ts /workdir/e2e/unit_tests/advanced_filtering.spec.ts UI_ACCOUNT: ${{ inputs.ui_account }} + UPGRADE_OS_CHANNEL: ${{ inputs.upgrade_os_channel }} run: cd tests && make start-cypress-tests - name: Upload Cypress screenshots (Basics) if: failure() && inputs.test_type == 'ui' diff --git a/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts b/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts index 4e9ae7558..51915afbb 100644 --- a/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/machine_registration.spec.ts @@ -37,11 +37,9 @@ describe('Machine registration testing', () => { // In upgrade scenario, we need to add extra channels if (utils.isCypressTag('upgrade')) { if (utils.isOperatorVersion('stable')) { - cy.addOsVersionChannel('dev'); - cy.addOsVersionChannel('staging'); + utils.isUpgradeOsChannel('dev') ? cy.addOsVersionChannel('dev') : cy.addOsVersionChannel('staging'); } else if (utils.isOperatorVersion('staging')) { cy.addOsVersionChannel('dev'); - cy.addOsVersionChannel('stable'); // Not sure it is needed } else { cy.addOsVersionChannel('stable'); } diff --git a/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts b/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts index ee38bd445..0bceac227 100644 --- a/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts +++ b/tests/cypress/latest/e2e/unit_tests/upgrade.spec.ts @@ -27,7 +27,6 @@ describe('Upgrade tests', () => { const uiAccount = Cypress.env('ui_account'); const uiPassword = "rancherpassword" const upgradeImage = Cypress.env('upgrade_image') - const upgradeOsChannel = Cypress.env('upgrade_os_channel') beforeEach(() => { (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login(); @@ -84,19 +83,11 @@ describe('Upgrade tests', () => { .click(); cy.getBySel('os-version-box') .click() - // TODO: remove hardcoded staging version - if (upgradeOsChannel == "staging") { - cy.getBySel('os-version-box') - .parents() - .contains('v1.2.1') - .click(); - } else { - cy.getBySel('os-version-box') - .parents() - .contains('latest-'+upgradeOsChannel) - .click(); - } - } + cy.getBySel('os-version-box') + .parents() + .contains('latest') + .click(); + } cy.getBySel('form-save') .contains('Create') diff --git a/tests/cypress/latest/support/commands.ts b/tests/cypress/latest/support/commands.ts index f63a31725..112936441 100644 --- a/tests/cypress/latest/support/commands.ts +++ b/tests/cypress/latest/support/commands.ts @@ -110,12 +110,18 @@ Cypress.Commands.add('createMachReg', ( if (utils.isCypressTag('upgrade')) { // Stable operator version is hardcoded for now // Will try to improve it in next version - utils.isOperatorVersion('staging') ? cy.contains('Elemental Teal ISO x86_64 latest-staging').click() : cy.contains('Elemental Teal ISO x86_64 v1.1.5').click(); + if (utils.isOperatorVersion('staging')) { + // In rare case, we might want to test upgrading from staging to dev + utils.isUpgradeOsChannel('dev') ? cy.contains('Elemental Teal ISO x86_64 (latest)').click(): null; + } else { + cy.contains('Elemental Teal ISO x86_64 v1.1.5') + .click(); + } } else if (utils.isOperatorVersion('stable')) { cy.contains('Elemental Teal ISO x86_64 v1.1.5') .click(); } else if (utils.isOperatorVersion('staging')) { - cy.contains('Elemental Teal ISO x86_64 latest-staging') + cy.contains('Elemental Teal ISO x86_64 (latest)') .click(); } else { cy.contains('Elemental Teal ISO x86_64 latest-dev') diff --git a/tests/cypress/latest/support/utils.ts b/tests/cypress/latest/support/utils.ts index a84b57588..46266163c 100644 --- a/tests/cypress/latest/support/utils.ts +++ b/tests/cypress/latest/support/utils.ts @@ -24,3 +24,8 @@ export const isRancherManagerVersion = (version: string) => { export const isUIVersion = (version: string) => { return (new RegExp(version)).test(Cypress.env("elemental_ui_version")); } + +// Check the upgrade target +export const isUpgradeOsChannel = (channel: string) => { + return (new RegExp(channel)).test(Cypress.env("upgrade_os_channel")); +} \ No newline at end of file