diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index 0a48ed8c4..d81c3f597 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -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"; @@ -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") @@ -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, { @@ -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); - } - }); } } diff --git a/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts b/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts index 629043716..f1a169101 100644 --- a/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts +++ b/cypress/e2e/tests/migration/applicationinventory/assessment/assess_review.test.ts @@ -25,12 +25,13 @@ import { AssessmentQuestionnaire } from "../../../../models/administration/asses const stakeholdersList: Array = []; const stakeholdersNameList: Array = []; +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(); diff --git a/cypress/e2e/views/assessmentquestionnaire.view.ts b/cypress/e2e/views/assessmentquestionnaire.view.ts index 4b36cdd3e..2dc4c61d7 100644 --- a/cypress/e2e/views/assessmentquestionnaire.view.ts +++ b/cypress/e2e/views/assessmentquestionnaire.view.ts @@ -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";