Skip to content

Commit

Permalink
[RFR] Update open() for a few classes (#1217)
Browse files Browse the repository at this point in the history
* Update open() for a few classes

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

* Update application.open()

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

* Update AssessmentQuestionnaire.open()

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

* Update AssessmentQuestionnaire.deleteAllQuestionnaires()

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

* Use different selector for user perspective menu toggle

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

* Update open methods for a few classes

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

* Update Stakeholder URL

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

* Address review comments

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

* Added comment about bug

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

---------

Signed-off-by: Nandini Chandra <[email protected]>
  • Loading branch information
nachandr authored Sep 13, 2024
1 parent f5396b9 commit 4c0d1b3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ import * as commonView from "../../../views/common.view";
export class AssessmentQuestionnaire {
public static fullUrl = Cypress.env("tackleUrl") + "/assessment";

public static open() {
public static open(forceReload = false) {
const itemsPerPage = 100;
if (forceReload) {
cy.visit(AssessmentQuestionnaire.fullUrl, { timeout: 35 * SEC }).then((_) => {
selectItemsPerPage(itemsPerPage);
});
return;
}
cy.url().then(($url) => {
if ($url != AssessmentQuestionnaire.fullUrl) {
selectUserPerspective("Administration");
clickByText(navMenu, assessmentQuestionnaires);
}
});
selectItemsPerPage(itemsPerPage);
}

public static operation(fileName: string, operation: string) {
Expand Down Expand Up @@ -112,7 +120,7 @@ export class AssessmentQuestionnaire {
if (rowName == legacyPathfinder) {
continue;
}
cy.wrap($rows.eq(i).find(actionButton)).click();
cy.wrap($rows.eq(i).find(actionButton)).click({ force: true });
cy.get("li.pf-v5-c-menu__list-item")
.contains("Delete")
.then(($delete_btn) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ export class Application {
public static open(forceReload = false): void {
const itemsPerPage = 100;
if (forceReload) {
cy.visit(Application.fullUrl, { timeout: 35 * SEC }).then((_) =>
selectItemsPerPage(itemsPerPage)
);
cy.visit(Application.fullUrl, { timeout: 35 * SEC }).then((_) => {
// Bug MTA-3812 Application Inventory page takes long to load
// Timeout time of 100s to be reduced after above bug is fixed
cy.get("h1", { timeout: 100 * SEC }).should("contain", applicationInventory);
selectItemsPerPage(itemsPerPage);
});
return;
}

Expand Down
14 changes: 11 additions & 3 deletions cypress/e2e/models/migration/controls/stakeholders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Stakeholders {
email: string;
jobfunction: string;
groups: Array<string>;
static fullUrl = Cypress.env("tackleUrl") + "controls/stakeholders";
static fullUrl = Cypress.env("tackleUrl") + "/controls/stakeholders";

constructor(email: string, name: string, jobfunction?: string, groups?: Array<string>) {
this.email = email;
Expand All @@ -60,7 +60,15 @@ export class Stakeholders {
if (groups) this.groups = groups;
}

public static openList(itemsPerPage = 100): void {
public static openList(forceReload = false): void {
if (forceReload) {
cy.visit(Stakeholders.fullUrl, { timeout: 35 * SEC }).then((_) => {
cy.get("h1", { timeout: 60 * SEC }).should("contain", "Controls");
selectItemsPerPage(100);
});
return;
}

cy.url().then(($url) => {
if ($url != Stakeholders.fullUrl) {
selectUserPerspective(migration);
Expand All @@ -70,7 +78,7 @@ export class Stakeholders {
}
});
cy.get("h1", { timeout: 30 * SEC }).should("contain.text", "Controls");
selectItemsPerPage(itemsPerPage);
selectItemsPerPage(100);
}

protected fillName(name: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ describe(["@tier3"], "Tests for application questionnaire features", () => {
after("Perform test data clean up", function () {
Application.open(true);
application.delete();
Stakeholders.openList(true);
deleteByList(stakeholderList);
AssessmentQuestionnaire.open(true);
AssessmentQuestionnaire.deleteAllQuestionnaires();
});
});
2 changes: 1 addition & 1 deletion cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ export function goToPage(page: number): void {

export function selectUserPerspective(userType: string): void {
cy.get(commonView.optionMenu).click();
cy.get(commonView.actionMenuItem).contains(userType).click();
cy.get(commonView.actionMenuItem).contains(userType).click({ force: true });
}

export function selectWithinModal(selector: string): void {
Expand Down

0 comments on commit 4c0d1b3

Please sign in to comment.