From c0633da10b7a2b540580ea515e52a98d52176014 Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Mon, 16 Oct 2023 23:59:29 -0500 Subject: [PATCH 1/5] Add method for importing questionnaire Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index bc1a569c0..5536b2291 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -2,10 +2,21 @@ import { click, clickByText, selectUserPerspective } from "../../../../utils/uti import { SEC, assessmentQuestionnaires } from "../../../types/constants"; import { legacyPathfinderToggle } from "../../../views/assessmentquestionnaire.view"; import { navMenu } from "../../../views/menu.view"; +import { button } from "../../../../e2e/types/constants"; + +export interface AssessmentQuestionnaire { + fileName: string; +} export class AssessmentQuestionnaire { public static fullUrl = Cypress.env("tackleUrl") + "/assessment"; + constructor( + fileName: string, + ) { + this.fileName = fileName; + } + public static open() { cy.url().then(($url) => { if ($url != AssessmentQuestionnaire.fullUrl) { @@ -17,6 +28,14 @@ export class AssessmentQuestionnaire { public importQuestionnaire() { AssessmentQuestionnaire.open(); + clickByText(button, "Import questionnaire"); + cy.get('input[type="file"]', { timeout: 2 * SEC }).attachFile(fileName, { + subjectType: "drag-n-drop", + }); + cy.get("form.pf-v5-c-form", { timeout: 5 * SEC }) + .find("button") + .contains("Import") + .trigger("click"); } public downloadYamlTemplate() { From fc47224f4d3e86bbd2bbded93f007a88e9b59594 Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Tue, 17 Oct 2023 18:54:44 -0500 Subject: [PATCH 2/5] Add methods to delete and export questionnaires Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index 5536b2291..19ab696f1 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -1,9 +1,13 @@ -import { click, clickByText, selectUserPerspective } from "../../../../utils/utils"; -import { SEC, assessmentQuestionnaires } from "../../../types/constants"; +import { click, clickByText, selectUserPerspective, inputText, performRowActionByIcon } from "../../../../utils/utils"; +import { SEC, assessmentQuestionnaires, deleteAction } from "../../../types/constants"; import { legacyPathfinderToggle } from "../../../views/assessmentquestionnaire.view"; import { navMenu } from "../../../views/menu.view"; import { button } from "../../../../e2e/types/constants"; +import { actionButton } from "../../../views/applicationinventory.view"; +"input#required-switch-0"; + +// const fileName = "questionnaire_import/cloud-native.yaml" export interface AssessmentQuestionnaire { fileName: string; } @@ -11,11 +15,12 @@ export interface AssessmentQuestionnaire { export class AssessmentQuestionnaire { public static fullUrl = Cypress.env("tackleUrl") + "/assessment"; + /* constructor( fileName: string, ) { this.fileName = fileName; - } + }*/ public static open() { cy.url().then(($url) => { @@ -26,16 +31,38 @@ export class AssessmentQuestionnaire { }); } - public importQuestionnaire() { + public static importQuestionnaire(fileName) { AssessmentQuestionnaire.open(); clickByText(button, "Import questionnaire"); - cy.get('input[type="file"]', { timeout: 2 * SEC }).attachFile(fileName, { + cy.get('input#yamlFile-file-upload-filename', { timeout: 2 * SEC }).attachFile(fileName, { subjectType: "drag-n-drop", }); cy.get("form.pf-v5-c-form", { timeout: 5 * SEC }) .find("button") .contains("Import") - .trigger("click"); + .click(); + } + + public static deleteQuestionnaire(fileName) { + AssessmentQuestionnaire.open(); + cy.contains(fileName, { timeout: 120 * SEC }) + .closest('tr') + .within(() => { + click(actionButton); + }) + clickByText(button, deleteAction); + inputText(".confirm-deletion-input", fileName); + clickByText(button, deleteAction); + } + + public static exportQuestionnaire(fileName) { + AssessmentQuestionnaire.open(); + cy.contains(fileName, { timeout: 120 * SEC }) + .closest('tr') + .within(() => { + click(actionButton); + }) + clickByText(button, 'Export'); } public downloadYamlTemplate() { From b69415810c830bb35e244e6d8635fc2a595f9f50 Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Wed, 18 Oct 2023 00:00:07 -0500 Subject: [PATCH 3/5] Add methods to toggle questionnaire status Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index 19ab696f1..b72dc07c0 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -65,10 +65,27 @@ export class AssessmentQuestionnaire { clickByText(button, 'Export'); } + public static toggleQuestionnaire(fileName, toggle: boolean) { + AssessmentQuestionnaire.open(); + let selector = (toggle)? ".pf-m-on" : ".pf-m-off"; + cy.contains(fileName, { timeout: 120 * SEC }) + .closest("tr") + .within(() => { + cy.get(selector) + .invoke("css", "display") + .then((display) => { + if (display.toString() == "none") { + click(".pf-v5-c-switch__toggle"); + } + }); + }); + } + public downloadYamlTemplate() { AssessmentQuestionnaire.open(); } + /* public static enableLegacyQuestionanire() { AssessmentQuestionnaire.open(); cy.get(legacyPathfinderToggle, { timeout: 2 * SEC }).then(($checkbox) => { @@ -85,5 +102,5 @@ export class AssessmentQuestionnaire { click(legacyPathfinderToggle); } }); - } + }*/ } From 0697f7bbc59c082b7a914d7580f64db6fa5b2e3d Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Wed, 18 Oct 2023 16:22:47 -0500 Subject: [PATCH 4/5] Moved selectors to view file Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 71 ++++++++----------- .../e2e/views/assessmentquestionnaire.view.ts | 3 + 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index b72dc07c0..06f93aaca 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -1,27 +1,19 @@ -import { click, clickByText, selectUserPerspective, inputText, performRowActionByIcon } from "../../../../utils/utils"; +import { click, clickByText, selectUserPerspective } from "../../../../utils/utils"; import { SEC, assessmentQuestionnaires, deleteAction } from "../../../types/constants"; -import { legacyPathfinderToggle } from "../../../views/assessmentquestionnaire.view"; +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"; - -"input#required-switch-0"; - -// const fileName = "questionnaire_import/cloud-native.yaml" -export interface AssessmentQuestionnaire { - fileName: string; -} +import { controlsForm } from "../../../views/common.view"; export class AssessmentQuestionnaire { public static fullUrl = Cypress.env("tackleUrl") + "/assessment"; - /* - constructor( - fileName: string, - ) { - this.fileName = fileName; - }*/ - public static open() { cy.url().then(($url) => { if ($url != AssessmentQuestionnaire.fullUrl) { @@ -33,59 +25,52 @@ export class AssessmentQuestionnaire { public static importQuestionnaire(fileName) { AssessmentQuestionnaire.open(); - clickByText(button, "Import questionnaire"); - cy.get('input#yamlFile-file-upload-filename', { timeout: 2 * SEC }).attachFile(fileName, { + click(importQuestionnaire); + cy.get(questionnaireUpload, { timeout: 2 * SEC }).attachFile(fileName, { subjectType: "drag-n-drop", }); - cy.get("form.pf-v5-c-form", { timeout: 5 * SEC }) - .find("button") - .contains("Import") - .click(); + cy.get(controlsForm, { timeout: 5 * SEC }) + .find("button") + .contains("Import") + .click(); } public static deleteQuestionnaire(fileName) { AssessmentQuestionnaire.open(); cy.contains(fileName, { timeout: 120 * SEC }) - .closest('tr') - .within(() => { - click(actionButton); - }) + .closest("tr") + .within(() => { + click(actionButton); + }); clickByText(button, deleteAction); - inputText(".confirm-deletion-input", fileName); + cy.get(confirmDeletion).click().focused().clear().type(fileName); clickByText(button, deleteAction); } public static exportQuestionnaire(fileName) { AssessmentQuestionnaire.open(); cy.contains(fileName, { timeout: 120 * SEC }) - .closest('tr') - .within(() => { - click(actionButton); - }) - clickByText(button, 'Export'); + .closest("tr") + .within(() => { + click(actionButton); + }); + clickByText(button, "Export"); } - public static toggleQuestionnaire(fileName, toggle: boolean) { + public static viewQuestionnaire(fileName) { AssessmentQuestionnaire.open(); - let selector = (toggle)? ".pf-m-on" : ".pf-m-off"; cy.contains(fileName, { timeout: 120 * SEC }) .closest("tr") .within(() => { - cy.get(selector) - .invoke("css", "display") - .then((display) => { - if (display.toString() == "none") { - click(".pf-v5-c-switch__toggle"); - } - }); + click(actionButton); }); + clickByText(button, "View"); } public downloadYamlTemplate() { AssessmentQuestionnaire.open(); } - /* public static enableLegacyQuestionanire() { AssessmentQuestionnaire.open(); cy.get(legacyPathfinderToggle, { timeout: 2 * SEC }).then(($checkbox) => { @@ -102,5 +87,5 @@ export class AssessmentQuestionnaire { click(legacyPathfinderToggle); } }); - }*/ + } } 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"; From 38bb9ecfebf7ceb301109198fe8760901eb581c6 Mon Sep 17 00:00:00 2001 From: Nandini Chandra Date: Wed, 18 Oct 2023 17:33:12 -0500 Subject: [PATCH 5/5] Add operation method Signed-off-by: Nandini Chandra --- .../assessment_questionnaire.ts | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts index 06f93aaca..0a48ed8c4 100644 --- a/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts +++ b/cypress/e2e/models/administration/assessment_questionnaire/assessment_questionnaire.ts @@ -23,6 +23,16 @@ export class AssessmentQuestionnaire { }); } + 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); @@ -36,35 +46,17 @@ export class AssessmentQuestionnaire { } public static deleteQuestionnaire(fileName) { - AssessmentQuestionnaire.open(); - cy.contains(fileName, { timeout: 120 * SEC }) - .closest("tr") - .within(() => { - click(actionButton); - }); - clickByText(button, deleteAction); + AssessmentQuestionnaire.operation(fileName, deleteAction); cy.get(confirmDeletion).click().focused().clear().type(fileName); clickByText(button, deleteAction); } public static exportQuestionnaire(fileName) { - AssessmentQuestionnaire.open(); - cy.contains(fileName, { timeout: 120 * SEC }) - .closest("tr") - .within(() => { - click(actionButton); - }); - clickByText(button, "Export"); + AssessmentQuestionnaire.operation(fileName, "Export"); } public static viewQuestionnaire(fileName) { - AssessmentQuestionnaire.open(); - cy.contains(fileName, { timeout: 120 * SEC }) - .closest("tr") - .within(() => { - click(actionButton); - }); - clickByText(button, "View"); + AssessmentQuestionnaire.operation(fileName, "View"); } public downloadYamlTemplate() {