From 53b72be9946b46cec78695363709c89454965c5e Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:54:33 +0530 Subject: [PATCH] New Cypress Test | Modify Facility Doctor Capacity | Facility Module (#7054) * modify doctor capacity * convert to POM --- .../e2e/facility_spec/facility_manage.cy.ts | 28 +++++++++++++++++++ .../pageobject/Facility/FacilityCreation.ts | 2 +- cypress/pageobject/Facility/FacilityManage.ts | 17 +++++++++++ src/Components/Facility/DoctorsCountCard.tsx | 2 ++ .../Facility/FacilityDoctorList.tsx | 7 +++-- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts index 67439e636dd..cebe550323a 100644 --- a/cypress/e2e/facility_spec/facility_manage.cy.ts +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -18,6 +18,8 @@ describe("Facility Manage Functions", () => { "Health Facility config updated successfully"; const facilityHrfId = uuidv4(); const facilityUpdatedHrfId = uuidv4(); + const doctorCapacity = "5"; + const doctorModifiedCapacity = "7"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -98,6 +100,32 @@ describe("Facility Manage Functions", () => { facilityManage.verifyHrfIdValue(facilityUpdatedHrfId); }); + it("Modify doctor capacity in Facility detail page", () => { + // Add a doctor capacity + facilityManage.clickFacilityAddDoctorTypeButton(); + facilityPage.selectAreaOfSpecialization("General Medicine"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.saveAndExitDoctorForm(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor count added successfully" + ); + facilityManage.verifyTotalDoctorCapacity(doctorCapacity); + // edit a existing doctor + facilityManage.clickEditFacilityDoctorCapacity(); + facilityPage.fillDoctorCount(doctorModifiedCapacity); + facilityPage.clickdoctorcapacityaddmore(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor count updated successfully" + ); + facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity); + // delete a bed + facilityManage.clickDeleteFacilityDoctorCapacity(); + facilityManage.clickButtonWithText("Delete"); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor specialization type deleted successfully" + ); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 4297179050b..e4c3a1207d7 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -96,7 +96,7 @@ class FacilityPage { } fillDoctorCount(count: string) { - cy.get("input#count").click().type(count); + cy.get("input#count").click().clear().click().type(count); } fillOxygenCapacity(capacity: string) { diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts index a7eab2884b4..6783168e1bf 100644 --- a/cypress/pageobject/Facility/FacilityManage.ts +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -13,6 +13,18 @@ class FacilityManage { .wait(100); // Adjust the wait time as needed } + verifyTotalDoctorCapacity(expectedCapacity) { + cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity); + } + + clickEditFacilityDoctorCapacity() { + cy.get("#edit-facility-doctorcapacity").click(); + } + + clickDeleteFacilityDoctorCapacity() { + cy.get("#delete-facility-doctorcapacity").click(); + } + clickSaveCoverImage() { cy.get("#save-cover-image").scrollIntoView(); cy.get("#save-cover-image").click(); @@ -54,5 +66,10 @@ class FacilityManage { verifyHrfIdValue(expectedValue) { cy.get("#hf_id").should("have.value", expectedValue); } + + clickFacilityAddDoctorTypeButton() { + cy.get("#facility-add-doctortype").scrollIntoView(); + cy.get("#facility-add-doctortype").click(); + } } export default FacilityManage; diff --git a/src/Components/Facility/DoctorsCountCard.tsx b/src/Components/Facility/DoctorsCountCard.tsx index ee15d7a2c9d..5c90918cb7d 100644 --- a/src/Components/Facility/DoctorsCountCard.tsx +++ b/src/Components/Facility/DoctorsCountCard.tsx @@ -64,6 +64,7 @@ const DoctorsCountCard = (props: DoctorsCountProps) => {