Skip to content

Commit

Permalink
New Cypress Test | Modify Facility Doctor Capacity | Facility Module (#…
Browse files Browse the repository at this point in the history
…7054)

* modify doctor capacity

* convert to POM
  • Loading branch information
nihal467 authored Jan 18, 2024
1 parent df758d2 commit 53b72be
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
28 changes: 28 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 17 additions & 0 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
2 changes: 2 additions & 0 deletions src/Components/Facility/DoctorsCountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const DoctorsCountCard = (props: DoctorsCountProps) => {
</div>
<div className="flex justify-end gap-4 border-t border-[#D2D6DC] bg-[#FBF9FB] px-3 py-2">
<ButtonV2
id="edit-facility-doctorcapacity"
variant="secondary"
ghost
onClick={() => {
Expand All @@ -75,6 +76,7 @@ const DoctorsCountCard = (props: DoctorsCountProps) => {
Edit
</ButtonV2>
<ButtonV2
id="delete-facility-doctorcapacity"
variant="danger"
ghost
onClick={() => setOpenDeleteDialog(true)}
Expand Down
7 changes: 5 additions & 2 deletions src/Components/Facility/FacilityDoctorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const FacilityDoctorList = (props: any) => {
<div className="rounded-full bg-primary-500 p-4">
<DoctorIcon className="h-5 w-5 fill-current text-white" />
</div>
<div>
<div id="facility-doctor-totalcapacity">
<div className="text-sm font-medium text-[#808080]">
Total Doctors
</div>
Expand Down Expand Up @@ -88,6 +88,7 @@ export const FacilityDoctorList = (props: any) => {
<div className="justify-between md:flex md:pb-2">
<div className="mb-2 text-xl font-bold">Doctors List</div>
<ButtonV2
id="facility-add-doctortype"
className="w-full md:w-auto"
onClick={() => setDoctorCapacityModalOpen(true)}
disabled={doctorList.length === DOCTOR_SPECIALIZATION.length}
Expand All @@ -97,7 +98,9 @@ export const FacilityDoctorList = (props: any) => {
Add Doctor Types
</ButtonV2>
</div>
<div className="mt-4">{doctorList}</div>
<div className="mt-4" id="facility-totaldoctor-capacity">
{doctorList}
</div>
</div>

{doctorCapacityModalOpen && (
Expand Down

0 comments on commit 53b72be

Please sign in to comment.