Skip to content

Commit

Permalink
[RFR] Add method to validate archetype/application review fields (#870)
Browse files Browse the repository at this point in the history
* Add method to validate archetype/application review fields

Signed-off-by: Nandini Chandra <[email protected]>

* update archetype.validateReviewFields()

Signed-off-by: Nandini Chandra <[email protected]>

* Remove duplicate function

Signed-off-by: Nandini Chandra <[email protected]>

* Moved common data to assessment.ts file

Signed-off-by: Nandini Chandra <[email protected]>

* Update assessment.sidedrawerTab()

Signed-off-by: Nandini Chandra <[email protected]>

* Some clean up

Signed-off-by: Nandini Chandra <[email protected]>

* Update effortEstimateList

Signed-off-by: Nandini Chandra <[email protected]>

* Update effortEstimateList

Signed-off-by: Nandini Chandra <[email protected]>

* Update archetype view

Signed-off-by: Nandini Chandra <[email protected]>

---------

Signed-off-by: Nandini Chandra <[email protected]>
  • Loading branch information
nachandr authored Dec 11, 2023
1 parent a3cba74 commit 4542100
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[],
Expand Down
58 changes: 56 additions & 2 deletions cypress/e2e/models/migration/applicationinventory/assessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
});
}
Expand Down
19 changes: 7 additions & 12 deletions cypress/e2e/models/migration/archetypes/archetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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);
});
Expand Down Expand Up @@ -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();
Expand Down
26 changes: 19 additions & 7 deletions cypress/e2e/tests/migration/archetypes/assess_review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions cypress/e2e/views/archetype.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']",
}
2 changes: 2 additions & 0 deletions cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

0 comments on commit 4542100

Please sign in to comment.