diff --git a/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts b/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts index f9bdb171a..3cdf7f79f 100644 --- a/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts +++ b/cypress/e2e/tests/upgrade/create_upgrade_data.test.ts @@ -20,6 +20,8 @@ import { getRandomApplicationData, login, preservecookies, + validateMtaVersionInCli, + validateMtaVersionInUi, } from "../../../utils/utils"; import { TagCategory } from "../../models/migration/controls/tagcategory"; import * as data from "../../../utils/data_utils"; @@ -41,10 +43,13 @@ describe(["@pre-upgrade"], "Creating pre-requisites before an upgrade", () => { let sourceControlUsernameCredentials: CredentialsSourceControlUsername; const assessment = new Assessment(getRandomApplicationData()); let stakeHolder: Stakeholders; + const expectedMtaVersion = Cypress.env("sourceMtaVersion"); before("Login", function () { // Perform login login(); + validateMtaVersionInCli(expectedMtaVersion); + validateMtaVersionInUi(expectedMtaVersion); }); beforeEach("Persist session", function () { diff --git a/cypress/e2e/views/common.view.ts b/cypress/e2e/views/common.view.ts index 505c7377c..40df8d949 100644 --- a/cypress/e2e/views/common.view.ts +++ b/cypress/e2e/views/common.view.ts @@ -55,3 +55,4 @@ export const nameHelperBusiness = "#business-service-name-helper"; export const nameHelperStakeholderGroup = "#-helper"; export const kebabMenuItem = "a.pf-c-dropdown__menu-item"; export const commonTable = "table[aria-label='main-table']"; +export const aboutButton = "#about-button"; diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index fc93a30b9..0a726302d 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -52,6 +52,7 @@ import { } from "../e2e/types/constants"; import { actionButton, date, createEntitiesCheckbox } from "../e2e/views/applicationinventory.view"; import { + aboutButton, closeSuccessNotification, confirmButton, divHeader, @@ -1757,3 +1758,31 @@ export function selectAssessmentApplications(apps: string): void { export function closeModalWindow(): void { click(closeModal, false, true); } + +export function getCommandOutput(command: string): Cypress.Chainable { + return cy.exec(command, { timeout: 30 * SEC }).then((result) => { + return result; + }); +} + +export function validateMtaVersionInCli(expectedMtaVersion: string): void { + const namespace = getNamespace(); + const podName = `$(oc get pods -n${namespace}| grep ui|cut -d " " -f 1)`; + const command = `oc describe pod ${podName} -n${namespace}| grep -i version|awk '{print $2}'`; + getCommandOutput(command).then((output) => { + if (expectedMtaVersion !== output.stdout) { + throw new Error( + `Expected version in UI pod: ${expectedMtaVersion}, Actual version in UI pod: ${output.stdout}` + ); + } + }); +} + +export function validateMtaVersionInUi(expectedVersion: string): void { + click(aboutButton); + cy.contains("dt", "Version") + .closest("dl") + .within(() => { + cy.get("dd").should("contain.text", expectedVersion); + }); +}