Skip to content

Commit

Permalink
[RFR] Refactored issues tests to be more generic and flexible (#868)
Browse files Browse the repository at this point in the history
* Refactored issues tests to be more generic and flexible

Signed-off-by: Igor Braginsky <[email protected]>

* Refactored all issue filtering tests

Signed-off-by: Igor Braginsky <[email protected]>

* Cleanup

Signed-off-by: Igor Braginsky <[email protected]>

---------

Signed-off-by: Igor Braginsky <[email protected]>
  • Loading branch information
ibragins authored Dec 11, 2023
1 parent 9f783c8 commit a3cba74
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
analyzeButton,
reviewAppButton,
migration,
filterIssue,
details,
legacyPathfinder,
} from "../../../types/constants";
Expand Down Expand Up @@ -76,7 +75,6 @@ import {
doesExistButton,
clickWithin,
validateSingleApplicationIssue,
filterIssueBy,
checkSuccessAlert,
} from "../../../../utils/utils";
import { AppIssue, applicationData, RbacValidationRules } from "../../../types/types";
Expand Down Expand Up @@ -470,13 +468,6 @@ export class Application {
});
}

validateIssueFilter(issues: AppIssue[], filterType: filterIssue, filterValue: string): void {
Issues.openSingleApplication(this.name);
issues.forEach((currentIssue) => {
filterIssueBy(filterType, currentIssue[filterValue]);
validateSingleApplicationIssue(currentIssue);
});
}
editApplicationFromApplicationProfile(): void {
this.applicationDetailsTab(details);
cy.wait(2000);
Expand Down
82 changes: 62 additions & 20 deletions cypress/e2e/models/migration/dynamic-report/issues/issues.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import {
click,
clickByText,
filterIssueBy,
getUrl,
inputText,
selectFilter,
selectItemsPerPage,
selectUserPerspective,
validateAnyNumberPresence,
validateNumberPresence,
validateTextPresence,
} from "../../../../../utils/utils";
import {
button,
filterIssue,
issueFilter,
migration,
SEC,
singleApplication,
trTag,
} from "../../../../types/constants";
import { navMenu } from "../../../../views/menu.view";
import { singleAppDropList, singleApplicationColumns } from "../../../../views/issue.view";
import {
bsFilterName,
issueColumns,
singleAppDropList,
singleApplicationColumns,
tagFilterName,
} from "../../../../views/issue.view";
import { AppIssue } from "../../../../types/types";
import { liTag, searchButton, searchInput, span } from "../../../../views/common.view";

export class Issues {
/** Contains URL of issues web page */
Expand All @@ -41,25 +52,56 @@ export class Issues {
clickByText(button, applicationName);
}

public static validateFilter(
issues: AppIssue[],
filterType: filterIssue,
filterValue: string
public static validateFilter(issue: AppIssue, isSingle = false): void {
cy.contains(issue.name)
.closest(trTag)
.within(() => {
validateTextPresence(issueColumns.issue, issue.name);
validateTextPresence(issueColumns.category, issue.category);
validateTextPresence(issueColumns.source, issue.source);
cy.get(issueColumns.target).within(() => {
issue.targets.forEach((currentTarget) => {
validateTextPresence(liTag, currentTarget);
});
});
validateNumberPresence(issueColumns.effort, issue.effort);
if (!isSingle) {
validateAnyNumberPresence(issueColumns.applications);
} else {
validateAnyNumberPresence(singleApplicationColumns.files);
}
});
}

public static applyFilter(
filterType: issueFilter,
filterValue: string,
isSingle = false
): void {
issues.forEach((issue: AppIssue) => {
const isApplicableFilter =
filterType === filterIssue.tags ||
filterType === filterIssue.category ||
filterType === filterIssue.source ||
filterType === filterIssue.target;
let selector = "";
if (!isSingle) {
Issues.openList();
selectFilter(filterType);
}

const isApplicableFilter =
filterType === issueFilter.appName ||
filterType === issueFilter.category ||
filterType === issueFilter.source ||
filterType === issueFilter.target;

if (isApplicableFilter) {
filterValue = issue[filterValue];
if (isApplicableFilter) {
inputText(searchInput, filterValue);
click(searchButton);
} else {
if (filterType == issueFilter.bs) {
selector = bsFilterName;
} else if (filterType == issueFilter.tags) {
selector = tagFilterName;
}
Issues.openList();
filterIssueBy(filterType, filterValue);
cy.get("tr").should("not.contain", "No data available");
validateTextPresence(singleApplicationColumns.issue, issue["name"]);
});
click(selector);
clickByText(span, filterValue);
click(selector);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ limitations under the License.
/// <reference types="cypress" />

import {
login,
getRandomApplicationData,
getRandomAnalysisData,
deleteByList,
clearAllFilters,
deleteByList,
getRandomAnalysisData,
getRandomApplicationData,
login,
} from "../../../../../../utils/utils";
import { Analysis } from "../../../../../models/migration/applicationinventory/analysis";
import { SEC, filterIssue } from "../../../../../types/constants";
import { issueFilter, SEC } from "../../../../../types/constants";
import { Issues } from "../../../../../models/migration/dynamic-report/issues/issues";
import { BusinessServices } from "../../../../../models/migration/controls/businessservices";
import * as data from "../../../../../../utils/data_utils";
import { AppIssue } from "../../../../../types/types";

let applicationsList: Array<Analysis> = [];
let businessService: BusinessServices;

describe(["@tier2"], "1 Bug: Issues filtering", () => {
describe(["@tier2"], "Issues filtering", () => {
before("Login", function () {
login();
businessService = new BusinessServices(data.getCompanyName(), data.getDescription());
Expand Down Expand Up @@ -60,57 +62,68 @@ describe(["@tier2"], "1 Bug: Issues filtering", () => {
application.analyze();
application.verifyAnalysisStatus("Completed");

Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.appName,
application.name
Issues.applyFilter(issueFilter.appName, application.name);
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.validateFilter(issue);
}
);
clearAllFilters();
});

it("Filtering issues by BS", function () {
Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.bs,
businessService.name
Issues.applyFilter(issueFilter.bs, businessService.name);
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.validateFilter(issue);
}
);
clearAllFilters();
});

it("Filtering issues by tags", function () {
Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.tags,
"tags"
this.analysisData["source_analysis_on_bookserverapp"]["tags"].forEach(
(currentTag: string) => {
Issues.applyFilter(issueFilter.tags, currentTag);
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.validateFilter(issue);
}
);
clearAllFilters();
}
);
clearAllFilters();
});

it("Filtering issues by category", function () {
Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.category,
"category"
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.applyFilter(issueFilter.category, issue.category);
Issues.validateFilter(issue);
clearAllFilters();
}
);
clearAllFilters();
});

it("Bug MTA-1779 - Filtering issues by source", function () {
Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.source,
"source"
it("Filtering issues by source", function () {
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.applyFilter(issueFilter.source, issue.source);
Issues.validateFilter(issue);
clearAllFilters();
}
);
clearAllFilters();
});

it("Filtering issues by target", function () {
Issues.validateFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.target,
"targets"
);
clearAllFilters();
let issues = this.analysisData["source_analysis_on_bookserverapp"]["issues"];
issues.forEach((issue: AppIssue) => {
issue.targets.forEach((target: string) => {
Issues.applyFilter(issueFilter.target, target);
Issues.validateFilter(issue);
clearAllFilters();
});
});
});

after("Perform test data clean up", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import {
clearAllFilters,
} from "../../../../../../utils/utils";
import { Analysis } from "../../../../../models/migration/applicationinventory/analysis";
import { SEC, filterIssue } from "../../../../../types/constants";
import { SEC, issueFilter } from "../../../../../types/constants";
import { Issues } from "../../../../../models/migration/dynamic-report/issues/issues";
import { AppIssue } from "../../../../../types/types";
let applicationsList: Array<Analysis> = [];
let application: Analysis;

describe(["@tier2"], "1 Bug: Single application issues filtering", () => {
describe(["@tier2"], "Single application issues filtering", () => {
before("Login", function () {
login();
});
Expand All @@ -54,30 +56,37 @@ describe(["@tier2"], "1 Bug: Single application issues filtering", () => {
application.analyze();
application.verifyAnalysisStatus("Completed");

application.validateIssueFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.category,
"category"
Issues.openSingleApplication(application.name);
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.applyFilter(issueFilter.category, issue.category, true);
Issues.validateFilter(issue, true);
clearAllFilters();
}
);
clearAllFilters();
});

it("Bug MTA-1779 - Filtering issues by source", function () {
application.validateIssueFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.source,
"source"
it("Filtering issues by source", function () {
Issues.openSingleApplication(application.name);
this.analysisData["source_analysis_on_bookserverapp"]["issues"].forEach(
(issue: AppIssue) => {
Issues.applyFilter(issueFilter.source, issue.source, true);
Issues.validateFilter(issue, true);
clearAllFilters();
}
);
clearAllFilters();
});

it("Filtering issues by target", function () {
application.validateIssueFilter(
this.analysisData["source_analysis_on_bookserverapp"]["issues"],
filterIssue.target,
"targets"
);
clearAllFilters();
Issues.openSingleApplication(application.name);
let issues = this.analysisData["source_analysis_on_bookserverapp"]["issues"];
issues.forEach((issue: AppIssue) => {
issue.targets.forEach((target: string) => {
Issues.applyFilter(issueFilter.target, target, true);
Issues.validateFilter(issue, true);
clearAllFilters();
});
});
});

after("Perform test data clean up", function () {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export enum SortType {
descending = "descending",
}

export enum filterIssue {
export enum issueFilter {
appName = "Application name",
archetype = "Archetype",
bs = "Business service",
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/views/issue.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ export enum singleApplicationColumns {
effort = 'td[data-label="Effort"]',
files = 'td[data-label="Affected files"]',
}

export enum issueColumns {
issue = 'td[data-label="Issue"]',
category = 'td[data-label="Category"]',
source = 'td[data-label="Source"]',
target = 'td[data-label="Target(s)"]',
effort = 'td[data-label="Effort"]',
applications = 'td[data-label="Affected applications"]',
}
3 changes: 1 addition & 2 deletions cypress/fixtures/analysis.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"source": "None",
"targets": ["cloud-readiness"],
"effort": 1,
"affectedFiles": 1,
"tags": ["EJB XML", "Java EE Batch", "EJB XML"]
"affectedFiles": 1
}
],
"dependencies": [
Expand Down
Loading

0 comments on commit a3cba74

Please sign in to comment.