Skip to content

Commit

Permalink
[RFR] Add method to enable/disable questionnaire (#757)
Browse files Browse the repository at this point in the history
* Add method to enable/disable questionnaire

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

* Update enable method

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

* Update timeout

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

---------

Signed-off-by: Nandini Chandra <[email protected]>
  • Loading branch information
nachandr authored Oct 19, 2023
1 parent 2ec169b commit d4c7079
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { click, clickByText, selectUserPerspective } from "../../../../utils/utils";
import { SEC, assessmentQuestionnaires, deleteAction } from "../../../types/constants";
import {
legacyPathfinderToggle,
questionnaireUpload,
confirmDeletion,
importQuestionnaire,
switchToggle,
} from "../../../views/assessmentquestionnaire.view";
import { navMenu } from "../../../views/menu.view";
import { button } from "../../../../e2e/types/constants";
Expand All @@ -23,7 +23,7 @@ export class AssessmentQuestionnaire {
});
}

public static operation(fileName, operation) {
public static operation(fileName: string, operation: string) {
AssessmentQuestionnaire.open();
cy.contains(fileName, { timeout: 120 * SEC })
.closest("tr")
Expand All @@ -33,7 +33,7 @@ export class AssessmentQuestionnaire {
clickByText(button, operation);
}

public static importQuestionnaire(fileName) {
public static import(fileName: string) {
AssessmentQuestionnaire.open();
click(importQuestionnaire);
cy.get(questionnaireUpload, { timeout: 2 * SEC }).attachFile(fileName, {
Expand All @@ -45,39 +45,37 @@ export class AssessmentQuestionnaire {
.click();
}

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

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

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

public downloadYamlTemplate() {
AssessmentQuestionnaire.open();
}

public static enableLegacyQuestionanire() {
public static enable(fileName: string, enable = true) {
AssessmentQuestionnaire.open();
cy.get(legacyPathfinderToggle, { timeout: 2 * SEC }).then(($checkbox) => {
if (!$checkbox.prop("checked")) {
click(legacyPathfinderToggle);
}
});
let selector = enable ? ".pf-m-on" : ".pf-m-off";
cy.contains(fileName, { timeout: 2 * SEC })
.closest("tr")
.within(() => {
cy.get(selector)
.invoke("css", "display")
.then((display) => {
if (display.toString() == "none") {
click(switchToggle);
}
});
});
}

public static disableLegacyQuestionanire() {
public downloadYamlTemplate() {
AssessmentQuestionnaire.open();
cy.get(legacyPathfinderToggle, { timeout: 2 * SEC }).then(($checkbox) => {
if ($checkbox.prop("checked")) {
click(legacyPathfinderToggle);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import { AssessmentQuestionnaire } from "../../../../models/administration/asses

const stakeholdersList: Array<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];
const fileName = "Legacy Pathfinder";

describe.skip(["@tier1"], "Application assessment and review tests", () => {
// Need to be unskipped when bug MTA-1449 is fixed . All test are failing .
before("Login and Create Test Data", function () {
login();
AssessmentQuestionnaire.enableLegacyQuestionanire();
AssessmentQuestionnaire.enable(fileName);
// Navigate to stakeholders control tab and create new stakeholder
const stakeholder = new Stakeholders(data.getEmail(), data.getFullName());
stakeholder.create();
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/views/assessmentquestionnaire.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,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";
export const switchToggle = ".pf-v5-c-switch__toggle";

0 comments on commit d4c7079

Please sign in to comment.