Skip to content

Commit

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

* facility bed capacity

* bug fix
  • Loading branch information
nihal467 authored Jan 18, 2024
1 parent 53b72be commit cee0aef
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
34 changes: 34 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ describe("Facility Manage Functions", () => {
const facilityUpdatedHrfId = uuidv4();
const doctorCapacity = "5";
const doctorModifiedCapacity = "7";
const totalCapacity = "100";
const currentOccupied = "80";
const totalUpdatedCapacity = "120";
const currentUpdatedOccupied = "100";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand Down Expand Up @@ -126,6 +130,36 @@ describe("Facility Manage Functions", () => {
);
});

it("Modify bed capacity in Facility detail page", () => {
// add multiple new bed capacity
facilityManage.clickFacilityAddBedTypeButton();
facilityPage.selectBedType("Oxygen beds");
facilityPage.fillTotalCapacity(totalCapacity);
facilityPage.fillCurrentlyOccupied(currentOccupied);
facilityPage.saveAndExitBedCapacityForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity added successfully"
);
facilityManage.verifyFacilityBedCapacity(totalCapacity);
facilityManage.verifyFacilityBedCapacity(currentOccupied);
// edit a existing bed
facilityManage.clickEditFacilityBedCapacity();
facilityPage.fillTotalCapacity(totalUpdatedCapacity);
facilityPage.fillCurrentlyOccupied(currentUpdatedOccupied);
facilityPage.clickbedcapcityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity updated successfully"
);
facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity);
facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied);
// delete a bed
facilityManage.clickDeleteFacilityBedCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed type deleted successfully"
);
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class FacilityPage {
}

fillTotalCapacity(capacity: string) {
cy.get("input#total-capacity").click().type(capacity);
cy.get("input#total-capacity").click().clear().click().type(capacity);
}

fillCurrentlyOccupied(occupied: string) {
cy.get("input#currently-occupied").click().type(occupied);
cy.get("input#currently-occupied").click().clear().click().type(occupied);
}

saveAndExitBedCapacityForm() {
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 @@ -17,14 +17,26 @@ class FacilityManage {
cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity);
}

verifyFacilityBedCapacity(expectedCapacity) {
cy.get("#facility-bed-capacity-details").contains(expectedCapacity);
}

clickEditFacilityDoctorCapacity() {
cy.get("#edit-facility-doctorcapacity").click();
}

clickEditFacilityBedCapacity() {
cy.get("#edit-facility-bedcapacity").click();
}

clickDeleteFacilityDoctorCapacity() {
cy.get("#delete-facility-doctorcapacity").click();
}

clickDeleteFacilityBedCapacity() {
cy.get("#delete-facility-bedcapacity").click();
}

clickSaveCoverImage() {
cy.get("#save-cover-image").scrollIntoView();
cy.get("#save-cover-image").click();
Expand Down Expand Up @@ -71,5 +83,10 @@ class FacilityManage {
cy.get("#facility-add-doctortype").scrollIntoView();
cy.get("#facility-add-doctortype").click();
}

clickFacilityAddBedTypeButton() {
cy.get("#facility-add-bedtype").scrollIntoView();
cy.get("#facility-add-bedtype").click();
}
}
export default FacilityManage;
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PatientConsultationPage {
cy.get("#icd11-search input[role='combobox']")
.scrollIntoView()
.click()
.type("1A");
.type("1A00");
cy.get("#icd11-search [role='option']")
.contains("1A00 Cholera")
.scrollIntoView()
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Facility/BedTypeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const BedTypeCard: React.FC<BedTypeCardProps> = ({
</div>
<div className="flex items-stretch justify-between gap-4 self-stretch">
<ButtonV2
id="edit-facility-bedcapacity"
onClick={() => {
setSelectedId(room_type || 0);
setOpen(true);
Expand All @@ -125,6 +126,7 @@ export const BedTypeCard: React.FC<BedTypeCardProps> = ({
</ButtonV2>

<ButtonV2
id="delete-facility-bedcapacity"
onClick={() => setOpenDeleteDialog(true)}
authorizeFor={NonReadOnlyUsers}
className=" tooltip bg-opacity/10 flex aspect-square h-7 w-7 flex-col items-center justify-center rounded bg-red-100 px-4 py-0 hover:bg-red-200"
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/FacilityBedCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const FacilityBedCapacity = (props: any) => {
<div className="justify-between md:flex md:pb-2">
<div className="mb-2 text-xl font-semibold">Bed Capacity</div>
<ButtonV2
id="facility-add-bedtype"
className="w-full md:w-auto"
onClick={() => setBedCapacityModalOpen(true)}
authorizeFor={NonReadOnlyUsers}
Expand Down

0 comments on commit cee0aef

Please sign in to comment.