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] Adapt rbac and download tests #752

Merged
merged 2 commits into from
Oct 18, 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
18 changes: 9 additions & 9 deletions cypress/e2e/models/migration/applicationinventory/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
applicationInventory,
button,
migration,
ReportTypeSelectors,
RepositoryType,
save,
SEC,
Expand Down Expand Up @@ -363,19 +364,18 @@ export class Analysis extends Application {
return;
}

downloadReport(type: string, isEnabled = true) {
downloadReport(type: ReportTypeSelectors) {
Analysis.open();
this.selectApplicationRow();
cy.get(rightSideMenu, { timeout: 30 * SEC }).within(() => {
clickTab("Reports");
if (isEnabled) {
clickByText("a", type);
cy.verifyDownload("report.tar.gz");
// Removing downloaded file after verifying it
cleanupDownloads();
} else {
doesExistText(type, isEnabled);
}
click(type);
// waits until the file is downloaded
cy.get(type, { timeout: 30 * SEC });
const extension = type === ReportTypeSelectors.YAML ? "yaml" : "tar";
cy.verifyDownload(`analysis-report-app-${this.name}.${extension}`);
// Removing downloaded file after verifying it
cleanupDownloads();
});
this.closeApplicationDetails();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
packaging,
kebabMenu,
repoTypeSelect,
topKebabMenu,
} from "../../../views/applicationinventory.view";
import { appDetailsView } from "../../../views/applicationinventory.view";
import * as commonView from "../../../views/common.view";
Expand Down Expand Up @@ -368,9 +369,7 @@ export class Application {
.contains(this.name)
.closest(trTag)
.within(() => {
click(selectBox);
cy.wait(SEC);
click('button[aria-label="Kebab toggle"]');
click(`${kebabMenu} > button`);
doesExistText(
"Analysis details",
rbacRules["analysis applicable options"]["Analysis details"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ limitations under the License.
*/
/// <reference types="cypress" />

import { getRandomAnalysisData, getRandomApplicationData, login } from "../../../../../utils/utils";
import { GeneralConfig } from "../../../../models/administration/general/generalConfig";
import {
cleanupDownloads,
getRandomAnalysisData,
getRandomApplicationData,
login,
} from "../../../../../utils/utils";
import { Analysis } from "../../../../models/migration/applicationinventory/analysis";
import { SEC } from "../../../../types/constants";
import { AnalysisStatuses, ReportTypeSelectors, SEC } from "../../../../types/constants";

describe(["@tier2"], "Enable and Download HTML and CSV Reports", function () {
let sourceApplication: Analysis;
let generalConfig = GeneralConfig.getInstance();

before("Login and enable download of HTML and CSV reports", function () {
before("Login", function () {
login();
});

Expand All @@ -37,7 +40,7 @@ describe(["@tier2"], "Enable and Download HTML and CSV Reports", function () {
});
});

it("Download HTML and CSV Reports - Source App", function () {
it("Download TAR and YAML Reports - Source App", function () {
sourceApplication = new Analysis(
getRandomApplicationData("SourceApp", {
sourceData: this.appData["bookserver-app"],
Expand All @@ -47,22 +50,13 @@ describe(["@tier2"], "Enable and Download HTML and CSV Reports", function () {
sourceApplication.create();
cy.wait(2 * SEC);
sourceApplication.analyze();
sourceApplication.verifyAnalysisStatus("Completed");
sourceApplication.downloadReport("HTML");
sourceApplication.downloadReport("CSV");
});

it("Disable HTML/CSV reports and validate they are disabled", function () {
// Disabling download of HTML and CSV reports
generalConfig.disableDownloadHtml();
generalConfig.disableDownloadCsv();

// Validating that existing reports do not have HTML/CSV links anymore
sourceApplication.downloadReport("HTML", false);
sourceApplication.downloadReport("CSV", false);
sourceApplication.verifyAnalysisStatus(AnalysisStatuses.completed);
sourceApplication.downloadReport(ReportTypeSelectors.TAR);
sourceApplication.downloadReport(ReportTypeSelectors.YAML);
});

after("Cleaning up", function () {
sourceApplication.delete();
cleanupDownloads();
});
});
5 changes: 5 additions & 0 deletions cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export enum AnalysisStatuses {
canceled = "Canceled",
}

export enum ReportTypeSelectors {
TAR = "#download-tar-button",
YAML = "#download-yaml-button",
}

export enum RepositoryType {
git = "Git",
subversion = "Subversion",
Expand Down