diff --git a/cypress/e2e/tests/migration/applicationinventory/manageimports/csv.test.ts b/cypress/e2e/tests/migration/applicationinventory/manageimports/csv.test.ts index c81966820..de4c5b5ee 100644 --- a/cypress/e2e/tests/migration/applicationinventory/manageimports/csv.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/manageimports/csv.test.ts @@ -15,17 +15,20 @@ limitations under the License. */ /// -import { login, openManageImportsPage } from "../../../../../utils/utils"; -import { topKebabMenu, kebabMenuItem } from "../../../../views/applicationinventory.view"; +import { click, login, openManageImportsPage } from "../../../../../utils/utils"; +import { kebabMenuItem } from "../../../../views/applicationinventory.view"; +import { Application } from "../../../../models/migration/applicationinventory/application"; +import { manageImportsActionsButton } from "../../../../views/common.view"; describe(["@tier2"], "Manage imports tests", function () { before("Login", function () { login(); + Application.open(); openManageImportsPage(); }); it("Download CSV template", function () { - cy.get(topKebabMenu).eq(1).click(); + click(manageImportsActionsButton, true, false, 1); cy.get(kebabMenuItem).contains("Download CSV template").click(); cy.readFile("cypress/downloads/template_application_import.csv").should( "contain", diff --git a/cypress/e2e/tests/migration/applicationinventory/manageimports/filter.test.ts b/cypress/e2e/tests/migration/applicationinventory/manageimports/filter.test.ts index e4d6a14fd..7cd0192a6 100644 --- a/cypress/e2e/tests/migration/applicationinventory/manageimports/filter.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/manageimports/filter.test.ts @@ -37,7 +37,7 @@ const filesToImport = [ "mandatory_and_empty_rows.csv", "non_existing_tags_business_service_rows.csv", ]; -var invalidSearchInput = String(data.getRandomNumber()); +const invalidSearchInput = String(data.getRandomNumber()); describe(["@tier2"], "Manage applications import filter validations", function () { before("Login and create test data", function () { @@ -63,7 +63,7 @@ describe(["@tier2"], "Manage applications import filter validations", function ( openManageImportsPage(); // Enter an existing file name substring and apply it as search filter - var validSearchInput = filesToImport[0].substring(0, 5); + const validSearchInput = filesToImport[0].substring(0, 5); applySearchFilter(FileName, validSearchInput); // Assert that application import row(s) containing the search text is/are displayed diff --git a/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts b/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts index 12c980788..e4b4ae9f7 100644 --- a/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/manageimports/pagination.test.ts @@ -27,7 +27,7 @@ import { deleteAppImportsTableRows, } from "../../../../../utils/utils"; import { trTag } from "../../../../types/constants"; -import { actionButton } from "../../../../views/applicationinventory.view"; +import { sideKebabMenuImports } from "../../../../views/applicationinventory.view"; import * as commonView from "../../../../views/common.view"; import { Application } from "../../../../models/migration/applicationinventory/application"; @@ -78,9 +78,11 @@ describe(["@tier3"], "Manage imports pagination validations", function () { beforeEach("Interceptors", function () { // Interceptors for Applications cy.intercept("GET", "/hub/application*").as("getApplications"); + cy.intercept("GET", "/hub/importsummaries*").as("getImports"); + cy.intercept("DELETE", "/hub/importsummaries*/*").as("deleteImport"); }); - it("Bug MTA-1185: Navigation button validations", function () { + it("Navigation button validations", function () { Application.open(); cy.get("@getApplications"); openManageImportsPage(); @@ -117,7 +119,7 @@ describe(["@tier3"], "Manage imports pagination validations", function () { cy.get(commonView.firstPageButton).should("not.be.disabled"); }); - it("Bug MTA-1185: Items per page validations", function () { + it("Items per page validations", function () { Application.open(); cy.get("@getApplications"); openManageImportsPage(); @@ -143,7 +145,7 @@ describe(["@tier3"], "Manage imports pagination validations", function () { }); }); - it("Bug MTA-1185: Page number validations", function () { + it("Page number validations", function () { Application.open(); cy.get("@getApplications"); openManageImportsPage(); @@ -162,7 +164,7 @@ describe(["@tier3"], "Manage imports pagination validations", function () { goToPage(1); }); - it("Bug MTA-1185: Last page item(s) deletion, impact on page reload validation", function () { + it("Last page item(s) deletion, impact on page reload validation", function () { // Navigate to Application inventory tab and open manage imports page Application.open(); cy.get("@getApplications"); @@ -170,20 +172,21 @@ describe(["@tier3"], "Manage imports pagination validations", function () { // Select 10 items per page selectItemsPerPage(10); - cy.wait(2000); + cy.wait("@getImports"); // Navigate to last page goToLastPage(); - cy.wait(2000); + cy.wait("@getImports"); // Delete all items of last page cy.get(commonView.appTable) .get("tbody") .find("td[data-label='File name']") .each(($tableRow) => { - click(actionButton); + click(sideKebabMenuImports); cy.get("ul[role=menu] > li").contains("Delete").click(); click(commonView.confirmButton); + cy.wait("@deleteImport"); cy.wait(4000); }); diff --git a/cypress/e2e/views/common.view.ts b/cypress/e2e/views/common.view.ts index 08037cdc7..f70722a80 100644 --- a/cypress/e2e/views/common.view.ts +++ b/cypress/e2e/views/common.view.ts @@ -60,3 +60,4 @@ export const kebabMenuItem = "a.pf-c-dropdown__menu-item"; export const commonTable = "table[aria-label='main-table']"; export const dropdownClearSelection = "pf-v5-c-select__toggle-clear"; export const footer = "footer"; +export const manageImportsActionsButton = 'button[aria-label="Actions"]'; diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 26daba61d..244d4b920 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -847,25 +847,20 @@ export function deleteApplicationTableRows(): void { } export function deleteAppImportsTableRows() { - function deleteItems(rowCount: number): void { - if (rowCount < 1) return; - cy.get(sideKebabMenuImports, { timeout: 10000 }).first().click(); - cy.get("ul[role=menu] > li").contains("Delete").click(); - cy.get(commonView.confirmButton) - .click() - .then(() => { - cy.wait(4000); - deleteItems(--rowCount); - }); - } - openManageImportsPage(); + + cy.intercept("DELETE", "/hub/importsummaries*/*").as("deleteImportUtils"); + cy.get(commonView.appTable) .find(trTag) .then(($rows) => { - const rowCount = $rows.length - 1; - - if (rowCount >= 1) deleteItems(rowCount); + for (let i = 0; i < $rows.length - 1; i++) { + cy.get(sideKebabMenuImports, { timeout: 10000 }).first().click(); + cy.get("ul[role=menu] > li").contains("Delete").click(); + cy.get(commonView.confirmButton).click(); + cy.wait("@deleteImportUtils"); + cy.wait(5000); + } }); }