From 2ec169b3dc375277691e8cfbea6f7c5c444056ee Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Thu, 19 Oct 2023 10:56:15 -0500 Subject: [PATCH] [RFR] Add methods for questionnaire class (#749) * Add method for importing questionnaire Signed-off-by: Nandini Chandra * Add methods to delete and export questionnaires Signed-off-by: Nandini Chandra * Add methods to toggle questionnaire status Signed-off-by: Nandini Chandra * Moved selectors to view file Signed-off-by: Nandini Chandra * Add operation method Signed-off-by: Nandini Chandra --------- Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 46 +++++++++++++++++-- .../e2e/views/assessmentquestionnaire.view.ts | 3 ++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index bc1a569c0..0a48ed8c4 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -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"; @@ -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() { diff --git a/cypress/e2e/views/assessmentquestionnaire.view.ts b/cypress/e2e/views/assessmentquestionnaire.view.ts index ead8c914e..4b36cdd3e 100644 --- a/cypress/e2e/views/assessmentquestionnaire.view.ts +++ b/cypress/e2e/views/assessmentquestionnaire.view.ts @@ -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";