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] Add methods for questionnaire class #749

Merged
merged 5 commits into from
Oct 19, 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
@@ -1,7 +1,15 @@
import { click, clickByText, selectUserPerspective } from "../../../../utils/utils";
import { SEC, assessmentQuestionnaires } from "../../../types/constants";
import { legacyPathfinderToggle } from "../../../views/assessmentquestionnaire.view";
import { SEC, assessmentQuestionnaires, deleteAction } from "../../../types/constants";
import {
legacyPathfinderToggle,
questionnaireUpload,
confirmDeletion,
importQuestionnaire,
} from "../../../views/assessmentquestionnaire.view";
import { navMenu } from "../../../views/menu.view";
import { button } from "../../../../e2e/types/constants";
import { actionButton } from "../../../views/applicationinventory.view";
import { controlsForm } from "../../../views/common.view";

export class AssessmentQuestionnaire {
public static fullUrl = Cypress.env("tackleUrl") + "/assessment";
Expand All @@ -15,8 +23,40 @@ export class AssessmentQuestionnaire {
});
}

public importQuestionnaire() {
public static operation(fileName, operation) {
AssessmentQuestionnaire.open();
cy.contains(fileName, { timeout: 120 * SEC })
.closest("tr")
.within(() => {
click(actionButton);
});
clickByText(button, operation);
}

public static importQuestionnaire(fileName) {
AssessmentQuestionnaire.open();
click(importQuestionnaire);
cy.get(questionnaireUpload, { timeout: 2 * SEC }).attachFile(fileName, {
nachandr marked this conversation as resolved.
Show resolved Hide resolved
subjectType: "drag-n-drop",
});
cy.get(controlsForm, { timeout: 5 * SEC })
.find("button")
.contains("Import")
.click();
}

public static deleteQuestionnaire(fileName) {
AssessmentQuestionnaire.operation(fileName, deleteAction);
cy.get(confirmDeletion).click().focused().clear().type(fileName);
clickByText(button, deleteAction);
}

public static exportQuestionnaire(fileName) {
AssessmentQuestionnaire.operation(fileName, "Export");
}

public static viewQuestionnaire(fileName) {
AssessmentQuestionnaire.operation(fileName, "View");
}

public downloadYamlTemplate() {
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/views/assessmentquestionnaire.view.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export const legacyPathfinderToggle = "input#required-switch-0";
export const questionnaireUpload = "input#yamlFile-file-upload-filename";
export const confirmDeletion = ".confirm-deletion-input";
export const importQuestionnaire = "#import-questionnaire";