Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Add methods for questionnaire class #749

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
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;
}

export class AssessmentQuestionnaire {
public static fullUrl = Cypress.env("tackleUrl") + "/assessment";

/*
constructor(
fileName: string,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add fileName in constructor ?
That will make it a mandatory parameter to initialize this class.

User can just enable legacyPathfinder and not necessarily import one.

We can make fileName a parameter in importQuestionnaire() method and pass it from test in case when we are importing.

Copy link
Contributor Author

@nachandr nachandr Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sshveta , thanks for the question.
My plan is to have the following methods for all questionnaires including the Legacy Pathfinder questionnaire. I know the import method is not relevant to the Legacy Pathfinder questionnaire since it's already available , but the other methods are . I'll look into this to figure out what works the best for this class.

  1. Import
  2. Export
  3. View
  4. Delete
  5. Enable
  6. Disable

) {
this.fileName = fileName;
}*/

public static open() {
cy.url().then(($url) => {
if ($url != AssessmentQuestionnaire.fullUrl) {
Expand All @@ -15,14 +31,61 @@ export class AssessmentQuestionnaire {
});
}

public importQuestionnaire() {
public static importQuestionnaire(fileName) {
AssessmentQuestionnaire.open();
clickByText(button, "Import questionnaire");
cy.get('input#yamlFile-file-upload-filename', { timeout: 2 * SEC }).attachFile(fileName, {
nachandr marked this conversation as resolved.
Show resolved Hide resolved
subjectType: "drag-n-drop",
});
cy.get("form.pf-v5-c-form", { timeout: 5 * SEC })
.find("button")
.contains("Import")
.click();
}
nachandr marked this conversation as resolved.
Show resolved Hide resolved

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);
nachandr marked this conversation as resolved.
Show resolved Hide resolved
}

public static exportQuestionnaire(fileName) {
AssessmentQuestionnaire.open();
cy.contains(fileName, { timeout: 120 * SEC })
.closest('tr')
.within(() => {
click(actionButton);
})
clickByText(button, 'Export');
}

public static toggleQuestionnaire(fileName, toggle: boolean) {
AssessmentQuestionnaire.open();
let selector = (toggle)? ".pf-m-on" : ".pf-m-off";
nachandr marked this conversation as resolved.
Show resolved Hide resolved
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");
}
nachandr marked this conversation as resolved.
Show resolved Hide resolved
});
});
}

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

/*
public static enableLegacyQuestionanire() {
AssessmentQuestionnaire.open();
cy.get(legacyPathfinderToggle, { timeout: 2 * SEC }).then(($checkbox) => {
Expand All @@ -39,5 +102,5 @@ export class AssessmentQuestionnaire {
click(legacyPathfinderToggle);
}
});
}
}*/
}
Loading