Skip to content

Commit

Permalink
Merge branch 'develop' into issue/9367/add_address_for_linked_facility
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaJ2305 authored Dec 11, 2024
2 parents 929c2ca + 05d89f4 commit c0e56c0
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 128 deletions.
156 changes: 101 additions & 55 deletions cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { advanceFilters } from "pageobject/utils/advanceFilterHelpers";

import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityPage, {
FacilityData,
} from "../../pageobject/Facility/FacilityCreation";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import LoginPage from "../../pageobject/Login/LoginPage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
Expand Down Expand Up @@ -59,6 +61,61 @@ describe("Facility Creation", () => {
];
const triageErrorMessage = ["This field is required"];
const facilityType = "Primary Health Centres";
const testFacilityData: FacilityData = {
basic: {
name: facilityName,
type: facilityType,
features: facilityFeature,
address: facilityAddress,
phoneNumber: facilityNumber,
location: "Kochi, Kerala",
},
location: {
pincode: "682001",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
ward: "4",
},
oxygen: {
capacity: oxygenCapacity,
expected: oxygenExpected,
bType: {
capacity: oxygenCapacity,
expected: oxygenExpected,
},
cType: {
capacity: oxygenCapacity,
expected: oxygenExpected,
},
dType: {
capacity: oxygenCapacity,
expected: oxygenExpected,
},
},
beds: [
{
type: "Oxygen Supported Bed",
totalCapacity: bedCapacity,
occupied: bedOccupancy,
},
{
type: "Ordinary Bed",
totalCapacity: bedCapacity,
occupied: bedOccupancy,
},
],
doctors: [
{
specialization: "General Medicine",
count: doctorCapacity,
},
{
specialization: "Pulmonology",
count: doctorCapacity,
},
],
};

before(() => {
loginPage.loginByRole("districtAdmin");
Expand Down Expand Up @@ -122,32 +179,12 @@ describe("Facility Creation", () => {
facilityPage.visitCreateFacilityPage();
facilityPage.submitForm();
cy.verifyErrorMessages(facilityErrorMessage);
facilityPage.fillFacilityName(facilityName);
facilityPage.selectFacilityType(facilityType);
facilityPage.clickfacilityfeatureoption();
facilityFeature.forEach((featureText) => {
cy.get("[role='option']").contains(featureText).click();
});
facilityPage.clickfacilityfeatureoption();
facilityPage.fillPincode("682001");
facilityPage.selectStateOnPincode("Kerala");
facilityPage.selectDistrictOnPincode("Ernakulam");
facilityPage.selectLocalBody("Aluva");
facilityPage.selectWard("4");
facilityPage.fillAddress(facilityAddress);
facilityPage.fillPhoneNumber(facilityNumber);
facilityPage.fillOxygenCapacity(oxygenCapacity);
facilityPage.fillExpectedOxygenRequirement(oxygenExpected);
facilityPage.fillBTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedBTypeCylinderRequirement(oxygenExpected);
facilityPage.fillCTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedCTypeCylinderRequirement(oxygenExpected);
facilityPage.fillDTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedDTypeCylinderRequirement(oxygenExpected);
facilityPage.selectLocation("Kochi, Kerala");
facilityPage.fillBasicDetails(testFacilityData.basic);
facilityPage.fillLocationDetails(testFacilityData.location);
facilityPage.fillOxygenDetails(testFacilityData.oxygen);
facilityPage.submitForm();
cy.closeNotification();
// create multiple bed capacity and verify card reflection
// add the bed capacity
facilityPage.selectBedType("Oxygen Supported Bed");
facilityPage.fillTotalCapacity(bedCapacity);
facilityPage.fillCurrentlyOccupied(bedOccupancy);
Expand Down Expand Up @@ -210,27 +247,32 @@ describe("Facility Creation", () => {
});

it("Create a new facility with single bed and doctor capacity", () => {
facilityPage.visitCreateFacilityPage();
facilityPage.fillFacilityName(facilityName);
facilityPage.selectFacilityType(facilityType);
facilityPage.fillPincode("682001");
facilityPage.selectStateOnPincode("Kerala");
facilityPage.selectDistrictOnPincode("Ernakulam");
facilityPage.selectLocalBody("Aluva");
facilityPage.selectWard("4");
facilityPage.fillAddress(facilityAddress);
facilityPage.fillPhoneNumber(facilityNumber);
facilityPage.submitForm();
// add the bed capacity
facilityPage.selectBedType("Oxygen Supported Bed");
facilityPage.fillTotalCapacity(oxygenCapacity);
facilityPage.fillCurrentlyOccupied(oxygenExpected);
facilityPage.saveAndExitBedCapacityForm();
// add the doctor capacity
facilityPage.selectAreaOfSpecialization("General Medicine");
facilityPage.fillDoctorCount(doctorCapacity);
facilityPage.saveAndExitDoctorForm();
facilityPage.verifyfacilitynewurl();
const singleCapacityData = {
...testFacilityData,
// Remove features, location, and oxygen that aren't used in this test
basic: {
...testFacilityData.basic,
features: undefined,
location: undefined,
},
oxygen: undefined,
// Override with single bed capacity
beds: [
{
type: "Oxygen Supported Bed",
totalCapacity: oxygenCapacity,
occupied: oxygenExpected,
},
],
// Override with single doctor capacity
doctors: [
{
specialization: "General Medicine",
count: doctorCapacity,
},
],
};
facilityPage.createNewFacility(singleCapacityData);
// verify the created facility details
facilityPage.getFacilityName().contains(facilityName).should("be.visible");
facilityPage
Expand All @@ -254,16 +296,20 @@ describe("Facility Creation", () => {
});

it("Create a new facility with no bed and doctor capacity", () => {
const noCapacityData = {
...testFacilityData,
basic: {
...testFacilityData.basic,
features: undefined,
location: undefined,
},
oxygen: undefined,
beds: [],
doctors: [],
};
facilityPage.visitCreateFacilityPage();
facilityPage.fillFacilityName(facilityName);
facilityPage.selectFacilityType(facilityType);
facilityPage.fillPincode("682001");
facilityPage.selectStateOnPincode("Kerala");
facilityPage.selectDistrictOnPincode("Ernakulam");
facilityPage.selectLocalBody("Aluva");
facilityPage.selectWard("4");
facilityPage.fillAddress(facilityAddress);
facilityPage.fillPhoneNumber(facilityNumber);
facilityPage.fillBasicDetails(noCapacityData.basic);
facilityPage.fillLocationDetails(noCapacityData.location);
facilityPage.submitForm();
// add no bed capacity and verify form error message
facilityPage.isVisibleselectBedType();
Expand Down
59 changes: 59 additions & 0 deletions cypress/e2e/facility_spec/FacilityHomepage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// FacilityCreation
import FacilityLocation from "pageobject/Facility/FacilityLocation";
import { PatientPage } from "pageobject/Patient/PatientCreation";
import PatientPredefined from "pageobject/Patient/PatientPredefined";
import { pageNavigation } from "pageobject/utils/paginationHelpers";

import FacilityPage from "../../pageobject/Facility/FacilityCreation";
Expand All @@ -14,6 +17,9 @@ describe("Facility Homepage Function", () => {
const facilityNotify = new FacilityNotify();
const facilityPage = new FacilityPage();
const manageUserPage = new ManageUserPage();
const patientPredefined = new PatientPredefined();
const patientPage = new PatientPage();
const facilityLocation = new FacilityLocation();
const facilitiesAlias = "downloadFacilitiesCSV";
const doctorsAlias = "downloadDoctorsCSV";
const triagesAlias = "downloadTriagesCSV";
Expand All @@ -25,13 +31,17 @@ describe("Facility Homepage Function", () => {
const facilityType = "Private Hospital";
const notificationErrorMsg = "Message cannot be empty";
const notificationMessage = "Test Notification";
const facilityWithNoAvailableBeds = "Dummy Facility 12";
const locationName = "Test-location";
const locationType = "WARD";

before(() => {
loginPage.loginByRole("districtAdmin");
cy.saveLocalStorage();
});

beforeEach(() => {
cy.viewport(1280, 720);
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/facility");
Expand Down Expand Up @@ -199,6 +209,55 @@ describe("Facility Homepage Function", () => {
facilityNotify.closeNotificationSlide();
loginPage.ensureLoggedIn();
loginPage.clickSignOutBtn();
loginPage.loginManuallyAsDistrictAdmin();
loginPage.ensureLoggedIn();
});

it("Verify the bed capacity badge reflection", () => {
facilityHome.typeFacilitySearch(facilityWithNoAvailableBeds);
facilityHome.assertFacilityInCard(facilityWithNoAvailableBeds);
cy.url().then((url) => {
const facilityUrl = url.toString();
facilityHome.verifyOccupancyBadgeVisibility();
facilityHome.assertFacilityBadgeContent("0", "0");

// create a new patient in the facility
cy.visit("/patients");
patientPage.createPatient();
patientPage.selectFacility(facilityWithNoAvailableBeds);
patientPredefined.createPatient();
patientPage.patientformvisibility();
patientPage.clickCreatePatient();
patientPage.verifyPatientIsCreated();
// navigate to facility page and verify the occupancy badge
cy.visit(facilityUrl);
facilityHome.verifyOccupancyBadgeVisibility();
facilityHome.assertFacilityBadgeContent("1", "0");
facilityHome.assertFacilityBadgeBackgroundColor("rgb(239, 68, 68)");
// create a new location and add a bed to the facility
facilityLocation.navigateToFacilityLocationManagement(
facilityWithNoAvailableBeds,
);
// create new location and add a bed to the facility
facilityLocation.clickAddNewLocationButton();
facilityLocation.fillLocationDetails(
locationName,
undefined,
locationType,
undefined,
);
facilityLocation.clickAddLocationButton();
facilityLocation.verifyAddLocationSuccessfulMesssage();
facilityLocation.clickManageBedButton(locationName);
facilityLocation.clickAddBedButton();
facilityLocation.fillBedForm("Bed 1", "Test Description", "Regular", 2);
facilityLocation.clickSubmitBedsButton();

// verify the occupancy badge reflection
cy.visit(facilityUrl);
facilityHome.verifyOccupancyBadgeVisibility();
facilityHome.assertFacilityBadgeContent("1", "2");
});
});

afterEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("Patient Consultation in multiple combination", () => {
patientTreatmentPlan.typeTreatmentPlan(patientTreatment);
patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction);
patientTreatmentPlan.typeSpecialInstruction(specialInstruction);
patientTreatmentPlan.fillTreatingPhysican(doctorName);
patientTreatmentPlan.fillTreatingPhysician(doctorName);
cy.clickSubmitButton("Create Consultation");
// the above submit should fail as IP number is missing
patientConsultationPage.typePatientNumber(patientIpNumber);
Expand Down Expand Up @@ -254,7 +254,7 @@ describe("Patient Consultation in multiple combination", () => {
patientInvestigation.selectInvestigationFrequency("6");
// Add advice and treating physican
patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction);
patientTreatmentPlan.fillTreatingPhysican(doctorName);
patientTreatmentPlan.fillTreatingPhysician(doctorName);
// add review after and add action
patientTreatmentPlan.selectReviewAfter("15 mins");
patientTreatmentPlan.selectAction("Specialist Required");
Expand Down Expand Up @@ -311,7 +311,7 @@ describe("Patient Consultation in multiple combination", () => {
// no investigation
patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction);
// no review after and no action
patientTreatmentPlan.fillTreatingPhysican(doctorName);
patientTreatmentPlan.fillTreatingPhysician(doctorName);
cy.clickSubmitButton("Create Consultation");
cy.verifyNotification("Patient discharged successfully");
// verify the Discharge Reason, Diagnosis, treatment physican
Expand Down Expand Up @@ -362,7 +362,7 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.selectPatientPrincipalDiagnosis(diagnosis4);
// no investigation for the patient
patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction);
patientTreatmentPlan.fillTreatingPhysican(doctorName);
patientTreatmentPlan.fillTreatingPhysician(doctorName);
// no review after and no action
cy.clickSubmitButton("Create Consultation");
// Create a shifting request
Expand Down
Loading

0 comments on commit c0e56c0

Please sign in to comment.