Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 authored Jan 20, 2025
2 parents 37fe79f + 7e3fc21 commit 827e2e9
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = defineConfig({
"cypress/e2e/batchOrderEntry.cy.js",
"cypress/e2e/dashboard.cy.js",
"cypress/e2e/labNumberManagement.cy.js",
"cypress/e2e/AdminE2E/MenuConfig/globalMenuConfig.cy.js",
];
return config;
},
Expand Down
56 changes: 56 additions & 0 deletions frontend/cypress/e2e/AdminE2E/MenuConfig/globalMenuConfig.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import LoginPage from "../../../pages/LoginPage";

let loginPage = null;
let homePage = null;
let adminPage = null;
let globalMenuConfigPage = null;

before(() => {
// Initialize LoginPage object and navigate to Admin Page
loginPage = new LoginPage();
loginPage.visit();

homePage = loginPage.goToHomePage();
adminPage = homePage.goToAdminPage();
});

describe("Global Menu Configuration", function () {
it("User navigates to the Global Menu Configuration page", function () {
globalMenuConfigPage = adminPage.goToGlobalMenuConfigPage();
});

it("User turns 0ff the toggle switch and submits", function () {
globalMenuConfigPage.turnOffToggleSwitch();
globalMenuConfigPage.submitButton();
});

it("User turns on the toggle switch", function () {
globalMenuConfigPage.turnOnToggleSwitch();
});
it("User checks the menu items and submits", function () {
globalMenuConfigPage.checkMenuItem("home");
globalMenuConfigPage.checkMenuItem("order");
globalMenuConfigPage.checkMenuItem("billing");
globalMenuConfigPage.checkMenuItem("immunoChem");
globalMenuConfigPage.checkMenuItem("cytology");
globalMenuConfigPage.checkMenuItem("results");
globalMenuConfigPage.checkMenuItem("validation");
globalMenuConfigPage.checkMenuItem("patient");
globalMenuConfigPage.checkMenuItem("pathology");
globalMenuConfigPage.checkMenuItem("workplan");
globalMenuConfigPage.checkMenuItem("nonConform");
globalMenuConfigPage.checkMenuItem("reports");
globalMenuConfigPage.checkMenuItem("study");
globalMenuConfigPage.checkMenuItem("admin");
globalMenuConfigPage.checkMenuItem("help");
globalMenuConfigPage.submitButton();
});
it("User relogs in to verify the menu changes", function () {
// Initialize LoginPage object and navigate to the menu
loginPage = new LoginPage();
loginPage.visit();

homePage = loginPage.goToHomePage();
globalMenuConfigPage = homePage.openNavigationMenu();
});
});
34 changes: 21 additions & 13 deletions frontend/cypress/pages/AdminPage.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
//This handles all pages of the admin
import LabNumberManagementPage from "./LabNumberManagementPage";
import GlobalMenuConfigPage from "./GlobalMenuConfigPage";

class AdminPage {
constructor() {}

visit() {
cy.visit("/administration"); //need to confirm this
}
//this page is also included in the homepage
goToAdminPage() {
this.openNavigationMenu();
cy.get("#menu_administration").click();
cy.get("#menu_administration_nav").click();
return new AdminPage();
}

//lab number management
goToLabNumberManagementPage() {
// Click on the element using the provided selector
cy.get("a.cds--side-nav__link[href='#labNumber']")
.should("be.visible") // Ensure the element is visible
.click(); // Click to navigate to the page
.should("be.visible")
.click();

cy.url().should("include", "#labNumber");
cy.contains("Lab Number Management").should("be.visible");

return new LabNumberManagementPage();
}

//global menu configuration
goToGlobalMenuConfigPage() {
// Expand the dropdown by clicking the button with the expanded state
cy.contains("span", "Menu Configuration").click();
cy.get("ul.cds--side-nav__menu").should("be.visible"); // Ensure the dropdown menu is visible
// Click the link for "Global Menu Configuration"
cy.get('a.cds--side-nav__link[href="#globalMenuManagement"]').click(); // Click the "Global Menu Configuration" link

// Verify the URL or some unique identifier of the target page
cy.url().should("include", "#labNumber"); // Validate URL fragment
cy.contains("Lab Number Management").should("be.visible"); // Confirm presence of the page content
// Verify the URL and the visibility of the content
cy.url().should("include", "#globalMenuManagement");
cy.contains("Global Menu Management").should("be.visible");

return new LabNumberManagementPage(); // Return the page object
return new GlobalMenuConfigPage();
}
}

Expand Down
54 changes: 54 additions & 0 deletions frontend/cypress/pages/GlobalMenuConfigPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class GlobalMenuConfigPage {
constructor() {}

// This method is used to visit the page
visit() {
cy.visit("/administration#globalMenuManagement");
}

turnOffToggleSwitch() {
cy.get("div.cds--toggle__switch").click();
}

turnOnToggleSwitch() {
cy.get("div.cds--toggle label div > div").should("be.visible").click();
}

checkMenuItem = function (menuItem) {
// Map of menu items to their respective checkboxes
const menuItems = {
home: "#menu_home_checkbox",
order: "#menu_sample_checkbox",
immunoChem: "#menu_immunochem_checkbox",
cytology: "#menu_cytology_checkbox",
results: "#menu_results_checkbox",
validation: "#menu_resultvalidation_checkbox",
reports: "#menu_reports_checkbox",
study: "#menu_reports_study_checkbox",
billing: "#menu_billing_checkbox",
admin: "#menu_administration_checkbox",
help: "#menu_help_checkbox",
patient: "#menu_patient_checkbox",
nonConform: "#menu_nonconformity_checkbox",
workplan: "#menu_workplan_checkbox",
pathology: "#menu_pathology_checkbox",
};

// Get the corresponding checkbox selector based on the passed menuItem
const checkboxSelector = menuItems[menuItem];

if (checkboxSelector) {
// Perform the check action, forcing it to check even if covered
cy.get(checkboxSelector).check({ force: true });
} else {
// If no valid menuItem is passed, log an error
cy.log("Invalid menu item");
}
};

submitButton() {
cy.contains("button", "Submit").click();
}
}

export default GlobalMenuConfigPage;
1 change: 1 addition & 0 deletions frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class HomePage {
goToAdminPage() {
this.openNavigationMenu();
cy.get("#menu_administration").click();
//cy.get("#menu_administration_nav").click();
return new AdminPage();
}
}
Expand Down

0 comments on commit 827e2e9

Please sign in to comment.