Skip to content

Commit

Permalink
[RFR] Add methods for questionnaire class (#749)
Browse files Browse the repository at this point in the history
* Add method for importing questionnaire

Signed-off-by: Nandini Chandra <[email protected]>

* Add methods to delete and export questionnaires

Signed-off-by: Nandini Chandra <[email protected]>

* Add methods to toggle questionnaire status

Signed-off-by: Nandini Chandra <[email protected]>

* Moved selectors to view file

Signed-off-by: Nandini Chandra <[email protected]>

* Add operation method

Signed-off-by: Nandini Chandra <[email protected]>

---------

Signed-off-by: Nandini Chandra <[email protected]>
  • Loading branch information
nachandr authored Oct 19, 2023
1 parent de04241 commit 2ec169b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
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, {
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";

0 comments on commit 2ec169b

Please sign in to comment.