From e6e4318736fe38f460a6f9c5b90721b6e78fbede Mon Sep 17 00:00:00 2001 From: kpunwatk Date: Thu, 16 Nov 2023 21:16:18 +0530 Subject: [PATCH] [WIP] Automate Application imformation test case Signed-off-by: Karishma Punwatkar modified: cypress/e2e/models/migration/applicationinventory/application.ts modified: cypress/e2e/tests/migration/applicationinventory/applications/crud.test.ts modified: cypress/e2e/types/constants.ts modified: cypress/e2e/views/applicationinventory.view.ts --- .../applicationinventory/application.ts | 23 +++++++++++- .../applications/crud.test.ts | 35 ++++++++++++++++++- cypress/e2e/types/constants.ts | 1 + .../e2e/views/applicationinventory.view.ts | 2 ++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/models/migration/applicationinventory/application.ts b/cypress/e2e/models/migration/applicationinventory/application.ts index 0b17c8368..deff3a9b7 100644 --- a/cypress/e2e/models/migration/applicationinventory/application.ts +++ b/cypress/e2e/models/migration/applicationinventory/application.ts @@ -26,6 +26,7 @@ import { analyzeButton, reviewAppButton, migration, + details, } from "../../../types/constants"; import { navMenu, navTab } from "../../../views/menu.view"; import { @@ -46,6 +47,7 @@ import { packaging, kebabMenu, repoTypeSelect, + profileEdit, } from "../../../views/applicationinventory.view"; import { appDetailsView } from "../../../views/applicationinventory.view"; import * as commonView from "../../../views/common.view"; @@ -214,11 +216,16 @@ export class Application { owner?: string; comment?: string; repoType?: string; + group?: string; }, + updateAppInfo = false, cancel = false ): void { cy.wait(2000); - performRowActionByIcon(this.name, editButton); + if (updateAppInfo) this.applicationInformation(); + else { + performRowActionByIcon(this.name, editButton); + } if (cancel) { cancelForm(); @@ -247,6 +254,14 @@ export class Application { this.selectRepoType(updatedValues.repoType); this.repoType = updatedValues.repoType; } + if (updatedValues.owner && updatedValues.owner != this.owner) { + this.selectOwner(updatedValues.owner); + this.owner = updatedValues.owner; + } + if (updatedValues.group && updatedValues.group != this.group) { + this.fillBinaryModeFields(); + this.group = updatedValues.group; + } if (updatedValues) { submitForm(); } @@ -429,4 +444,10 @@ export class Application { doesExistText("Upload a local binary", rbacRules["Upload binary"]); clickByText(button, "Cancel"); } + + applicationInformation(): void { + this.applicationDetailsTab(details); + cy.wait(2000); + cy.get(profileEdit).click(); + } } diff --git a/cypress/e2e/tests/migration/applicationinventory/applications/crud.test.ts b/cypress/e2e/tests/migration/applicationinventory/applications/crud.test.ts index 302cabb06..a95d2a34b 100644 --- a/cypress/e2e/tests/migration/applicationinventory/applications/crud.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/applications/crud.test.ts @@ -15,9 +15,17 @@ limitations under the License. */ /// -import { exists, login, notExists, getRandomApplicationData } from "../../../../../utils/utils"; +import { + exists, + login, + notExists, + getRandomApplicationData, + getRandomAnalysisData, +} from "../../../../../utils/utils"; import * as data from "../../../../../utils/data_utils"; import { Assessment } from "../../../../models/migration/applicationinventory/assessment"; +import { Stakeholders } from "../../../../models/migration/controls/stakeholders"; +import { Analysis } from "../../../../models/migration/applicationinventory/analysis"; describe(["@tier1"], "Application crud operations", () => { beforeEach("Login", function () { @@ -26,6 +34,13 @@ describe(["@tier1"], "Application crud operations", () => { // Interceptors cy.intercept("POST", "/hub/application*").as("postApplication"); cy.intercept("GET", "/hub/application*").as("getApplication"); + + cy.fixture("application").then(function (appData) { + this.appData = appData; + }); + cy.fixture("analysis").then(function (analysisData) { + this.analysisData = analysisData; + }); }); it("Application crud", function () { @@ -49,4 +64,22 @@ describe(["@tier1"], "Application crud operations", () => { // Assert that newly created application is deleted notExists(application.name); }); + + it("Update application profile details", function () { + const stakeholder = new Stakeholders(data.getEmail(), data.getFullName()); + stakeholder.create(); + cy.wait(2000); + // const application = new Assessment(getRandomApplicationData()); + const application = new Analysis( + getRandomApplicationData("tackleTestApp_Source", { + sourceData: this.appData["tackle-testapp-git"], + }), + getRandomAnalysisData(this.analysisData["analysis_for_enableTagging"]) + ); + application.create(); + cy.wait("@getApplication"); + + var addComment = data.getDescription(); + application.edit({ owner: stakeholder.name, comment: addComment }, true); + }); }); diff --git a/cypress/e2e/types/constants.ts b/cypress/e2e/types/constants.ts index 458abefea..b933f772b 100644 --- a/cypress/e2e/types/constants.ts +++ b/cypress/e2e/types/constants.ts @@ -37,6 +37,7 @@ export const criticality = "Criticality"; export const credentials = "Credentials"; export const credentialType = "Credential type"; export const deleteAction = "Delete"; +export const details = "Details"; export const editAction = "Edit"; export const startDate = "Start date"; export const endDate = "End date"; diff --git a/cypress/e2e/views/applicationinventory.view.ts b/cypress/e2e/views/applicationinventory.view.ts index d849d0168..0a14e01e3 100644 --- a/cypress/e2e/views/applicationinventory.view.ts +++ b/cypress/e2e/views/applicationinventory.view.ts @@ -43,6 +43,8 @@ export const kebabMenu = "#row-actions"; export const topKebabMenu = "#toolbar-kebab"; export const kebabMenuItem = "span.pf-v5-c-menu__item-text"; export const bulkApplicationSelectionCheckBox = "input[name='bulk-selected-items-checkbox']"; +export const profileEdit = ".pf-m-1-col > .pf-v5-c-button"; + // This is on the Application imports page. export const sideKebabMenuImports = "button[aria-label='Kebab toggle']";