From 45421001b48e2904ff99e1db26a24e0b3342dd6d Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Mon, 11 Dec 2023 12:35:48 -0600 Subject: [PATCH] [RFR] Add method to validate archetype/application review fields (#870) * Add method to validate archetype/application review fields Signed-off-by: Nandini Chandra * update archetype.validateReviewFields() Signed-off-by: Nandini Chandra * Remove duplicate function Signed-off-by: Nandini Chandra * Moved common data to assessment.ts file Signed-off-by: Nandini Chandra * Update assessment.sidedrawerTab() Signed-off-by: Nandini Chandra * Some clean up Signed-off-by: Nandini Chandra * Update effortEstimateList Signed-off-by: Nandini Chandra * Update effortEstimateList Signed-off-by: Nandini Chandra * Update archetype view Signed-off-by: Nandini Chandra --------- Signed-off-by: Nandini Chandra --- .../applicationinventory/application.ts | 5 ++ .../applicationinventory/assessment.ts | 58 ++++++++++++++++++- .../models/migration/archetypes/archetype.ts | 19 +++--- .../assessment/assess_review.test.ts | 16 +++-- .../archetypes/assess_review.test.ts | 26 ++++++--- cypress/e2e/views/archetype.view.ts | 7 --- cypress/e2e/views/common.view.ts | 2 + 7 files changed, 96 insertions(+), 37 deletions(-) diff --git a/cypress/e2e/models/migration/applicationinventory/application.ts b/cypress/e2e/models/migration/applicationinventory/application.ts index 00ce86e9f..bbf902062 100644 --- a/cypress/e2e/models/migration/applicationinventory/application.ts +++ b/cypress/e2e/models/migration/applicationinventory/application.ts @@ -549,6 +549,11 @@ export class Application { Assessment.verifyStatus(this.name, column, status); } + validateReviewFields(): void { + Application.open(); + Assessment.validateReviewFields(this.name, "Application"); + } + retake_questionnaire( risk, stakeholders?: Stakeholders[], diff --git a/cypress/e2e/models/migration/applicationinventory/assessment.ts b/cypress/e2e/models/migration/applicationinventory/assessment.ts index 0f8c1d62e..d43125724 100644 --- a/cypress/e2e/models/migration/applicationinventory/assessment.ts +++ b/cypress/e2e/models/migration/applicationinventory/assessment.ts @@ -43,7 +43,6 @@ import { } from "../../../views/review.view"; import { Stakeholdergroups } from "../controls/stakeholdergroups"; import { Stakeholders } from "../controls/stakeholders"; -import { rightSideMenu } from "../../../views/analysis.view"; export class Assessment { public static selectStakeholders(stakeholders: Stakeholders[]): void { @@ -217,6 +216,61 @@ export class Assessment { cy.wait(2 * SEC); } + public static validateReviewFields(name: string, entityName: string): void { + let list = [ + "Proposed action", + "Effort estimate", + "Business criticality", + "Work priority", + "Comments", + ]; + let actionList = [ + `${entityName} - ${name}-Rehost`, + `${entityName} - ${name}-Replatform`, + `${entityName} - ${name}-Refactor`, + `${entityName} - ${name}-Retain`, + `${entityName} - ${name}-Repurchase`, + `${entityName} - ${name}-Retire`, + ]; + let effortEstimateList = [ + `${entityName} - ${name}-Small`, + `${entityName} - ${name}-Medium`, + `${entityName} - ${name}-Large`, + `${entityName} - ${name}-Extra large`, + ]; + let criticalityList = [ + `${entityName} - ${name}-1`, + `${entityName} - ${name}-2`, + `${entityName} - ${name}-3`, + `${entityName} - ${name}-4`, + `${entityName} - ${name}-5`, + `${entityName} - ${name}-6`, + `${entityName} - ${name}-7`, + `${entityName} - ${name}-8`, + `${entityName} - ${name}-9`, + `${entityName} - ${name}-10`, + ]; + + this.sidedrawerTab(name, "Review"); + for (let i in list) { + cy.get("dt") + .contains(list[i]) + .closest("div") + .within(() => { + cy.get("dd").then(($value) => { + let text = $value.text(); + if (list[i] == "Proposed action") expect(text).to.be.oneOf(actionList); + if (list[i] == "Effort estimate") + expect(text).to.be.oneOf(effortEstimateList); + if (list[i] == "Business criticality" || list[i] == "Work priority") + expect(text).to.be.oneOf(criticalityList); + if (list[i] == "Comments") expect(text).not.equal("Not yet reviewed"); + }); + }); + } + click(commonView.sideDrawer.closeDrawer); + } + public static verifyStatus(name, column, status): void { let columnSelector: string; if (column === "assessment") columnSelector = assessmentColumnSelector; @@ -239,7 +293,7 @@ export class Assessment { public static sidedrawerTab(name: string, tab: string): void { selectRow(name); - cy.get(rightSideMenu).within(() => { + cy.get(commonView.sideDrawer.pageDrawerContent).within(() => { clickTab(tab); }); } diff --git a/cypress/e2e/models/migration/archetypes/archetype.ts b/cypress/e2e/models/migration/archetypes/archetype.ts index 727995b6f..3ca798de1 100644 --- a/cypress/e2e/models/migration/archetypes/archetype.ts +++ b/cypress/e2e/models/migration/archetypes/archetype.ts @@ -216,19 +216,9 @@ export class Archetype { ); } - validateAssessmentField(): void { + validateAssessmentField(risk: string): void { Archetype.open(true); - this.sidedrawerTab("Details"); - cy.get(archetype.sideDrawer.risk).contains("Archetype risk"); - cy.get(archetype.sideDrawer.riskValue).contains(/High|Medium|Low/g); - click(archetype.sideDrawer.closeDrawer); - } - - sidedrawerTab(tab: string): void { - this.selectArchetype(); - cy.get(rightSideMenu).within(() => { - clickTab(tab); - }); + Assessment.validateAssessmentField(this.name, "Archetype", risk); } selectArchetype(): void { @@ -244,4 +234,9 @@ export class Archetype { cy.wait(8 * SEC); Assessment.perform_review(risk); } + + validateReviewFields(): void { + Archetype.open(true); + Assessment.validateReviewFields(this.name, "Archetype"); + } } diff --git a/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts b/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts index 3e7101184..9234cf5c9 100644 --- a/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts @@ -53,7 +53,6 @@ describe(["@tier1"], "Application assessment and review tests", () => { }); it("Application assessment and review with low risk", function () { - // Navigate to application inventory tab and create new application const application = new Application(getRandomApplicationData()); application.create(); cy.wait("@getApplication"); @@ -63,20 +62,19 @@ describe(["@tier1"], "Application assessment and review tests", () => { application.perform_assessment("low", stakeholders); cy.wait(2 * SEC); application.verifyStatus("assessment", "Completed"); + application.validateAssessmentField("Low"); // Perform application review application.perform_review("low"); cy.wait(2 * SEC); application.verifyStatus("review", "Completed"); - application.validateAssessmentField("Low"); + application.validateReviewFields(); - // Delete application application.delete(); cy.wait(2 * SEC); }); it(["@interop"], "Application assessment and review with medium risk", function () { - // Navigate to application inventory tab and create new application const application = new Application(getRandomApplicationData()); application.create(); cy.wait("@getApplication"); @@ -86,20 +84,19 @@ describe(["@tier1"], "Application assessment and review tests", () => { application.perform_assessment("medium", stakeholders); cy.wait(2 * SEC); application.verifyStatus("assessment", "Completed"); + application.validateAssessmentField("Medium"); // Perform application review application.perform_review("medium"); cy.wait(2 * SEC); application.verifyStatus("review", "Completed"); - application.validateAssessmentField("Medium"); + application.validateReviewFields(); - // Delete application application.delete(); cy.wait(2 * SEC); }); it("Application assessment and review with high risk", function () { - // Navigate to application inventory tab and create new application const application = new Application(getRandomApplicationData()); application.create(); cy.wait("@getApplication"); @@ -109,14 +106,14 @@ describe(["@tier1"], "Application assessment and review tests", () => { application.perform_assessment("high", stakeholders); cy.wait(2 * SEC); application.verifyStatus("assessment", "Completed"); + application.validateAssessmentField("High"); // Perform application review application.perform_review("high"); cy.wait(2 * SEC); application.verifyStatus("review", "Completed"); - application.validateAssessmentField("High"); + application.validateReviewFields(); - // Delete application application.delete(); cy.wait(2 * SEC); }); @@ -165,6 +162,7 @@ describe(["@tier1"], "Application assessment and review tests", () => { application.verifyStatus("assessment", "Completed"); application.verifyStatus("review", "Completed"); + application.validateReviewFields(); // Automates bug: https://issues.redhat.com/browse/MTA-1751 application.clickReviewButton(); diff --git a/cypress/e2e/tests/migration/archetypes/assess_review.test.ts b/cypress/e2e/tests/migration/archetypes/assess_review.test.ts index 0af0f7873..bded9734e 100644 --- a/cypress/e2e/tests/migration/archetypes/assess_review.test.ts +++ b/cypress/e2e/tests/migration/archetypes/assess_review.test.ts @@ -32,7 +32,7 @@ import { Tag } from "../../../models/migration/controls/tags"; let stakeholders: Stakeholders[]; let tags: Tag[]; -describe(["@tier1"], "Archetype assessment tests", () => { +describe(["@tier1"], "Archetype assessment and review tests", () => { before("Login and Create Test Data", function () { login(); AssessmentQuestionnaire.deleteAllQuesionnaire(); @@ -42,7 +42,7 @@ describe(["@tier1"], "Archetype assessment tests", () => { tags = createMultipleTags(2); }); - it("Archetype assessment with low risk", function () { + it("Archetype assessment and review with low risk", function () { const archetype = new Archetype( data.getRandomWord(8), [tags[0].name], @@ -55,13 +55,17 @@ describe(["@tier1"], "Archetype assessment tests", () => { archetype.perform_assessment("low", stakeholders); cy.wait(2 * SEC); - archetype.validateAssessmentField(); + archetype.validateAssessmentField("Low"); + + archetype.perform_review("low"); + cy.wait(2 * SEC); + archetype.validateReviewFields(); archetype.delete(); cy.wait(2 * SEC); }); - it("Archetype assessment with medium risk", function () { + it("Archetype assessment and review with medium risk", function () { const archetype = new Archetype( data.getRandomWord(8), [tags[0].name], @@ -74,13 +78,17 @@ describe(["@tier1"], "Archetype assessment tests", () => { archetype.perform_assessment("medium", stakeholders); cy.wait(2 * SEC); - archetype.validateAssessmentField(); + archetype.validateAssessmentField("Medium"); + + archetype.perform_review("medium"); + cy.wait(2 * SEC); + archetype.validateReviewFields(); archetype.delete(); cy.wait(2 * SEC); }); - it("Archetype assessment with high risk", function () { + it("Archetype assessment and review with high risk", function () { const archetype = new Archetype( data.getRandomWord(8), [tags[0].name], @@ -93,7 +101,11 @@ describe(["@tier1"], "Archetype assessment tests", () => { archetype.perform_assessment("high", stakeholders); cy.wait(2 * SEC); - archetype.validateAssessmentField(); + archetype.validateAssessmentField("High"); + + archetype.perform_review("high"); + cy.wait(2 * SEC); + archetype.validateReviewFields(); archetype.delete(); cy.wait(2 * SEC); diff --git a/cypress/e2e/views/archetype.view.ts b/cypress/e2e/views/archetype.view.ts index 4ebc0b846..64fe1ff66 100644 --- a/cypress/e2e/views/archetype.view.ts +++ b/cypress/e2e/views/archetype.view.ts @@ -20,10 +20,3 @@ export const archetypeTags = "#tags"; export const stakeholders = "input[aria-label='stakeholder-select-toggle']"; export const stakeholderGroups = "input[aria-label='stakeholder-groups-select-toggle']"; export const comments = "#comments"; - -//Fields related to archetype side drawer -export enum sideDrawer { - risk = "h3.pf-v5-c-title.pf-m-md", - riskValue = "span.pf-v5-c-label__content", - closeDrawer = "button[aria-label='Close drawer panel']", -} diff --git a/cypress/e2e/views/common.view.ts b/cypress/e2e/views/common.view.ts index 9c846d1ad..221b3d153 100644 --- a/cypress/e2e/views/common.view.ts +++ b/cypress/e2e/views/common.view.ts @@ -74,8 +74,10 @@ export const filterDropDownContainer = export const filterDropDown = "div.pf-v5-c-select"; export const actionSelectToggle = "#action-select-toggle"; +// Application/Archetype side drawer export enum sideDrawer { risk = "h3.pf-v5-c-title.pf-m-md", riskValue = "span.pf-v5-c-label__content", closeDrawer = "button[aria-label='Close drawer panel']", + pageDrawerContent = "#page-drawer-content", }