diff --git a/cypress/e2e/models/migration/applicationinventory/archetype.ts b/cypress/e2e/models/migration/applicationinventory/archetype.ts deleted file mode 100644 index 518460be1..000000000 --- a/cypress/e2e/models/migration/applicationinventory/archetype.ts +++ /dev/null @@ -1,196 +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 { - clickByText, - cancelForm, - inputText, - selectFormItems, - selectItemsPerPage, - selectUserPerspective, - submitForm, - click, - clickKebabMenuOptionArchetype, -} from "../../../../utils/utils"; -import { migration, SEC, trTag } from "../../../types/constants"; -import { navMenu } from "../../../views/menu.view"; -import { Stakeholdergroups } from "../controls/stakeholdergroups"; -import { Stakeholders } from "../controls/stakeholders"; -import { sideKebabMenu } from "../../../views/applicationinventory.view"; -import * as archetype from "../../../views/archetype.view"; -import * as commonView from "../../../views/common.view"; - -export interface Archetype { - name: string; - criteriaTags: string[]; - archetypeTags: string[]; - description?: string; - stakeholders?: Stakeholders[]; - stakeholderGroups?: Stakeholdergroups[]; - comments?: string; -} - -export class Archetype { - constructor( - name: string, - criteriaTags: string[], - archetypeTags: string[], - description?: string, - stakeholders?: Stakeholders[], - stakeholderGroups?: Stakeholdergroups[], - comments?: string - ) { - this.name = name; - this.criteriaTags = criteriaTags; - this.archetypeTags = archetypeTags; - this.description = description; - this.stakeholders = stakeholders; - this.stakeholderGroups = stakeholderGroups; - this.comments = comments; - } - - static fullUrl = Cypress.env("tackleUrl") + "/archetypes"; - - public static open(forceReload = false) { - if (forceReload) { - cy.visit(Archetype.fullUrl); - } - cy.url().then(($url) => { - if ($url != Archetype.fullUrl) { - selectUserPerspective(migration); - clickByText(navMenu, "Archetypes"); - selectItemsPerPage(100); - } - }); - } - - protected fillName(name: string): void { - inputText(archetype.name, name); - } - - protected selectCriteriaTags(tags: string[]): void { - tags.forEach(function (tag) { - selectFormItems(archetype.criteriaTags, tag); - }); - } - - protected selectArchetypeTags(tags: string[]): void { - tags.forEach(function (tag) { - selectFormItems(archetype.archetypeTags, tag); - }); - } - - protected fillDescription(description: string): void { - inputText(archetype.description, description); - } - - protected selectStakeholders(stakeholders: Stakeholders[]) { - stakeholders.forEach((stakeholder) => { - inputText(archetype.stakeholders, stakeholder.name); - cy.get("button").contains(stakeholder.name).click(); - }); - } - - protected selectStakeholderGroups(stakeholderGroups: Stakeholdergroups[]) { - stakeholderGroups.forEach((stakeholderGroup) => { - inputText(archetype.stakeholderGroups, stakeholderGroup.name); - cy.get("button").contains(stakeholderGroup.name).click(); - }); - } - - protected fillComment(comments: string): void { - inputText(archetype.comments, comments); - } - - create(cancel = false): void { - Archetype.open(); - cy.contains("button", "Create new archetype").should("be.enabled").click(); - if (cancel) { - cancelForm(); - } else { - this.fillName(this.name); - this.selectCriteriaTags(this.criteriaTags); - this.selectArchetypeTags(this.archetypeTags); - if (this.description) this.fillDescription(this.description); - if (this.stakeholders) this.selectStakeholders(this.stakeholders); - if (this.stakeholderGroups) this.selectStakeholderGroups(this.stakeholderGroups); - } - if (this.comments) this.fillComment(this.comments); - submitForm(); - } - - delete(cancel = false): void { - Archetype.open(); - clickKebabMenuOptionArchetype(this.name, "Delete"); - if (cancel) { - cancelForm(); - } else click(commonView.confirmButton); - } - - edit( - updatedValues: { - name?: string; - criteriaTags?: string[]; - archetypeTags?: string[]; - description?: string; - stakeholders?: Stakeholders[]; - stakeholderGroups?: Stakeholdergroups[]; - comments?: string; - }, - cancel = false - ): void { - Archetype.open(); - clickKebabMenuOptionArchetype(this.name, "Edit"); - - if (cancel) { - cancelForm(); - } else { - if (updatedValues.name && updatedValues.name != this.name) { - this.fillName(updatedValues.name); - this.name = updatedValues.name; - } - if (updatedValues.description && updatedValues.description != this.description) { - this.fillDescription(updatedValues.description); - this.description = updatedValues.description; - } - if (updatedValues.criteriaTags && updatedValues.criteriaTags != this.criteriaTags) { - this.selectCriteriaTags(updatedValues.criteriaTags); - this.criteriaTags = updatedValues.criteriaTags; - } - if (updatedValues.archetypeTags && updatedValues.archetypeTags != this.archetypeTags) { - this.selectArchetypeTags(updatedValues.archetypeTags); - this.archetypeTags = updatedValues.archetypeTags; - } - if (updatedValues.stakeholders && updatedValues.stakeholders != this.stakeholders) { - this.selectStakeholders(updatedValues.stakeholders); - this.stakeholders = updatedValues.stakeholders; - } - if ( - updatedValues.stakeholderGroups && - updatedValues.stakeholderGroups != this.stakeholderGroups - ) { - this.selectStakeholderGroups(updatedValues.stakeholderGroups); - this.stakeholderGroups = updatedValues.stakeholderGroups; - } - if (updatedValues.comments && updatedValues.comments != this.comments) { - this.fillComment(updatedValues.comments); - this.comments = updatedValues.comments; - } - if (updatedValues) { - submitForm(); - } - } - } -} diff --git a/cypress/e2e/models/migration/archetypes/archetype.ts b/cypress/e2e/models/migration/archetypes/archetype.ts index 09a40cf00..e8e9ffa5e 100644 --- a/cypress/e2e/models/migration/archetypes/archetype.ts +++ b/cypress/e2e/models/migration/archetypes/archetype.ts @@ -22,6 +22,7 @@ import { selectUserPerspective, submitForm, click, + clickKebabMenuOptionArchetype, } from "../../../../utils/utils"; import { migration, trTag } from "../../../types/constants"; import { navMenu } from "../../../views/menu.view"; @@ -132,14 +133,65 @@ export class Archetype { delete(cancel = false): void { Archetype.open(); - cy.contains(this.name) - .closest(trTag) - .within(() => { - click(sideKebabMenu); - }); + clickKebabMenuOptionArchetype(this.name, "Delete"); cy.get(actionMenuItem).contains("Delete").click(); if (cancel) { cancelForm(); } else click(confirmButton); } + + edit( + updatedValues: { + name?: string; + criteriaTags?: string[]; + archetypeTags?: string[]; + description?: string; + stakeholders?: Stakeholders[]; + stakeholderGroups?: Stakeholdergroups[]; + comments?: string; + }, + cancel = false + ): void { + Archetype.open(); + clickKebabMenuOptionArchetype(this.name, "Edit"); + + if (cancel) { + cancelForm(); + } else { + if (updatedValues.name && updatedValues.name != this.name) { + this.fillName(updatedValues.name); + this.name = updatedValues.name; + } + if (updatedValues.description && updatedValues.description != this.description) { + this.fillDescription(updatedValues.description); + this.description = updatedValues.description; + } + if (updatedValues.criteriaTags && updatedValues.criteriaTags != this.criteriaTags) { + this.selectCriteriaTags(updatedValues.criteriaTags); + this.criteriaTags = updatedValues.criteriaTags; + } + if (updatedValues.archetypeTags && updatedValues.archetypeTags != this.archetypeTags) { + this.selectArchetypeTags(updatedValues.archetypeTags); + this.archetypeTags = updatedValues.archetypeTags; + } + if (updatedValues.stakeholders && updatedValues.stakeholders != this.stakeholders) { + this.selectStakeholders(updatedValues.stakeholders); + this.stakeholders = updatedValues.stakeholders; + } + if ( + updatedValues.stakeholderGroups && + updatedValues.stakeholderGroups != this.stakeholderGroups + ) { + this.selectStakeholderGroups(updatedValues.stakeholderGroups); + this.stakeholderGroups = updatedValues.stakeholderGroups; + } + if (updatedValues.comments && updatedValues.comments != this.comments) { + this.fillComment(updatedValues.comments); + this.comments = updatedValues.comments; + } + if (updatedValues) { + submitForm(); + } + } + } } diff --git a/cypress/e2e/tests/migration/applicationinventory/applications/pagination.test.ts b/cypress/e2e/tests/migration/applicationinventory/applications/pagination.test.ts index d2e4923e7..16fe5d1ac 100644 --- a/cypress/e2e/tests/migration/applicationinventory/applications/pagination.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/applications/pagination.test.ts @@ -20,10 +20,9 @@ import { selectItemsPerPage, deleteByList, createMultipleApplications, - goToPage, validatePagination, + itemsPerPageValidation, } from "../../../../../utils/utils"; -import * as commonView from "../../../../views/common.view"; import { Application } from "../../../../models/migration/applicationinventory/application"; let applicationsList: Array = []; @@ -48,52 +47,9 @@ describe(["@tier3"], "Application inventory pagination validations", function () }); it("Items per page validations", function () { - // Navigate to Application inventory tab - Application.open(); - cy.wait("@getApplications"); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // Verify that only 10 items are displayed - cy.get(commonView.appTable) - .find("td[data-label=Name]") - .then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPage(20); - cy.wait(2000); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get(commonView.appTable) - .find("td[data-label=Name]") - .then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - // Navigate to Application inventory tab Application.open(); cy.wait("@getApplications"); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // 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"); - }); - - // Go back to page number 1 - goToPage(1); + itemsPerPageValidation(); }); after("Perform test data clean up", function () { diff --git a/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts b/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts index afa85a820..919f77ea9 100644 --- a/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts @@ -18,24 +18,24 @@ limitations under the License. import { login, selectItemsPerPage, - click, importApplication, openManageImportsPage, deleteApplicationTableRows, - goToPage, goToLastPage, deleteAppImportsTableRows, validatePagination, + itemsPerPageValidation, + deleteAllImports, } from "../../../../../utils/utils"; -import { sideKebabMenu } from "../../../../views/applicationinventory.view"; import * as commonView from "../../../../views/common.view"; import { Application } from "../../../../models/migration/applicationinventory/application"; +import { trTag } from "../../../../types/constants"; const filePath = "app_import/csv/"; const filesToImport = "valid_application_rows.csv"; -describe(["@tier3"], "1 Bug: Manage imports pagination validations", function () { +describe(["@tier3"], "Manage imports pagination validations", function () { before("Login and Create Test Data", function () { // Import multiple csv files function importMultipleFiles(num): void { @@ -69,43 +69,10 @@ describe(["@tier3"], "1 Bug: Manage imports pagination validations", function () it("Items per page validations", function () { openManageImportsPage(); selectItemsPerPage(10); - cy.wait(2000); - - // Verify that only 10 items are displayed - cy.get(commonView.appTable) - .find("td[data-label='File name']") - .then(($rowCount) => { - cy.wrap($rowCount.length).should("eq", 10); - }); - - selectItemsPerPage(20); - cy.wait(2000); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get(commonView.appTable) - .find("td[data-label='File name']") - .then(($rowCount) => { - cy.wrap($rowCount.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - openManageImportsPage(); - selectItemsPerPage(10); - cy.wait(2000); - - 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"); - }); - - // Back to page 1 - goToPage(1); + itemsPerPageValidation(commonView.appTable, "Filename"); }); - it("Bug MTA-1693: Last page item(s) deletion, impact on page reload validation", function () { + it("Last page item(s) deletion, impact on page reload validation", function () { openManageImportsPage(); selectItemsPerPage(10); cy.wait("@getImports"); @@ -115,20 +82,11 @@ describe(["@tier3"], "1 Bug: Manage imports pagination validations", function () cy.wait("@getImports"); // Delete all items of last page - cy.get(commonView.appTable) - .get("tbody") - .find("td[data-label='File name']") - .each(($tableRow) => { - click(sideKebabMenu); - cy.get("ul[role=menu] > li").contains("Delete").click(); - click(commonView.confirmButton); - cy.wait("@deleteImport"); - cy.wait(4000); - }); + deleteAllImports(); // Verify that page is re-directed to previous page cy.get(commonView.appTable) - .find("td[data-label='File name']") + .find("td[data-label='Filename']") .then(($rows) => { cy.wrap($rows.length).should("eq", 10); }); diff --git a/cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts b/cypress/e2e/tests/migration/archetypes/crud.test.ts similarity index 82% rename from cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts rename to cypress/e2e/tests/migration/archetypes/crud.test.ts index 01fc7fa1d..2ab7b871d 100644 --- a/cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts +++ b/cypress/e2e/tests/migration/archetypes/crud.test.ts @@ -16,21 +16,20 @@ limitations under the License. /// import { - login, - exists, - createMultipleStakeholders, - createMultipleStakeholderGroups, checkSuccessAlert, + createMultipleStakeholderGroups, + createMultipleStakeholders, createMultipleTags, + exists, + login, notExists, -} from "../../../../../utils/utils"; - -import { successAlertMessage } from "../../../../views/common.view"; -import * as data from "../../../../../utils/data_utils"; -import { Archetype } from "../../../../models/migration/applicationinventory/archetype"; -import { Stakeholders } from "../../../../models/migration/controls/stakeholders"; -import { Stakeholdergroups } from "../../../../models/migration/controls/stakeholdergroups"; -import { Tag } from "../../../../models/migration/controls/tags"; +} from "../../../../utils/utils"; +import { Archetype } from "../../../models/migration/archetypes/archetype"; +import { Stakeholdergroups } from "../../../models/migration/controls/stakeholdergroups"; +import { Stakeholders } from "../../../models/migration/controls/stakeholders"; +import { Tag } from "../../../models/migration/controls/tags"; +import { successAlertMessage } from "../../../views/common.view"; +import * as data from "../../../../utils/data_utils"; let stakeholders: Stakeholders[]; let stakeholderGroups: Stakeholdergroups[]; diff --git a/cypress/e2e/tests/migration/archetypes/pagination.test.ts b/cypress/e2e/tests/migration/archetypes/pagination.test.ts index ea75919da..39c4e78dc 100644 --- a/cypress/e2e/tests/migration/archetypes/pagination.test.ts +++ b/cypress/e2e/tests/migration/archetypes/pagination.test.ts @@ -19,6 +19,7 @@ import { createMultipleArchetypes, deleteAllArchetypes, deleteAllRows, + deleteByList, goToLastPage, itemsPerPageValidation, login, @@ -26,11 +27,12 @@ import { validatePagination, } from "../../../../utils/utils"; import { Archetype } from "../../../models/migration/archetypes/archetype"; +let archetypeList: Archetype[] = []; describe(["@tier3"], "Archetypes pagination validations", function () { before("Login and Create Test Data", function () { login(); - createMultipleArchetypes(11); + archetypeList = createMultipleArchetypes(11); }); it("Navigation button validations", function () { @@ -56,6 +58,6 @@ describe(["@tier3"], "Archetypes pagination validations", function () { }); after("Perform test data clean up", function () { - deleteAllArchetypes(); + deleteByList(archetypeList); }); }); diff --git a/cypress/e2e/tests/migration/controls/businessservices/pagination.test.ts b/cypress/e2e/tests/migration/controls/businessservices/pagination.test.ts index 0f6e14c25..1f26ed1a0 100644 --- a/cypress/e2e/tests/migration/controls/businessservices/pagination.test.ts +++ b/cypress/e2e/tests/migration/controls/businessservices/pagination.test.ts @@ -19,15 +19,12 @@ import { login, selectItemsPerPage, createMultipleBusinessServices, - goToLastPage, validatePagination, - goToPage, deleteApplicationTableRows, deleteAllBusinessServices, - deleteAllItems, + itemsPerPageValidation, + autoPageChangeValidations, } from "../../../../../utils/utils"; -import { SEC } from "../../../../types/constants"; -import { prevPageButton } from "../../../../views/common.view"; import { BusinessServices } from "../../../../models/migration/controls/businessservices"; describe(["@tier3"], "Business services pagination validations", function () { @@ -37,55 +34,21 @@ describe(["@tier3"], "Business services pagination validations", function () { }); it("Navigation button validations", function () { - // Navigate to business services tab BusinessServices.openList(); selectItemsPerPage(10); validatePagination(); }); it("Items per page validations", function () { - // Navigate to business services tab BusinessServices.openList(); selectItemsPerPage(10); - // Verify that only 10 items are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - // Select 20 items per page - selectItemsPerPage(20); - cy.wait(2 * SEC); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - // Navigate to business services tab and select 10 items per page - BusinessServices.openList(); - selectItemsPerPage(10); - 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(prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); + itemsPerPageValidation(); }); it("Last page item(s) deletion, impact on page reload validation", function () { BusinessServices.openList(); selectItemsPerPage(10); - cy.wait(2 * SEC); - goToLastPage(); - // Delete all items of last page - deleteAllItems(); - // Verify that page is re-directed to previous page - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); + autoPageChangeValidations(); }); after("Perform test data clean up", function () { diff --git a/cypress/e2e/tests/migration/controls/jobfunctions/pagination.test.ts b/cypress/e2e/tests/migration/controls/jobfunctions/pagination.test.ts index 277acceb3..cf078ca53 100644 --- a/cypress/e2e/tests/migration/controls/jobfunctions/pagination.test.ts +++ b/cypress/e2e/tests/migration/controls/jobfunctions/pagination.test.ts @@ -21,8 +21,8 @@ import { createMultipleJobFunctions, deleteByList, validatePagination, + itemsPerPageValidation, } from "../../../../../utils/utils"; -import { pageNumInput, prevPageButton } from "../../../../views/common.view"; import { Jobfunctions } from "../../../../models/migration/controls/jobfunctions"; let jobFunctionsList: Array = []; @@ -44,43 +44,9 @@ describe(["@tier3"], "Job functions pagination validations", function () { }); it("Items per page validations", function () { - // Navigate to Job functions tab Jobfunctions.openList(); - - // Select 10 items per page selectItemsPerPage(10); - cy.wait(2000); - - // Verify that only 10 items are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPage(20); - cy.wait(2000); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - // Navigate to Job functions tab - Jobfunctions.openList(); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // Go to page number 2 - cy.get(pageNumInput).eq(0).clear().type("2").type("{enter}"); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); + itemsPerPageValidation(); }); after("Perform test data clean up", function () { diff --git a/cypress/e2e/tests/migration/controls/stakeholdergroups/filter.test.ts b/cypress/e2e/tests/migration/controls/stakeholdergroups/filter.test.ts index 6c711bdce..4eaf3f898 100644 --- a/cypress/e2e/tests/migration/controls/stakeholdergroups/filter.test.ts +++ b/cypress/e2e/tests/migration/controls/stakeholdergroups/filter.test.ts @@ -45,7 +45,7 @@ let stakeholdersList: Array = []; let stakeholderGroupsList: Array = []; const invalidSearchInput = `${data.getRandomNumber()}`; -describe(["@tier2"], "3 Bugs: Stakeholder groups filter validations", function () { +describe(["@tier2"], "Stakeholder groups filter validations", function () { before("Login and Create Test Data", function () { login(); @@ -57,7 +57,7 @@ describe(["@tier2"], "3 Bugs: Stakeholder groups filter validations", function ( cy.intercept("GET", "/hub/stakeholdergroups*").as("getStakeholderGroups"); }); - it("Bug MTA-1715: Name filter validations", function () { + it("Name filter validations", function () { Stakeholdergroups.openList(); cy.get("@getStakeholderGroups"); @@ -74,13 +74,13 @@ describe(["@tier2"], "3 Bugs: Stakeholder groups filter validations", function ( applySearchFilter(name, invalidSearchInput); - cy.get("h2").contains("No stakeholder groups available"); + cy.get("h2").contains("No stakeholder group available"); clickByText(button, clearAllFilters); cy.get("@getStakeholderGroups"); }); - it("Bug MTA-1715: Description filter validations", function () { + it("Description filter validations", function () { Stakeholdergroups.openList(); cy.get("@getStakeholderGroups"); @@ -98,13 +98,13 @@ describe(["@tier2"], "3 Bugs: Stakeholder groups filter validations", function ( applySearchFilter(description, invalidSearchInput); - cy.get("h2").contains("No stakeholder groups available"); + cy.get("h2").contains("No stakeholder group available"); clickByText(button, clearAllFilters); cy.get("@getStakeholderGroups"); }); - it("Bug MTA-1715: Member filter validations", function () { + it("Member filter validations", function () { Stakeholdergroups.openList(); cy.get("@getStakeholderGroups"); @@ -130,7 +130,7 @@ describe(["@tier2"], "3 Bugs: Stakeholder groups filter validations", function ( applySearchFilter(stakeholders, invalidSearchInput); - cy.get("h2").contains("No stakeholder groups available"); + cy.get("h2").contains("No stakeholder group available"); clickByText(button, clearAllFilters); cy.get("@getStakeholderGroups"); diff --git a/cypress/e2e/tests/migration/controls/stakeholdergroups/pagination.test.ts b/cypress/e2e/tests/migration/controls/stakeholdergroups/pagination.test.ts index f7bf99fa6..5e12bf1f2 100644 --- a/cypress/e2e/tests/migration/controls/stakeholdergroups/pagination.test.ts +++ b/cypress/e2e/tests/migration/controls/stakeholdergroups/pagination.test.ts @@ -21,12 +21,12 @@ import { createMultipleStakeholderGroups, validatePagination, deleteAllStakeholderGroups, - deleteAllItems, + itemsPerPageValidation, + autoPageChangeValidations, } from "../../../../../utils/utils"; import { Stakeholdergroups } from "../../../../models/migration/controls/stakeholdergroups"; -import { lastPageButton, pageNumInput, prevPageButton } from "../../../../views/common.view"; -describe(["@tier3"], "2 Bugs: Stakeholder groups pagination validations", function () { +describe(["@tier3"], "Stakeholder groups pagination validations", function () { before("Login and Create Test Data", function () { login(); createMultipleStakeholderGroups(11); @@ -38,76 +38,25 @@ describe(["@tier3"], "2 Bugs: Stakeholder groups pagination validations", functi }); it("Navigation button validations", function () { - // Navigate to stakeholder groups tab Stakeholdergroups.openList(); cy.get("@getStakeholdergroups"); selectItemsPerPage(10); validatePagination(); }); - it("Bug MTA-1694: Items per page validations", function () { - // Navigate to stakeholder groups tab - Stakeholdergroups.openList(); - cy.get("@getStakeholdergroups"); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // Verify that only 10 items are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPage(20); - cy.wait(2000); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - // Navigate to stakeholder groups tab + it("Items per page validations", function () { Stakeholdergroups.openList(); cy.get("@getStakeholdergroups"); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // Go to page number 2 - cy.get(pageNumInput).eq(0).clear().type("2").type("{enter}"); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); + itemsPerPageValidation(); }); - it("Bug MTA-1694: Last page item(s) deletion, impact on page reload validation", function () { + it("Last page item(s) deletion, impact on page reload validation", function () { // Issue - https://issues.redhat.com/browse/TACKLE-155 // Navigate to stakeholder groups tab Stakeholdergroups.openList(); cy.get("@getStakeholdergroups"); - - // Select 10 items per page selectItemsPerPage(10); - cy.wait(2000); - - // Navigate to last page - cy.get(lastPageButton).eq(0).click(); - cy.wait(2000); - - // Delete all items of last page - deleteAllItems(); - - // Verify that page is re-directed to previous page - cy.get("td[data-label=Name]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); + autoPageChangeValidations(); }); after("Perform test data clean up", function () { diff --git a/cypress/e2e/tests/migration/controls/stakeholders/pagination.test.ts b/cypress/e2e/tests/migration/controls/stakeholders/pagination.test.ts index 97e34645b..9a4ce8830 100644 --- a/cypress/e2e/tests/migration/controls/stakeholders/pagination.test.ts +++ b/cypress/e2e/tests/migration/controls/stakeholders/pagination.test.ts @@ -21,10 +21,11 @@ import { createMultipleStakeholders, validatePagination, deleteAllItems, + itemsPerPageValidation, + autoPageChangeValidations, } from "../../../../../utils/utils"; -import { lastPageButton, pageNumInput, prevPageButton } from "../../../../views/common.view"; +import { appTable } from "../../../../views/common.view"; import { Stakeholders } from "../../../../models/migration/controls/stakeholders"; -import { stakeHoldersTable } from "../../../../views/stakeholders.view"; describe(["@tier3"], "Stakeholder pagination validations", function () { before("Login and Create Test Data", function () { @@ -38,7 +39,6 @@ describe(["@tier3"], "Stakeholder pagination validations", function () { }); it("Navigation button validations", function () { - // Navigate to stakeholder tab Stakeholders.openList(); cy.get("@getStakeholders"); selectItemsPerPage(10); @@ -46,70 +46,20 @@ describe(["@tier3"], "Stakeholder pagination validations", function () { }); it("Items per page validations", function () { - // Navigate to stakeholder tab Stakeholders.openList(); cy.get("@getStakeholders"); - - // Select 10 items per page - selectItemsPerPage(10); - cy.wait(2000); - - // Verify that only 10 items are displayed - cy.get("td[data-label=Email]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPage(20); - cy.wait(2000); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get("td[data-label=Email]").then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - // Navigate to stakeholder tab - Stakeholders.openList(); - cy.get("@getStakeholders"); - - // Select 10 items per page selectItemsPerPage(10); - cy.wait(2000); - - // Go to page number 2 - cy.get(pageNumInput).eq(0).clear().type("2").type("{enter}"); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); + itemsPerPageValidation(appTable, "Email"); }); it("Last page item(s) deletion, impact on page reload validation", function () { - // Navigate to stakeholder tab Stakeholders.openList(); cy.get("@getStakeholders"); - - // Select 10 items per page selectItemsPerPage(10); - cy.wait(2000); - - // Navigate to last page - cy.get(lastPageButton).eq(0).click(); - cy.wait(2000); - - // Delete all items of last page - deleteAllItems(stakeHoldersTable); - - // Verify that page is re-directed to previous page - cy.get("td[data-label=Email]").then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); + autoPageChangeValidations(appTable, "Email"); }); after("Perform test data clean up", function () { - deleteAllItems(stakeHoldersTable); + deleteAllItems(); }); }); diff --git a/cypress/e2e/tests/migration/controls/tags/tagcategory/pagination.test.ts b/cypress/e2e/tests/migration/controls/tags/tagcategory/pagination.test.ts index f89b33216..e0baaa871 100644 --- a/cypress/e2e/tests/migration/controls/tags/tagcategory/pagination.test.ts +++ b/cypress/e2e/tests/migration/controls/tags/tagcategory/pagination.test.ts @@ -20,12 +20,12 @@ import { selectItemsPerPage, createMultipleTags, deleteAllTagsAndTagCategories, - goToPage, validatePagination, + itemsPerPageValidation, } from "../../../../../../utils/utils"; import { SEC } from "../../../../../types/constants"; -import { prevPageButton, appTable } from "../../../../../views/common.view"; +import { appTable } from "../../../../../views/common.view"; import { TagCategory } from "../../../../../models/migration/controls/tagcategory"; import { tagCategory } from "../../../../../views/tags.view"; @@ -58,55 +58,19 @@ describe(["@tier3"], "Tag category pagination validations", function () { }); }); - after("Perform test data clean up", function () { - // Delete the tags created before the tests - deleteAllTagsAndTagCategories(); - }); - it("Navigation button validations", function () { - // Navigate to Tags tab TagCategory.openList(); selectItemsPerPage(10); validatePagination(); }); it("Items per page validations", function () { - // Navigate to Tags tab TagCategory.openList(); - - // Select 10 items per page selectItemsPerPage(10); - - // Verify that only 10 items are displayed - cy.get(tagCategory, { timeout: 2 * SEC }).then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - // Select 20 items per page - selectItemsPerPage(20); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get(tagCategory, { timeout: 2 * SEC }).then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); + itemsPerPageValidation(appTable, "Tag category"); }); - it("Page number validations", function () { - // Navigate to Tags tab - TagCategory.openList(); - - // Select 10 items per page - selectItemsPerPage(10); - - // Go to page number 2 - goToPage(2); - - // Verify that page number has changed, as previous page nav button got enabled - cy.get(prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); - - // Go back to page number 1 - goToPage(1); + after("Perform test data clean up", function () { + deleteAllTagsAndTagCategories(); }); }); diff --git a/cypress/e2e/tests/migration/migration-waves/pagination.test.ts b/cypress/e2e/tests/migration/migration-waves/pagination.test.ts index 8299422d5..935c0502b 100644 --- a/cypress/e2e/tests/migration/migration-waves/pagination.test.ts +++ b/cypress/e2e/tests/migration/migration-waves/pagination.test.ts @@ -18,18 +18,17 @@ limitations under the License. import { login, selectItemsPerPage, - goToPage, createMultipleMigrationWaves, deleteByList, validatePagination, + itemsPerPageValidation, } from "../../../../utils/utils"; -import * as commonView from "../../../views/common.view"; import { MigrationWave } from "../../../models/migration/migration-waves/migration-wave"; -import { MigrationWaveView } from "../../../views/migration-wave.view"; let migrationWavesList: MigrationWave[] = []; -//Automates Polarion TC 357 + describe(["@tier3"], "Migration Waves pagination validations", function () { + //Automates Polarion TC 357 before("Login and Create Test Data", function () { login(); migrationWavesList = createMultipleMigrationWaves(11); @@ -44,35 +43,7 @@ describe(["@tier3"], "Migration Waves pagination validations", function () { it("Items per page validations", function () { MigrationWave.open(); selectItemsPerPage(10); - - // Verify that only 10 items are displayed - cy.get(MigrationWaveView.migrationWavesTable) - .find("td[data-label=Name]") - .then(($rows) => { - cy.wrap($rows.length).should("eq", 10); - }); - - selectItemsPerPage(20); - - // Verify that items less than or equal to 20 and greater than 10 are displayed - cy.get(MigrationWaveView.migrationWavesTable) - .find("td[data-label=Name]") - .then(($rows) => { - cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); - }); - }); - - it("Page number validations", function () { - MigrationWave.open(); - selectItemsPerPage(10); - - goToPage(2); - - cy.get(commonView.prevPageButton).each(($previousBtn) => { - cy.wrap($previousBtn).should("not.be.disabled"); - }); - - goToPage(1); + itemsPerPageValidation(); }); after("Perform test data clean up", function () { diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 9e9945625..81473bbfe 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -753,7 +753,7 @@ export function verifyAppImport( ): void { // Verify the app import features for a single row cy.get("table > tbody > tr").as("firstRow"); - cy.get("@firstRow").find("td[data-label='File name']").should("contain", fileName); + cy.get("@firstRow").find("td[data-label='Filename']").should("contain", fileName); cy.get("@firstRow").find("td[data-label='Status']").find("div").should("contain", status); cy.get("@firstRow").find("td[data-label='column-4']").should("contain", accepted); cy.get("@firstRow").find("td[data-label='column-5']").should("contain", rejected); @@ -1207,10 +1207,31 @@ export function deleteAllRows(tableSelector: string = commonView.commonTable) { .find(trTag) .then(($rows) => { for (let i = 0; i < $rows.length - 1; i++) { - cy.get(sideKebabMenu, { timeout: 10000 }).first().click(); + if (!isTableEmpty()) { + cy.get(sideKebabMenu, { timeout: 10000 }).first().click(); + cy.get("ul[role=menu] > li").contains("Delete").click(); + cy.get(commonView.confirmButton).click(); + cy.wait(5000); + } + } + }); + } + }); +} + +export function deleteAllImports(tableSelector: string = commonView.commonTable) { + isTableEmpty().then((empty) => { + if (!empty) { + cy.get(tableSelector) + .find(trTag) + .then(($rows) => { + for (let i = 0; i < $rows.length - 1; i++) { + cy.get(commonView.manageImportsActionsButton, { timeout: 10000 }) + .eq(1) + .click(); cy.get("ul[role=menu] > li").contains("Delete").click(); cy.get(commonView.confirmButton).click(); - cy.wait(5000); + cy.wait(2 * SEC); } }); } @@ -1277,7 +1298,7 @@ export function deleteApplicationTableRows(): void { export function deleteAppImportsTableRows() { openManageImportsPage(); selectItemsPerPage(100); - deleteAllRows(); + deleteAllImports(); } export const deleteFromArray = (array: T[], el: T): T[] => { @@ -1414,13 +1435,16 @@ export function validatePagination(): void { cy.get(firstPageButton).eq(0).click(); } -export function itemsPerPageValidation(tableSelector = commonView.appTable): void { +export function itemsPerPageValidation( + tableSelector = commonView.appTable, + columnName = "Name" +): void { selectItemsPerPage(10); cy.wait(2000); // Verify that only 10 items are displayed cy.get(tableSelector) - .find("td[data-label=Name]") + .find(`td[data-label='${columnName}']`) .then(($rows) => { cy.wrap($rows.length).should("eq", 10); }); @@ -1430,18 +1454,21 @@ export function itemsPerPageValidation(tableSelector = commonView.appTable): voi // Verify that items less than or equal to 20 and greater than 10 are displayed cy.get(tableSelector) - .find("td[data-label=Name]") + .find(`td[data-label='${columnName}']`) .then(($rows) => { cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10); }); } -export function autoPageChangeValidations(): void { +export function autoPageChangeValidations( + tableSelector = commonView.appTable, + columnName = "Name" +): void { selectItemsPerPage(10); goToLastPage(); - deleteAllRows(); + deleteAllItems(tableSelector); // Verify that page is re-directed to previous page - cy.get("td[data-label=Name]").then(($rows) => { + cy.get(`td[data-label='${columnName}']`).then(($rows) => { cy.wrap($rows.length).should("eq", 10); }); }