Skip to content

Commit

Permalink
[RFR] [JF] Adapt filter tests and refactor filter method (#827)
Browse files Browse the repository at this point in the history
* refactor filter method

Signed-off-by: Alejandro Brugarolas <[email protected]>

* add utils

Signed-off-by: Alejandro Brugarolas <[email protected]>

* refactors

Signed-off-by: Alejandro Brugarolas <[email protected]>

* fix pr

Signed-off-by: Alejandro Brugarolas <[email protected]>

* fix pr

Signed-off-by: Alejandro Brugarolas <[email protected]>

---------

Signed-off-by: Alejandro Brugarolas <[email protected]>
  • Loading branch information
abrugaro authored Nov 22, 2023
1 parent 9162ca1 commit 2884727
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,125 +41,103 @@ import { Stakeholdergroups } from "../../../../models/migration/controls/stakeho
import * as commonView from "../../../../../e2e/views/common.view";
import * as data from "../../../../../utils/data_utils";

var stakeholdersList: Array<Stakeholders> = [];
var stakeholdergroupsList: Array<Stakeholdergroups> = [];
var invalidSearchInput = data.getRandomNumber();
let stakeholdersList: Array<Stakeholders> = [];
let stakeholderGroupsList: Array<Stakeholdergroups> = [];
const invalidSearchInput = `${data.getRandomNumber()}`;

describe(["@tier2"], "Stakeholder groups filter validations", function () {
before("Login and Create Test Data", function () {
login();

// Create multiple stakeholder groups and stakeholders
stakeholdersList = createMultipleStakeholders(2);
stakeholdergroupsList = createMultipleStakeholderGroups(2, stakeholdersList);
stakeholderGroupsList = createMultipleStakeholderGroups(2, stakeholdersList);
});

beforeEach("Interceptors", function () {
// Interceptors
cy.intercept("GET", "/hub/stakeholdergroups*").as("getStakeholdergroups");
cy.intercept("GET", "/hub/stakeholdergroups*").as("getStakeholderGroups");
});

it("Bug MTA-1715: Name filter validations", function () {
// Navigate to stakeholder groups tab
Stakeholdergroups.openList();
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter an existing name substring and apply it as search filter
var validSearchInput = stakeholdergroupsList[0].name.substring(0, 5);
const validSearchInput = stakeholderGroupsList[0].name.substring(0, 5);
applySearchFilter(name, validSearchInput);

// Assert that stakeholder groups row(s) containing the search text is/are displayed
exists(stakeholdergroupsList[0].name);
if (stakeholdergroupsList[1].name.indexOf(validSearchInput) >= 0) {
exists(stakeholderGroupsList[0].name);
if (stakeholderGroupsList[1].name.indexOf(validSearchInput) >= 0) {
exists(stakeholdersList[1].name);
}

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter a non-existing name substring and apply it as search filter
applySearchFilter(name, invalidSearchInput);

// Assert that no search results are found
cy.get("h2").contains("No stakeholder groups available");

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");
});

it("Bug MTA-1715: Description filter validations", function () {
// Navigate to stakeholder groups tab
Stakeholdergroups.openList();
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter an existing description substring and apply it as search filter
var validSearchInput = stakeholdergroupsList[0].description.substring(0, 3);
const validSearchInput = stakeholderGroupsList[0].description.substring(0, 3);
applySearchFilter(description, validSearchInput);

// Assert that stakeholder groups row(s) containing the search text is/are displayed
exists(stakeholdergroupsList[0].description);
if (stakeholdergroupsList[1].description.indexOf(validSearchInput) >= 0) {
exists(stakeholdergroupsList[1].description);
exists(stakeholderGroupsList[0].description);
if (stakeholderGroupsList[1].description.indexOf(validSearchInput) >= 0) {
exists(stakeholderGroupsList[1].description);
}

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter a non-existing description substring and apply it as search filter
applySearchFilter(description, invalidSearchInput);

// Assert that no search results are found
cy.get("h2").contains("No stakeholder groups available");

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");
});

it("Bug MTA-1715: Member filter validations", function () {
// Navigate to stakeholder groups tab
Stakeholdergroups.openList();
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter an existing member substring and apply it as search filter
var validSearchInput = stakeholdergroupsList[0].members[0].substring(0, 3);
const validSearchInput = stakeholderGroupsList[0].members[0].substring(0, 3);
applySearchFilter(stakeholders, validSearchInput);

// Assert that stakeholder groups row(s) containing the search text is/are displayed
selectItemsPerPage(100);
cy.get(tdTag)
.contains(stakeholdergroupsList[0].name)
.contains(stakeholderGroupsList[0].name)
.parent(trTag)
.within(() => {
click(commonView.expandRow);
})
.get("div > dd")
.should("contain", stakeholdergroupsList[0].members[0]);
.should("contain", stakeholderGroupsList[0].members[0]);

if (stakeholdergroupsList[1].members[0].indexOf(validSearchInput) >= 0) {
exists(stakeholdergroupsList[1].members[0]);
if (stakeholderGroupsList[1].members[0].indexOf(validSearchInput) >= 0) {
exists(stakeholderGroupsList[1].members[0]);
}

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");

// Enter a non-existing member substring and apply it as search filter
applySearchFilter(stakeholders, invalidSearchInput);

// Assert that no search results are found
cy.get("h2").contains("No stakeholder groups available");

// Clear all filters
clickByText(button, clearAllFilters);
cy.get("@getStakeholdergroups");
cy.get("@getStakeholderGroups");
});

after("Perform test data clean up", function () {
deleteByList(stakeholdersList);
deleteByList(stakeholdergroupsList);
deleteByList(stakeholderGroupsList);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
clearAllFilters,
businessService,
owner,
businessServiceLower,
} from "../../../types/constants";
import * as data from "../../../../utils/data_utils";
import { MigrationWave } from "../../../models/migration/migration-waves/migration-wave";
Expand Down Expand Up @@ -108,13 +109,13 @@ describe(
cy.contains(manageApplications).click();

// Apply BS associated with applicationsList[1].name as search filter
applySearchFilter(businessService, applicationsList[1].business, true, 1);
applySearchFilter(businessServiceLower, applicationsList[1].business, true, 1);
cy.get("td").should("contain", applicationsList[1].name);
cy.get("td").should("not.contain", applicationsList[0].name);
clickByText(button, clearAllFilters);

// Apply BS associated with applicationsList[0].name as search filter
applySearchFilter(businessService, applicationsList[0].business, true, 1);
applySearchFilter(businessServiceLower, applicationsList[0].business, true, 1);
cy.get("td").should("not.contain", applicationsList[1].name);
cy.get("td").should("contain", applicationsList[0].name);
clickByText(button, clearAllFilters);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/tests/rbac/disable_keycloak.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe(["@tier4"], "Perform certain operations after disabling Keycloak", func
});

it.skip("Bug MTA-1152: Auth disabled, Verify presence of Review application button", function () {
Application.validateReviewButton(this.rbacRules);
// Application.validateReviewButton(this.rbacRules);
});

after("Re-enable Keycloak", function () {
Expand Down
10 changes: 1 addition & 9 deletions cypress/e2e/tests/upgrade/create_upgrade_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ limitations under the License.
*/
/// <reference types="cypress" />

import {
getRandomAnalysisData,
getRandomApplicationData,
login,
preservecookies,
} from "../../../utils/utils";
import { getRandomAnalysisData, getRandomApplicationData, login } from "../../../utils/utils";
import { TagCategory } from "../../models/migration/controls/tagcategory";
import * as data from "../../../utils/data_utils";
import { Tag } from "../../models/migration/controls/tags";
Expand All @@ -45,9 +40,6 @@ describe(["@pre-upgrade"], "Creating pre-requisites before an upgrade", () => {
});

beforeEach("Persist session", function () {
// Save the session and token cookie for maintaining one login session
preservecookies();

cy.fixture("application").then(function (appData) {
this.appData = appData;
});
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const analyzeButton = "Analyze";
export const artifact = "Artifact";
export const businessServices = "Business services";
export const businessService = "Business Service";
export const businessServiceLower = "Business service";
export const button = "button";
export const category = "Category";
export const clearAllFilters = "Clear all filters";
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ export const nextButton = "button[cy-data='next']";
export const span = "span";
export const liTag = "li";
export const searchInput = "#search-input";
/**
* ul[role=listbox] > li is for the Application Inventory page.
* span.pf-c-check__label is for the Copy assessment page.
*/
export const standardFilter = "ul[role=listbox] > li, span.pf-v5-c-check__label";
export const specialFilter = "div.pf-v5-c-select__menu > fieldset > label > span";
export const filterDropDownContainer =
"div.pf-v5-c-toolbar__group.pf-m-toggle-group.pf-m-filter-group.pf-m-show";
export const filterDropDown = "div.pf-v5-c-select";
Loading

0 comments on commit 2884727

Please sign in to comment.