Skip to content

Commit

Permalink
[RFR] Report tab refactoring (#883)
Browse files Browse the repository at this point in the history
* Report tab refactoring

Signed-off-by: Shveta Sachdeva <[email protected]>

* Report tab refactoring

Signed-off-by: Shveta Sachdeva <[email protected]>

---------

Signed-off-by: Shveta Sachdeva <[email protected]>
Co-authored-by: Shveta Sachdeva <[email protected]>
  • Loading branch information
sshveta and Shveta Sachdeva authored Dec 14, 2023
1 parent d4e81a2 commit 2aa03d4
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 889 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/models/administration/general/generalConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { click, clickByText, selectUserPerspective } from "../../../../utils/utils";
import { administration, general } from "../../../types/constants";
import { navMenu } from "../../../views/menu.view";
import { switchToggle } from "../../../views/reports.view";
import { switchToggle } from "../../../views/reportsTab.view";

export class GeneralConfig {
static fullUrl = Cypress.env("tackleUrl") + "/general";
Expand Down
77 changes: 77 additions & 0 deletions cypress/e2e/models/migration/reports-tab/reports-tab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Copyright © 2021 the Konveyor Contributors (https://konveyor.io/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { clickByText, getUrl, selectUserPerspective } from "../../../../utils/utils";
import { SEC, migration } from "../../../types/constants";
import { navMenu } from "../../../views/menu.view";
import {
highRiskDonut,
lowRiskDonut,
mediumRiskDonut,
unknownRiskDonut,
} from "../../../views/reportsTab.view";

export class Reports {
static fullUrl = Cypress.env("tackleUrl") + "/reports";

public static open(): void {
if (!getUrl().includes(Reports.fullUrl)) {
selectUserPerspective(migration);
}
clickByText(navMenu, "Reports");
cy.wait(2 * SEC);
}

public static verifyRisk(
highRiskValue: number,
mediumRiskValue: number,
lowRiskValue: number,
unknownRiskValue: number,
totalApps: string
): void {
Reports.open();
this.getRiskValue(highRiskDonut, highRiskValue);
this.getTotalApplicationsValue(highRiskDonut, totalApps);
this.getRiskValue(mediumRiskDonut, mediumRiskValue);
this.getTotalApplicationsValue(mediumRiskDonut, totalApps);
this.getRiskValue(lowRiskDonut, lowRiskValue);
this.getTotalApplicationsValue(lowRiskDonut, totalApps);
this.getRiskValue(unknownRiskDonut, unknownRiskValue);
this.getTotalApplicationsValue(unknownRiskDonut, totalApps);
}

public static getRiskValue(selector, value): void {
cy.get(selector)
.eq(0)
.find("tspan")
.eq(0)
.invoke("text")
.then(($text) => {
cy.wrap(parseFloat($text)).should("eq", value);
});
}

public static getTotalApplicationsValue(selector, value): void {
cy.get(selector)
.eq(0)
.find("tspan")
.eq(1)
.invoke("text")
.then(($text) => {
cy.wrap($text).should("include", value);
});
}
}
72 changes: 0 additions & 72 deletions cypress/e2e/models/migration/reports/reports.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
deleteAppImportsTableRows,
notExists,
deleteByList,
deleteAllMigrationWaves,
} from "../../../../../utils/utils";

import { Stakeholders } from "../../../../models/migration/controls/stakeholders";
Expand Down Expand Up @@ -83,6 +84,7 @@ describe(["@tier2"], "Operations after application import", () => {
});

after("Perform test data clean up", function () {
deleteAllMigrationWaves();
deleteApplicationTableRows();
deleteAppImportsTableRows();
deleteByList(stakeholders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
deleteApplicationTableRows,
deleteAppImportsTableRows,
clickOnSortButton,
deleteAllMigrationWaves,
} from "../../../../../utils/utils";
import { navMenu } from "../../../../views/menu.view";
import { SortType, applicationInventory } from "../../../../types/constants";
Expand Down Expand Up @@ -167,6 +168,7 @@ describe(["@tier2"], "Manage applications import sort validations", function ()
});

after("Perform test data clean up", function () {
deleteAllMigrationWaves();
deleteApplicationTableRows();
deleteAppImportsTableRows();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,38 @@ limitations under the License.

import {
login,
clickByText,
createMultipleStakeholders,
createMultipleApplications,
selectUserPerspective,
deleteByList,
deleteApplicationTableRows,
deleteAllMigrationWaves,
} from "../../../../utils/utils";
import { verifyApplicationRisk } from "../../../models/migration/reports/reports";
import { navMenu } from "../../../views/menu.view";
import { legacyPathfinder, migration, reports, SEC } from "../../../types/constants";
import { legacyPathfinder } from "../../../types/constants";
import { Stakeholders } from "../../../models/migration/controls/stakeholders";
import { Application } from "../../../models/migration/applicationinventory/application";
import { AssessmentQuestionnaire } from "../../../models/administration/assessment_questionnaire/assessment_questionnaire";
import { Reports } from "../../../models/migration/reports-tab/reports-tab";

let stakeholdersList: Array<Stakeholders> = [];
let applicationsList: Array<Application> = [];
const totalApplications = "8";
const highRiskApps = 3;
const mediumRiskApps = 1;
const lowRiskApps = 2;
const unknownRiskApps = 2;

describe(["@tier2"], "Application risks tests", () => {
let riskType = ["low", "medium", "high"];
let riskType = ["low", "medium", "high", "low", "high", "high"];

describe(["@tier2"], "Reports tests", () => {
before("Login and Create Test Data", function () {
login();
AssessmentQuestionnaire.deleteAllQuesionnaire();
AssessmentQuestionnaire.enable(legacyPathfinder);
deleteAllMigrationWaves();
deleteApplicationTableRows();
stakeholdersList = createMultipleStakeholders(1);
applicationsList = createMultipleApplications(3);
for (let i = 0; i < applicationsList.length; i++) {
applicationsList = createMultipleApplications(8);
for (let i = 0; i < 6; i++) {
// Perform assessment of application
applicationsList[i].perform_assessment(riskType[i], stakeholdersList);
applicationsList[i].verifyStatus("assessment", "Completed");
Expand All @@ -52,14 +59,14 @@ describe(["@tier2"], "Application risks tests", () => {
}
});

it("Application risk validation", function () {
selectUserPerspective(migration);
clickByText(navMenu, reports);
cy.wait(3 * SEC);

for (let i = 0; i < 3; i++) {
verifyApplicationRisk(riskType[i], applicationsList[i].name);
}
it("Number of Application risk validation", function () {
Reports.verifyRisk(
highRiskApps,
mediumRiskApps,
lowRiskApps,
unknownRiskApps,
totalApplications
);
});

after("Perform test data clean up", function () {
Expand Down
Loading

0 comments on commit 2aa03d4

Please sign in to comment.