From 2aa03d468b633fe8673741b4c2d1d018f04e9c4e Mon Sep 17 00:00:00 2001 From: Shveta Sachdeva Date: Wed, 13 Dec 2023 21:23:49 -0800 Subject: [PATCH] [RFR] Report tab refactoring (#883) * Report tab refactoring Signed-off-by: Shveta Sachdeva * Report tab refactoring Signed-off-by: Shveta Sachdeva --------- Signed-off-by: Shveta Sachdeva Co-authored-by: Shveta Sachdeva --- .../administration/general/generalConfig.ts | 2 +- .../migration/reports-tab/reports-tab.ts | 77 ++++ .../e2e/models/migration/reports/reports.ts | 72 ---- .../assessment_after_import.test.ts | 2 + .../manageimports/sort.test.ts | 2 + .../reports.test.ts} | 41 ++- .../tests/migration/reports/filter.test.ts | 343 ------------------ .../migration/reports/pagination.test.ts | 243 ------------- .../e2e/tests/migration/reports/sort.test.ts | 212 ----------- .../{reports.view.ts => reportsTab.view.ts} | 5 + cypress/utils/utils.ts | 28 +- 11 files changed, 138 insertions(+), 889 deletions(-) create mode 100644 cypress/e2e/models/migration/reports-tab/reports-tab.ts delete mode 100644 cypress/e2e/models/migration/reports/reports.ts rename cypress/e2e/tests/migration/{reports/applicationRisk.test.ts => reports-tab/reports.test.ts} (67%) delete mode 100644 cypress/e2e/tests/migration/reports/filter.test.ts delete mode 100644 cypress/e2e/tests/migration/reports/pagination.test.ts delete mode 100644 cypress/e2e/tests/migration/reports/sort.test.ts rename cypress/e2e/views/{reports.view.ts => reportsTab.view.ts} (86%) diff --git a/cypress/e2e/models/administration/general/generalConfig.ts b/cypress/e2e/models/administration/general/generalConfig.ts index 3be7391fe..f262b8170 100644 --- a/cypress/e2e/models/administration/general/generalConfig.ts +++ b/cypress/e2e/models/administration/general/generalConfig.ts @@ -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"; diff --git a/cypress/e2e/models/migration/reports-tab/reports-tab.ts b/cypress/e2e/models/migration/reports-tab/reports-tab.ts new file mode 100644 index 000000000..a425b1d2d --- /dev/null +++ b/cypress/e2e/models/migration/reports-tab/reports-tab.ts @@ -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); + }); + } +} diff --git a/cypress/e2e/models/migration/reports/reports.ts b/cypress/e2e/models/migration/reports/reports.ts deleted file mode 100644 index 5b8b6dd00..000000000 --- a/cypress/e2e/models/migration/reports/reports.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -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 { selectItemsPerPage } from "../../../../utils/utils"; -import { applicationName, button, risk } from "../../../types/constants"; -import { - applicationConfidenceandRiskTitle, - articleButton, - articleCard, - articleExpandedContent, - articleHeader, - articleItem, -} from "../../../views/reports.view"; - -export function selectItemsPerPageInReports(items: number, articleTitle: string): void { - cy.get(articleTitle) - .closest(articleItem) - .within(() => { - selectItemsPerPage(items); - }); -} - -export function expandArticle(name: string): void { - cy.xpath(`//h3[contains(text(), '${name}')]`) - .closest(articleItem) - .within(() => { - cy.get(articleCard).then(($div) => { - if (!$div.find(articleExpandedContent).length) { - cy.get(articleButton).eq(0).click({ force: true }); - } - }); - }); -} - -export function verifyApplicationRisk(riskType: string, appName: string): void { - // Verifies particular application's risk type - selectItemsPerPageInReports(100, applicationConfidenceandRiskTitle); - cy.wait(4000); - cy.get(applicationConfidenceandRiskTitle) - .closest(articleItem) - .find("tbody > tr") - .each(($ele) => { - if ($ele.find(`td[data-label="${applicationName}"]`).text() == appName) { - expect($ele.find(`td[data-label="${risk}"]`).text().toLowerCase()).to.equal( - riskType - ); - } - }); -} -export function closeArticle(articleTitle: string): void { - cy.get(articleTitle) - .closest(articleCard) - .find(articleHeader) - .within(() => { - cy.get(button).click(); - }); -} diff --git a/cypress/e2e/tests/migration/applicationinventory/assessment/assessment_after_import.test.ts b/cypress/e2e/tests/migration/applicationinventory/assessment/assessment_after_import.test.ts index 77acfc4f0..b934bef26 100644 --- a/cypress/e2e/tests/migration/applicationinventory/assessment/assessment_after_import.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/assessment/assessment_after_import.test.ts @@ -24,6 +24,7 @@ import { deleteAppImportsTableRows, notExists, deleteByList, + deleteAllMigrationWaves, } from "../../../../../utils/utils"; import { Stakeholders } from "../../../../models/migration/controls/stakeholders"; @@ -83,6 +84,7 @@ describe(["@tier2"], "Operations after application import", () => { }); after("Perform test data clean up", function () { + deleteAllMigrationWaves(); deleteApplicationTableRows(); deleteAppImportsTableRows(); deleteByList(stakeholders); diff --git a/cypress/e2e/tests/migration/applicationinventory/manageimports/sort.test.ts b/cypress/e2e/tests/migration/applicationinventory/manageimports/sort.test.ts index cab77e32f..4b9627031 100644 --- a/cypress/e2e/tests/migration/applicationinventory/manageimports/sort.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/manageimports/sort.test.ts @@ -26,6 +26,7 @@ import { deleteApplicationTableRows, deleteAppImportsTableRows, clickOnSortButton, + deleteAllMigrationWaves, } from "../../../../../utils/utils"; import { navMenu } from "../../../../views/menu.view"; import { SortType, applicationInventory } from "../../../../types/constants"; @@ -167,6 +168,7 @@ describe(["@tier2"], "Manage applications import sort validations", function () }); after("Perform test data clean up", function () { + deleteAllMigrationWaves(); deleteApplicationTableRows(); deleteAppImportsTableRows(); }); diff --git a/cypress/e2e/tests/migration/reports/applicationRisk.test.ts b/cypress/e2e/tests/migration/reports-tab/reports.test.ts similarity index 67% rename from cypress/e2e/tests/migration/reports/applicationRisk.test.ts rename to cypress/e2e/tests/migration/reports-tab/reports.test.ts index 5cfaf3a8d..09fa02921 100644 --- a/cypress/e2e/tests/migration/reports/applicationRisk.test.ts +++ b/cypress/e2e/tests/migration/reports-tab/reports.test.ts @@ -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 = []; let applicationsList: Array = []; +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"); @@ -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 () { diff --git a/cypress/e2e/tests/migration/reports/filter.test.ts b/cypress/e2e/tests/migration/reports/filter.test.ts deleted file mode 100644 index c012c4fbc..000000000 --- a/cypress/e2e/tests/migration/reports/filter.test.ts +++ /dev/null @@ -1,343 +0,0 @@ -/* -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 { - login, - clickByText, - applySearchFilter, - getTableColumnData, - selectFilter, - createMultipleStakeholders, - createMultipleApplications, - selectUserPerspective, - deleteByList, -} from "../../../../utils/utils"; -import { navMenu } from "../../../views/menu.view"; -import { - reports, - name, - button, - clearAllFilters, - category, - question, - answer, - migration, - SEC, - identiFiedRisks, - suggestedAdoptionPlan, - tdTag, -} from "../../../types/constants"; -import { - applicationConfidenceandRiskTitle, - articleBody, - articleCard, - identiFiedRisksTitle, -} from "../../../views/reports.view"; -import * as data from "../../../../utils/data_utils"; -import { - expandArticle, - closeArticle, - selectItemsPerPageInReports, -} from "../../../models/migration/reports/reports"; -import { Stakeholders } from "../../../models/migration/controls/stakeholders"; -import { Application } from "../../../models/migration/applicationinventory/application"; - -let applicationsList: Array = []; -let stakeholdersList: Array = []; -let invalidSearchInput = String(data.getRandomNumber()); - -describe.skip(["@tier2"], "Bug MTA-1762: Reports filter validations", () => { - before("Login and create test data", function () { - // Perform login - login(); - - stakeholdersList = createMultipleStakeholders(1); - applicationsList = createMultipleApplications(2); - - // Perform assessment of application - applicationsList[0].perform_assessment("high", stakeholdersList); - applicationsList[0].verifyStatus("assessment", "Completed"); - cy.wait(4 * SEC); - // Perform application review - applicationsList[0].perform_review("high"); - applicationsList[0].verifyStatus("review", "Completed"); - }); - - it("Bug MTA-1762: Name field validations", function () { - // Navigate to reports - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(2 * SEC); - - // Enter an existing application name substring and apply it as search filter - let validSearchInput = applicationsList[0].name; - - applySearchFilter(name, validSearchInput); - cy.wait(3 * SEC); - - // Check element filtered for table Adoption Candidate Distribution - selectItemsPerPageInReports(100, applicationConfidenceandRiskTitle); - - // Wait for DOM to render table and sibling elements - cy.get(applicationConfidenceandRiskTitle) - .closest(articleCard) - .find(articleBody) - .should("not.have.class", "pf-v5-c-empty-state") - .find(tdTag) - .should("contain", applicationsList[0].name); - - // Check element filtered for table Identified risks - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - - selectItemsPerPageInReports(100, identiFiedRisksTitle); - - let applicationsData = getTableColumnData("Application(s)"); - cy.wrap(applicationsData).each((application) => { - expect(application).to.have.string(validSearchInput); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - //close Row Details of Identified risks - closeArticle(identiFiedRisksTitle); - // Enter an invalid substring and apply it as search filter - applySearchFilter(name, invalidSearchInput); - - // Expand article cards - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - expandArticle(suggestedAdoptionPlan); - cy.wait(2 * SEC); - - // Assert that no search results are found - // Check for current landscape donut charts - cy.get("div > h2").eq(0).contains("No data available"); - - // Clear all filters - clickByText(button, clearAllFilters); - }); - - it("Bug MTA-1762: Identified risk - Application name field validations", function () { - // Navigate to reports - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(2 * SEC); - - // Workaround for filters - Keeping default filter selected for reports filter - // if it gets changed to tag/business service due to last test case then - // eq(1) for identified filter text input does not apply - selectFilter("Name"); - - // Enter an application name and apply it as search filter - let validSearchInput = applicationsList[0].name.substring(0, 11); - - // Expand table Identified risks - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - - selectItemsPerPageInReports(100, identiFiedRisksTitle); - - applySearchFilter(name, validSearchInput, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered applications rows and verify - let applicationsData = getTableColumnData("Application(s)"); - cy.wrap(applicationsData).each((application) => { - expect(application).to.have.string(applicationsList[0].name); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - applySearchFilter(name, applicationsList[0].name, true); - cy.wait(3 * SEC); - - // Get list of filtered applications rows and verify - applicationsData = getTableColumnData("Application(s)"); - cy.wrap(applicationsData).each((application) => { - expect(application).to.have.string(applicationsList[0].name); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - // Enter an invalid substring and apply it as search filter - applySearchFilter(name, invalidSearchInput, true, 1); - - // Assert that no search results are found - cy.get("h2").contains("No data available"); - - // Clear all filters - clickByText(button, clearAllFilters); - }); - - it("Bug MTA-1762: Identified risk - Category field validations", function () { - // Navigate to reports - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(2 * SEC); - - // Expand table Identified risks - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - - selectItemsPerPageInReports(100, identiFiedRisksTitle); - - // Get a category of assessment questions and apply it as search filter - let categoryString = "Application details"; - let validSearchInput = categoryString.substring(0, 16); - - applySearchFilter(category, validSearchInput, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered category rows and verify - let categoryData = getTableColumnData("Category"); - cy.wrap(categoryData).each((category) => { - expect(categoryString.toLowerCase()).to.equal(category); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - applySearchFilter(category, categoryString, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered category rows and verify - categoryData = getTableColumnData("Category"); - cy.wrap(categoryData).each((category) => { - expect(categoryString.toLowerCase()).to.equal(category); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - // Enter an invalid substring and apply it as search filter - applySearchFilter(category, invalidSearchInput, true, 1); - - // Assert that no search results are found - cy.get("h2").contains("No data available"); - - // Clear all filters - clickByText(button, clearAllFilters); - }); - - it("Bug MTA-1762: Identified risk - Question field validations", function () { - // Navigate to reports - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(2 * SEC); - - // Expand table Identified risks - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - - selectItemsPerPageInReports(100, identiFiedRisksTitle); - - // Get a question from assessment question's list and apply it as search filter - let questionString = "How is the application tested?"; - let validSearchInput = questionString.substring(0, 27); - applySearchFilter(question, validSearchInput, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered questions rows and verify - let questionsData = getTableColumnData("Question"); - cy.wrap(questionsData).each((question) => { - expect(questionString.toLowerCase()).to.equal(question); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - applySearchFilter(question, questionString, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered questions rows and verify - questionsData = getTableColumnData("Question"); - cy.wrap(questionsData).each((question) => { - expect(questionString.toLowerCase()).to.equal(question); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - // Enter an invalid substring and apply it as search filter - applySearchFilter(question, invalidSearchInput, true, 1); - - // Assert that no search results are found - cy.get("h2").contains("No data available"); - - // Clear all filters - clickByText(button, clearAllFilters); - }); - - it("Bug MTA-1762: Identified risk - Answer field validations", function () { - // Navigate to reports - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(2 * SEC); - - // Expand table Identified risks - expandArticle(identiFiedRisks); - cy.wait(2 * SEC); - - selectItemsPerPageInReports(100, identiFiedRisksTitle); - - // select an answer input from existing answers and apply it as search filter - let answerString = "Not tracked"; - let validSearchInput = answerString.substring(0, 7); - applySearchFilter(answer, validSearchInput, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered answers rows and verify - let answersData = getTableColumnData("Answer"); - cy.wrap(answersData).each((answer) => { - expect(answerString.toLowerCase()).to.equal(answer); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - applySearchFilter(answer, answerString, true, 1); - cy.wait(3 * SEC); - - // Get list of filtered answers rows and verify - answersData = getTableColumnData("Answer"); - cy.wrap(answersData).each((answer) => { - expect(answerString.toLowerCase()).to.equal(answer); - }); - - // Clear all filters - clickByText(button, clearAllFilters); - - // Enter an invalid substring and apply it as search filter - applySearchFilter(answer, invalidSearchInput, true, 1); - - // Assert that no search results are found - cy.get("h2").contains("No data available"); - - // Clear all filters - clickByText(button, clearAllFilters); - }); - - after("Perform test data clean up", function () { - // Delete the applications and stakeholders - deleteByList(applicationsList); - deleteByList(stakeholdersList); - }); -}); diff --git a/cypress/e2e/tests/migration/reports/pagination.test.ts b/cypress/e2e/tests/migration/reports/pagination.test.ts deleted file mode 100644 index af3fb3569..000000000 --- a/cypress/e2e/tests/migration/reports/pagination.test.ts +++ /dev/null @@ -1,243 +0,0 @@ -/* -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 { - login, - clickByText, - createMultipleStakeholders, - createMultipleApplications, - selectUserPerspective, - goToPage, - deleteByList, -} from "../../../../utils/utils"; -import { navMenu } from "../../../views/menu.view"; -import { migration, reports, SEC } from "../../../types/constants"; -import { - expandArticle, - selectItemsPerPageInReports, -} from "../../../models/migration/reports/reports"; -import { Stakeholders } from "../../../models/migration/controls/stakeholders"; -import * as commonView from "../../../views/common.view"; -import { - applicationConfidenceandRiskTitle, - identiFiedRisksTitle, -} from "../../../views/reports.view"; -import { Application } from "../../../models/migration/applicationinventory/application"; - -let applicationsList: Array = []; -let stakeholdersList: Array = []; - -describe.skip(["@tier3"], "Bug MTA-1762: Reports pagination validations", () => { - before("Login and create test data", function () { - // Perform login - login(); - stakeholdersList = createMultipleStakeholders(1); - let rowsToCreate = 11; - - // Create 11 applications - applicationsList = createMultipleApplications(rowsToCreate); - - // Get the last extra application created - let newApplication = applicationsList[applicationsList.length - 1]; - // Perform assessment of application - newApplication.perform_assessment("high", stakeholdersList); - newApplication.verifyStatus("assessment", "Completed"); - cy.wait(4 * SEC); - // Perform application review - newApplication.perform_review("high"); - newApplication.verifyStatus("review", "Completed"); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Navigation button validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // select 10 items per page - selectItemsPerPageInReports(10, applicationConfidenceandRiskTitle); - - // Verify next buttons are enabled as there are more than 11 rows present - cy.get(commonView.nextPageButton).each(($nextBtn) => { - cy.wrap($nextBtn).should("not.be.disabled"); - }); - - // Verify that previous buttons are disabled being on the first page - cy.get(commonView.prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("be.disabled"); - }); - - // Verify that navigation button to last page is enabled - cy.get(commonView.lastPageButton).should("not.be.disabled"); - - // Verify that navigation button to first page is disabled being on the first page - cy.get(commonView.firstPageButton).should("be.disabled"); - - // Navigate to next page - cy.get(commonView.nextPageButton).eq(0).click(); - - // Verify that previous buttons are enabled after moving to next page - cy.get(commonView.prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); - - // Verify that navigation button to first page is enabled after moving to next page - cy.get(commonView.firstPageButton).should("not.be.disabled"); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Items per page validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Select 10 items per page - selectItemsPerPageInReports(10, applicationConfidenceandRiskTitle); - cy.wait(2 * SEC); - - // Verify that only 10 items are displayed - cy.get("td[data-label='Application name']").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPageInReports(20, applicationConfidenceandRiskTitle); - cy.wait(2 * SEC); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label='Application name']").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Page number validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Select 10 items per page - selectItemsPerPageInReports(10, applicationConfidenceandRiskTitle); - cy.wait(2 * SEC); - - // Go to page number 2 - goToPage(2); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(commonView.prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); - }); - - it("Bug MTA-1762: Identified risks - Navigation button validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Expand identified risks card - expandArticle("Identified risks"); - cy.wait(3 * SEC); - - // select 10 items per page - selectItemsPerPageInReports(10, identiFiedRisksTitle); - - // Verify next buttons are enabled as there are more than 11 rows present - cy.get(commonView.nextPageButton).eq(2).should("not.be.disabled"); - cy.get(commonView.nextPageButton).eq(3).should("not.be.disabled"); - - // Verify that previous buttons are disabled being on the first page - cy.get(commonView.prevPageButton).eq(2).should("be.disabled"); - cy.get(commonView.prevPageButton).eq(3).should("be.disabled"); - - // Verify that navigation button to last page is enabled - cy.get(commonView.lastPageButton).eq(1).should("not.be.disabled"); - - // Verify that navigation button to first page is disabled being on the first page - cy.get(commonView.firstPageButton).eq(1).should("be.disabled"); - - // Navigate to next page - cy.get(commonView.nextPageButton).eq(3).click(); - - // Verify that previous buttons are enabled after moving to next page - cy.get(commonView.prevPageButton).eq(2).should("not.be.disabled"); - cy.get(commonView.prevPageButton).eq(3).should("not.be.disabled"); - - // Verify that navigation button to first page is enabled after moving to next page - cy.get(commonView.firstPageButton).eq(2).should("not.be.disabled"); - }); - - it("Bug MTA-1762: Identified risks - Items per page validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Expand identified risks card - expandArticle("Identified risks"); - cy.wait(2 * SEC); - - // Select 10 items per page - selectItemsPerPageInReports(10, identiFiedRisksTitle); - cy.wait(2 * SEC); - - // Verify that only 10 items are displayed - cy.get("td[data-label='Category']").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPageInReports(20, identiFiedRisksTitle); - cy.wait(2 * SEC); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label='Category']").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Bug MTA-1762: Identified risks - Page number validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Expand identified risks card - expandArticle("Identified risks"); - cy.wait(2 * SEC); - - // Select 10 items per page - selectItemsPerPageInReports(10, identiFiedRisksTitle); - cy.wait(2 * SEC); - - // Go to page number 2 - cy.get(commonView.pageNumInput).eq(1).clear().type("2").type("{enter}"); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(commonView.prevPageButton) - .eq(1) - .each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); - }); - - after("Perform test data clean up", function () { - // Delete the stakeholders and applications created before the tests - deleteByList(stakeholdersList); - deleteByList(applicationsList); - }); -}); diff --git a/cypress/e2e/tests/migration/reports/sort.test.ts b/cypress/e2e/tests/migration/reports/sort.test.ts deleted file mode 100644 index 6048a4611..000000000 --- a/cypress/e2e/tests/migration/reports/sort.test.ts +++ /dev/null @@ -1,212 +0,0 @@ -/* -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 { - login, - clickByText, - verifySortAsc, - verifySortDesc, - getTableColumnData, - createMultipleApplications, - createMultipleStakeholders, - selectUserPerspective, - clickOnSortButton, - deleteByList, -} from "../../../../utils/utils"; -import { navMenu } from "../../../views/menu.view"; -import { - reports, - applicationName, - criticality, - effort, - priority, - confidence, - migration, - SortType, - SEC, -} from "../../../types/constants"; -import { Stakeholders } from "../../../models/migration/controls/stakeholders"; -import { Application } from "../../../models/migration/applicationinventory/application"; -let applicationsList: Array = []; -let stakeholdersList: Array = []; - -describe.skip(["@tier2"], "Bug MTA-1762: Reports sort validations", () => { - before("Login and create test data", function () { - // Perform login - login(); - - stakeholdersList = createMultipleStakeholders(1); - applicationsList = createMultipleApplications(2); - - let risks = ["low", "medium", "high"]; - for (let i = 0; i < applicationsList.length; i++) { - // Perform assessment of application - applicationsList[i].perform_assessment(risks[i], stakeholdersList); - applicationsList[i].verifyStatus("assessment", "Completed"); - cy.wait(4 * SEC); - // Perform application review - applicationsList[i].perform_review(risks[i]); - applicationsList[i].verifyStatus("review", "Completed"); - } - }); - - it("Bug MTA-1762: Adoption candidate distribution - Application name sort validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // get unsorted list when page loads - const unsortedList = getTableColumnData(applicationName); - - // Sort the Adoption candidate distribution by application name in ascending order - clickOnSortButton(applicationName, SortType.ascending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in ascending order - const afterAscSortList = getTableColumnData(applicationName); - verifySortAsc(afterAscSortList, unsortedList); - - // Sort the Adoption candidate distribution by application name in descending order - clickOnSortButton(applicationName, SortType.descending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in descending order - const afterDescSortList = getTableColumnData(applicationName); - verifySortDesc(afterDescSortList, unsortedList); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Criticality sort validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // get unsorted list when page loads - const unsortedList = getTableColumnData(criticality); - - // Sort the Adoption candidate distribution by criticality in ascending order - clickOnSortButton(criticality, SortType.ascending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in ascending order - const afterAscSortList = getTableColumnData(criticality); - verifySortAsc(afterAscSortList, unsortedList); - - // Sort the Adoption candidate distribution by criticality in descending order - clickOnSortButton(criticality, SortType.descending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in descending order - const afterDescSortList = getTableColumnData(criticality); - verifySortDesc(afterDescSortList, unsortedList); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Priority sort validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // get unsorted list when page loads - const unsortedList = getTableColumnData(priority); - - // Sort the Adoption candidate distribution by priority in ascending order - clickOnSortButton(priority, SortType.ascending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in ascending order - const afterAscSortList = getTableColumnData(priority); - verifySortAsc(afterAscSortList, unsortedList); - - // Sort the Adoption candidate distribution by priority in descending order - clickOnSortButton(priority, SortType.descending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in descending order - const afterDescSortList = getTableColumnData(priority); - verifySortDesc(afterDescSortList, unsortedList); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Confidence sort validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // get unsorted list when page loads - const unsortedList = getTableColumnData(confidence); - - // Sort the Adoption candidate distribution by confidence in ascending order - clickOnSortButton(confidence, SortType.ascending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in ascending order - const afterAscSortList = getTableColumnData(confidence); - verifySortAsc(afterAscSortList, unsortedList); - - // Sort the Adoption candidate distribution by confidence in descending order - clickOnSortButton(confidence, SortType.descending); - cy.wait(2 * SEC); - - // Verify that the Adoption candidate distribution table rows are displayed in descending order - const afterDescSortList = getTableColumnData(confidence); - verifySortDesc(afterDescSortList, unsortedList); - }); - - it("Bug MTA-1762: Adoption candidate distribution - Effort sort validations", function () { - // Navigate to reports page - selectUserPerspective(migration); - clickByText(navMenu, reports); - cy.wait(3 * SEC); - - // Sort the Adoption candidate distribution by effort in ascending order - clickOnSortButton(effort, SortType.ascending); - cy.wait(2 * SEC); - - const afterAscSortList = getTableColumnData(effort); - - // List of efforts - const itemsList = ["small", "medium", "large", "extra large"]; - - // Verify that the Adoption candidate distribution table rows are displayed in ascending order - let prevAscIndex = 0; - cy.wrap(afterAscSortList).each((value) => { - let currentIndex = itemsList.indexOf(value.toString()); - expect(currentIndex >= prevAscIndex).to.be.true; - }); - - // Sort the Adoption candidate distribution by effort in descending order - clickOnSortButton(effort, SortType.descending); - cy.wait(2 * SEC); - - const afterDescSortList = getTableColumnData(effort); - - // Verify that the Adoption candidate distribution table rows are displayed in descending order - let prevDescIndex = itemsList.length - 1; - cy.wrap(afterDescSortList).each((value) => { - let currentIndex = itemsList.indexOf(value.toString()); - expect(currentIndex <= prevDescIndex).to.be.true; - }); - }); - - after("Perform test data clean up", function () { - // Delete All - deleteByList(stakeholdersList); - deleteByList(applicationsList); - }); -}); diff --git a/cypress/e2e/views/reports.view.ts b/cypress/e2e/views/reportsTab.view.ts similarity index 86% rename from cypress/e2e/views/reports.view.ts rename to cypress/e2e/views/reportsTab.view.ts index 9d924dadf..b84474ca2 100644 --- a/cypress/e2e/views/reports.view.ts +++ b/cypress/e2e/views/reportsTab.view.ts @@ -27,3 +27,8 @@ export const itemsPerPageToggleButton = "div > button[aria-label='Items per page export const closeRowIdentifiedRisk = ":nth-child(4) > .pf-c-card > .pf-c-card__header > .pf-c-card__header-toggle > .pf-c-button > .pf-c-card__header-toggle-icon > svg"; export const switchToggle = ".pf-v5-c-switch__toggle"; + +export const highRiskDonut = "#landscape-donut-red"; +export const mediumRiskDonut = "#landscape-donut-yellow"; +export const lowRiskDonut = "#landscape-donut-green"; +export const unknownRiskDonut = "#landscape-donut-unassessed"; diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 4964af5c9..56d32dd34 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -90,7 +90,7 @@ import { import { CredentialsMaven } from "../e2e/models/administration/credentials/credentialsMaven"; import { CredentialsSourceControlUsername } from "../e2e/models/administration/credentials/credentialsSourceControlUsername"; import { CredentialsSourceControlKey } from "../e2e/models/administration/credentials/credentialsSourceControlKey"; -import { switchToggle } from "../e2e/views/reports.view"; +import { switchToggle } from "../e2e/views/reportsTab.view"; import Chainable = Cypress.Chainable; import { MigrationWave } from "../e2e/models/migration/migration-waves/migration-wave"; import { Jira } from "../e2e/models/administration/jira-connection/jira"; @@ -105,6 +105,10 @@ import { tagFilterName, } from "../e2e/views/issue.view"; import { Archetype } from "../e2e/models/migration/archetypes/archetype"; +import { + MigrationWaveView, + getSpecialMigrationWavesTableSelector, +} from "../e2e/views/migration-wave.view"; const { _ } = Cypress; @@ -1302,6 +1306,28 @@ export function deleteApplicationTableRows(): void { deleteAllRows(); } +export function deleteAllMigrationWaves() { + MigrationWave.open(); + selectItemsPerPage(100); + // This method if for pages that have delete button inside Kebab menu + // like Applications and Imports page + isTableEmpty().then((empty) => { + if (!empty) { + cy.get("tbody tr").then(($rows) => { + for (let i = 0; i < $rows.length; i++) { + cy.get(MigrationWaveView.actionsButton, { timeout: 10000 }).first().click(); + cy.contains("Delete").click(); + cy.get(commonView.confirmButton).click(); + cy.wait(5000); + isTableEmpty().then((empty) => { + if (empty) return; + }); + } + }); + } + }); +} + export function deleteAppImportsTableRows() { openManageImportsPage(); selectItemsPerPage(100);