From 0be342c119a6faa2b0f7cff84277cda5dd94a44e Mon Sep 17 00:00:00 2001 From: Brian308 Date: Mon, 13 Jan 2025 17:08:16 +0300 Subject: [PATCH] Added admin e2e --- frontend/cypress.config.js | 1 + frontend/cypress/e2e/admin.cy.js | 17 +++++++++++++++ frontend/cypress/fixtures/Admin.json | 4 ++++ frontend/cypress/fixtures/DashBoard.json | 3 +++ frontend/cypress/pages/AdminPage.js | 27 ++++++++++++++++++++++++ frontend/cypress/pages/HomePage.js | 7 ++++++ 6 files changed, 59 insertions(+) create mode 100644 frontend/cypress/e2e/admin.cy.js create mode 100644 frontend/cypress/fixtures/Admin.json create mode 100644 frontend/cypress/fixtures/DashBoard.json create mode 100644 frontend/cypress/pages/AdminPage.js diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index f5b9f83351..a48c23a42a 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -20,6 +20,7 @@ module.exports = defineConfig({ "cypress/e2e/report.cy.js", "cypress/e2e/batchOrderEntry.cy.js", "cypress/e2e/dashboard.cy.js", + "cypress/e2e/admin.cy.js", ]; return config; }, diff --git a/frontend/cypress/e2e/admin.cy.js b/frontend/cypress/e2e/admin.cy.js new file mode 100644 index 0000000000..a3be6e3e50 --- /dev/null +++ b/frontend/cypress/e2e/admin.cy.js @@ -0,0 +1,17 @@ +import LoginPage from "../pages/LoginPage"; + +let homePage = null; +let loginPage = null; +let adminPage = null; + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Admin Component Menu", function () { + it("User navigates to the Admin Component Menu", function () { + homePage = loginPage.goToHomePage(); + adminPage = homePage.goToAdminPage(); + }); +}); diff --git a/frontend/cypress/fixtures/Admin.json b/frontend/cypress/fixtures/Admin.json new file mode 100644 index 0000000000..c171ff7f73 --- /dev/null +++ b/frontend/cypress/fixtures/Admin.json @@ -0,0 +1,4 @@ +{ + "username": "admin", + "password": "adminADMIN!" +} diff --git a/frontend/cypress/fixtures/DashBoard.json b/frontend/cypress/fixtures/DashBoard.json new file mode 100644 index 0000000000..7d8d4a4cb4 --- /dev/null +++ b/frontend/cypress/fixtures/DashBoard.json @@ -0,0 +1,3 @@ +{ + "labNo": "DEV01250000000000087" +} diff --git a/frontend/cypress/pages/AdminPage.js b/frontend/cypress/pages/AdminPage.js new file mode 100644 index 0000000000..a7f5cbcf14 --- /dev/null +++ b/frontend/cypress/pages/AdminPage.js @@ -0,0 +1,27 @@ +class AdminPage { + visit() { + cy.visit("/admin"); + } + + getHeader() { + return cy.get("h1"); + } + + // Add more methods to interact with elements on the admin page as needed + clickSomeAdminButton() { + return cy.get("#someAdminButton").click(); + } + + // Example method to verify an element on the admin page + verifyAdminElement() { + return cy.get("#adminElement").should("be.visible"); + } + goToAdminPage() { + this.openNavigationMenu(); + cy.get("#menu_admin").click(); + cy.get("#menu_admin_nav").click(); + return new AdminPage(); + } +} + +export default AdminPage; diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index dfedb13fc3..ff7c338a7c 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -12,6 +12,7 @@ import RoutineReportPage from "./RoutineReportPage"; import StudyReportPage from "./StudyReportPage"; import DashBoardPage from "./DashBoard"; +import AdminPage from "./AdminPage"; class HomePage { constructor() {} @@ -192,6 +193,12 @@ class HomePage { cy.get("#menu_immunochemdashboard_nav").click(); return new DashBoardPage(); } + + goToAdminPage() { + this.openNavigationMenu(); + cy.get("#menu_administration").click(); + return new AdminPage(); + } } export default HomePage;