From 8778802b4f9995e59ff41a985027b2f2e27d8217 Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Tue, 29 Aug 2023 16:57:15 -0500 Subject: [PATCH] Refactor deleteAppImportsTableRows() Signed-off-by: Nandini Chandra --- cypress/utils/utils.ts | 45 +++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 1bbe6f608..4182e78dc 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -856,36 +856,27 @@ export function deleteApplicationTableRows(): void { }); } -export function deleteAppImportsTableRows(lastPage = false): void { - if (!lastPage) { - openManageImportsPage(); - // Select 100 items per page - selectItemsPerPage(100); - cy.wait(2000); +export function deleteAppImportsTableRows() { + function deleteItems(rowCount): 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.get(commonView.appTable) - .next() - .then(($div) => { - if (!$div.hasClass("pf-c-empty-state")) { - cy.get("tbody") - .find(trTag) - .not(".pf-c-table__expandable-row") - .each(($tableRow) => { - var date = $tableRow.find("td[data-label=Date]").text(); - cy.get(tdTag) - .contains(date) - .parent(trTag) - .within(() => { - cy.get(sideKebabMenuImports).click(); - }) - .contains(button, deleteAction) - .click(); - cy.wait(800); - click(commonView.confirmButton); - cy.wait(4000); - }); - } + .find(trTag) + .then(($rows) => { + let rowCount = 0; + rowCount = $rows.length - 1; + + if (rowCount >= 1) deleteItems(rowCount); }); }