diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index a48f5dd3f..f8c3f9b81 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -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; }, diff --git a/frontend/cypress/e2e/AdminE2E/MenuConfig/globalMenuConfig.cy.js b/frontend/cypress/e2e/AdminE2E/MenuConfig/globalMenuConfig.cy.js new file mode 100644 index 000000000..270f8784b --- /dev/null +++ b/frontend/cypress/e2e/AdminE2E/MenuConfig/globalMenuConfig.cy.js @@ -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(); + }); +}); diff --git a/frontend/cypress/pages/AdminPage.js b/frontend/cypress/pages/AdminPage.js index 0d059f1a0..42574ab6c 100644 --- a/frontend/cypress/pages/AdminPage.js +++ b/frontend/cypress/pages/AdminPage.js @@ -1,5 +1,6 @@ //This handles all pages of the admin import LabNumberManagementPage from "./LabNumberManagementPage"; +import GlobalMenuConfigPage from "./GlobalMenuConfigPage"; class AdminPage { constructor() {} @@ -7,26 +8,33 @@ class AdminPage { 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(); } } diff --git a/frontend/cypress/pages/GlobalMenuConfigPage.js b/frontend/cypress/pages/GlobalMenuConfigPage.js new file mode 100644 index 000000000..2bb95abcb --- /dev/null +++ b/frontend/cypress/pages/GlobalMenuConfigPage.js @@ -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; diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index ff7c338a7..9def37f26 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -197,6 +197,7 @@ class HomePage { goToAdminPage() { this.openNavigationMenu(); cy.get("#menu_administration").click(); + //cy.get("#menu_administration_nav").click(); return new AdminPage(); } }