From bdd55c3a81de15726002d912c2c27056d1f0ff4b Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 9 Oct 2024 15:10:29 +0100 Subject: [PATCH] chore: Add e2e tests --- .../hospital/edit_hospital.cy.ts | 48 +++++++++++++++++++ .../hospital/hospitalForm/HospitalForm.tsx | 10 +++- .../admin/hospital/hospitalForm/styles.scss | 2 +- src/components/accessories/button/Button.tsx | 2 + src/components/accessories/button/types.ts | 4 +- .../accessories/menuItem/MenuItem.tsx | 3 ++ .../adminActivity/SideMenu/SideMenu.tsx | 4 +- src/routes/Admin/AdminRoutes.tsx | 2 +- 8 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 cypress/integrations/admin_activities/hospital/edit_hospital.cy.ts diff --git a/cypress/integrations/admin_activities/hospital/edit_hospital.cy.ts b/cypress/integrations/admin_activities/hospital/edit_hospital.cy.ts new file mode 100644 index 000000000..389641541 --- /dev/null +++ b/cypress/integrations/admin_activities/hospital/edit_hospital.cy.ts @@ -0,0 +1,48 @@ +/// + +const STARTS_PATH = "/admin"; + +describe("Edit Hospital Activity specs", () => { + it("should render the ui", () => { + cy.authenticate(STARTS_PATH); + cy.dataCy("hospital-infos").click(); + cy.dataCy("edit-hospital").click(); + cy.dataCy("activity-title").contains("Edit hospital"); + }); + + it("should fail to edit the hospitalInfo", () => { + cy.byId("description").clear().type("FAIL"); + cy.byId("email").clear().type("luke@hospital.com"); + cy.dataCy("submit-form").click(); + cy.dataCy("dialog-info").should("not.exist"); + cy.dataCy("info-box").contains("Invalid payload"); + }); + + it("should successfully save hospital infos changes", () => { + cy.byId("description").clear().type("St. LUKE Hospital"); + cy.byId("email").clear().type("luke@hospital.com"); + cy.byId("currencyCod").clear().type("FCFA"); + cy.dataCy("submit-form").click(); + cy.dataCy("dialog-info").contains("updated successfully"); + cy.dataCy("approve-dialog").click(); + }); + + it("should redirect after hospital info update", () => { + cy.dataCy("activity-title").contains("Wards"); + }); + + it("should cancel the discard of the hospital infos", () => { + cy.dataCy("edit-hospital").first().click(); + cy.dataCy("cancel-form").click(); + cy.dataCy("dialog-info").contains("lost"); + cy.dataCy("close-dialog").click().click(); + cy.dataCy("dialog-info").should("not.be.visible"); + }); + + it("should cancel the update of the hospital infos", () => { + cy.dataCy("cancel-form").click(); + cy.dataCy("dialog-info").contains("lost"); + cy.dataCy("approve-dialog").click(); + cy.dataCy("activity-title").contains("Wards"); + }); +}); diff --git a/src/components/accessories/admin/hospital/hospitalForm/HospitalForm.tsx b/src/components/accessories/admin/hospital/hospitalForm/HospitalForm.tsx index ab6c204b0..f13e8884e 100644 --- a/src/components/accessories/admin/hospital/hospitalForm/HospitalForm.tsx +++ b/src/components/accessories/admin/hospital/hospitalForm/HospitalForm.tsx @@ -177,14 +177,20 @@ const HospitalForm: FC = ({
-
-
+