Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] [JF] [TA] adapt manageimport tests #734

Merged
merged 5 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ limitations under the License.
*/
/// <reference types="cypress" />

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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -162,28 +164,29 @@ 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");
openManageImportsPage();

// 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);
});

Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';
25 changes: 10 additions & 15 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}

Expand Down