diff --git a/cypress/e2e/models/migration/applicationinventory/analysis.ts b/cypress/e2e/models/migration/applicationinventory/analysis.ts index 977c24ea8..6d2f528d0 100644 --- a/cypress/e2e/models/migration/applicationinventory/analysis.ts +++ b/cypress/e2e/models/migration/applicationinventory/analysis.ts @@ -73,6 +73,7 @@ import { languageSelectionDropdown, manageCredentials, mavenCredential, + numberOfRulesColumn, openjdkToggleButton, panelBody, rightSideMenu, @@ -112,6 +113,7 @@ export class Analysis extends Application { information?: number; total?: number; }; + ruleFileToQuantity?: { [id: string]: number }; constructor(appData: applicationData, analysisData: analysisData) { super(appData); @@ -138,6 +140,7 @@ export class Analysis extends Application { openSourceLibraries, customRuleRepository, language, + ruleFileToQuantity, } = analysisData; this.name = appData.name; this.source = source; @@ -158,6 +161,7 @@ export class Analysis extends Application { if (incidents) this.incidents = incidents; if (openSourceLibraries) this.openSourceLibraries = openSourceLibraries; if (language) this.language = language; + if (ruleFileToQuantity) this.ruleFileToQuantity = ruleFileToQuantity; } public selectSourceofAnalysis(source: string): void { @@ -533,4 +537,25 @@ export class Analysis extends Application { } cy.get(closeWizard).click({ force: true }); } + + // verifyRulesNumber verifies the number of rules found in an uploaded custom rules file + public verifyRulesNumber(): void { + Application.open(); + this.selectApplication(); + cy.contains(button, analyzeButton).should("be.enabled").click(); + this.selectSourceofAnalysis(this.source); + next(); + next(); + next(); + this.uploadCustomRule(); + for (let fileName in this.numberOfRules) { + const numOfrules = this.numberOfRules[fileName]; + cy.get(trTag) + .filter(':contains("' + fileName + '")') + .within(() => { + cy.get(numberOfRulesColumn).contains(numOfrules.toString()); + }); + } + cy.get(closeWizard).click({ force: true }); + } } diff --git a/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts b/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts index 8cea6189c..6a2f99397 100644 --- a/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/analysis/custom-rules.test.ts @@ -30,9 +30,9 @@ import { deleteByList } from "../../../../../utils/utils"; import { CredentialsMaven } from "../../../../models/administration/credentials/credentialsMaven"; import { Application } from "../../../../models/migration/applicationinventory/application"; -describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { +describe(["@tier2"], "Custom Rules in analyses", function () { const applications: Analysis[] = []; - let tackleTestappName: string; + let tackleTestapp: Analysis; let sourceCredential: CredentialsSourceControlUsername; let mavenCredential: CredentialsMaven; @@ -95,14 +95,14 @@ describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { }); // Automates Bug MTA-2001 - it("Verify triggered rule for dependency", function () { + it("Bug MTA-3863: Verify triggered rule for dependency", function () { const app = new Analysis( getRandomApplicationData("tackle-testapp-custom-rules", { sourceData: this.appData["tackle-testapp-git"], }), getRandomAnalysisData(this.analysisData["tackle_test_app_custom_rules"]) ); - tackleTestappName = app.name; + tackleTestapp = app; Application.open(); applications.push(app); app.create(); @@ -115,10 +115,15 @@ describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { // Automates Bug MTA-2000 it("Verify triggered rule for javax.* package import", function () { - Issues.openSingleApplication(tackleTestappName); + Issues.openSingleApplication(tackleTestapp.name); exists("CUSTOM RULE for javax.* package import"); }); + // Automates Bug MTA-2003 + it("Verify number of rules detected in uploaded yaml file", function () { + tackleTestapp.verifyRulesNumber(); + }); + it("Verify a file is not a valid XML", function () { const app = new Analysis( getRandomApplicationData("tackle-testapp-fileNotValidXML", { @@ -127,6 +132,7 @@ describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { getRandomAnalysisData(this.analysisData["tackle_testapp_fileNotValidXML"]) ); app.create(); + applications.push(app); app.verifyFileNotValidXML(); }); @@ -137,7 +143,6 @@ describe(["@tier2"], "Bug MTA-2015: Custom Rules in analyses", function () { }), getRandomAnalysisData(this.analysisData["python_demo_application"]) ); - tackleTestappName = app.name; applications.push(app); app.create(); app.analyze(); diff --git a/cypress/e2e/types/types.ts b/cypress/e2e/types/types.ts index f4cf51b07..6857e37be 100644 --- a/cypress/e2e/types/types.ts +++ b/cypress/e2e/types/types.ts @@ -125,6 +125,7 @@ export type analysisData = { total?: number; }; techTags?: string[][]; + ruleFileToQuantity?: { [id: string]: number }; }; export type UserData = { diff --git a/cypress/e2e/views/analysis.view.ts b/cypress/e2e/views/analysis.view.ts index 25a4f573f..556a72ee3 100644 --- a/cypress/e2e/views/analysis.view.ts +++ b/cypress/e2e/views/analysis.view.ts @@ -45,3 +45,4 @@ export const codeEditorControls = "div.pf-v5-c-code-editor__controls"; export const menuToggle = "button.pf-v5-c-menu-toggle"; export const menuList = "div.pf-v5-c-menu"; export const languageSelectionDropdown = "#filter-control-name-Languages"; +export const numberOfRulesColumn = "td[data-label='Number of rules']"; diff --git a/cypress/fixtures/analysis.json b/cypress/fixtures/analysis.json index 5ce67c6e6..89cdfa72d 100644 --- a/cypress/fixtures/analysis.json +++ b/cypress/fixtures/analysis.json @@ -1027,7 +1027,7 @@ }, "upload_binary_analysis_on_jee_app_custom_rules": { "source": "Upload a local binary", - "target": ["Application server migration"], + "target": ["Application server migration to"], "binary": ["jee-example-app-1.0.0.ear"], "customRule": ["hibernate-custom.windup.xml"], "appName": "jee-example-app custom rules" @@ -1040,6 +1040,10 @@ "01-custom-rule-example.windup.yaml", "01-javax-package-custom-target.windup.yaml" ], + "numberOfRules": { + "01-custom-rule-example.windup.yaml": 1, + "01-javax-package-custom-target.windup.yaml": 1 + }, "openSourceLibraries": true }, "affected_files_on_day_trader_app": { diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index d8e1f4652..3661b8304 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -1091,6 +1091,7 @@ export function getRandomAnalysisData(analysisdata): analysisData { excludedPackagesList: analysisdata.excludedPackagesList, incidents: analysisdata.incidents, openSourceLibraries: analysisdata.openSourceLibraries, + numberOfRules: analysisdata.numberOfRules, }; }