diff --git a/README.md b/README.md index 002afc979bc..a6a2806558d 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Once the development server has started, open [localhost:4000](http://localhost: Authenticate to staging API with any of the following credentials ```yaml -- username: devdistrictadmin +- username: dev-districtadmin password: Coronasafe@123 role: District Admin diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts deleted file mode 100644 index da06c65ed53..00000000000 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ /dev/null @@ -1,82 +0,0 @@ -// FacilityCreation -import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; -import FacilityPage from "../../pageobject/Facility/FacilityCreation"; -import LoginPage from "../../pageobject/Login/LoginPage"; - -describe("Facility Creation", () => { - let facilityUrl: string; - const facilityPage = new FacilityPage(); - const loginPage = new LoginPage(); - - before(() => { - loginPage.loginAsDisctrictAdmin(); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.viewport(1280, 720); - cy.restoreLocalStorage(); - cy.awaitUrl("/facility"); - }); - - it("Create a new facility", () => { - facilityPage.visitCreateFacilityPage(); - facilityPage.fillFacilityName("cypress facility"); - facilityPage.fillPincode("682001"); - facilityPage.selectState("Kerala"); - facilityPage.selectDistrict("Ernakulam"); - facilityPage.selectLocalBody("Aluva"); - facilityPage.selectWard("4"); - facilityPage.fillAddress("Cypress Address"); - facilityPage.fillPhoneNumber("9898469865"); - facilityPage.submitForm(); - - facilityPage.selectBedType("Oxygen beds"); - facilityPage.fillTotalCapacity("10"); - facilityPage.fillCurrentlyOccupied("5"); - facilityPage.saveAndExitBedCapacityForm(); - - facilityPage.selectAreaOfSpecialization("General Medicine"); - facilityPage.fillDoctorCount("5"); - facilityPage.saveAndExitDoctorForm(); - facilityPage.verifyfacilitynewurl(); - cy.url().then((newUrl) => { - facilityUrl = newUrl; - }); - }); - - it("Update the existing facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickUpdateFacilityOption(); - facilityPage.clickUpdateFacilityType("Request Approving Center"); - facilityPage.fillFacilityName("cypress facility updated"); - facilityPage.fillAddress("Cypress Facility Updated Address"); - facilityPage.fillOxygenCapacity("100"); - facilityPage.fillExpectedOxygenRequirement("80"); - facilityPage.selectLocation("Kochi, Kerala"); - facilityPage.submitForm(); - - cy.url().should("not.include", "/update"); - }); - - it("Configure the existing facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickConfigureFacilityOption(); - facilityPage.fillMiddleWareAddress("dev_middleware.coronasafe.live"); - facilityPage.clickupdateMiddleWare(); - facilityPage.verifySuccessNotification("Facility updated successfully"); - }); - - it("Delete a facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickDeleteFacilityOption(); - facilityPage.confirmDeleteFacility(); - }); - - afterEach(() => { - cy.saveLocalStorage(); - }); -}); diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts new file mode 100644 index 00000000000..d43aa093a69 --- /dev/null +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -0,0 +1,245 @@ +// FacilityCreation +import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import FacilityHome from "../../pageobject/Facility/FacilityHome"; +import ManageUserPage from "../../pageobject/Users/ManageUserPage"; +import { UserCreationPage } from "../../pageobject/Users/UserCreation"; + +describe("Facility Creation", () => { + let facilityUrl1: string; + const facilityPage = new FacilityPage(); + const loginPage = new LoginPage(); + const facilityHome = new FacilityHome(); + const manageUserPage = new ManageUserPage(); + const userCreationPage = new UserCreationPage(); + const facilityFeature = [ + "CT Scan", + "X-Ray", + "Maternity Care", + "Neonatal Care", + "Operation Theater", + "Blood Bank", + ]; + const bedCapacity = "10"; + const bedOccupancy = "5"; + const oxygenCapacity = "100"; + const oxygenExpected = "80"; + const totalCapacity = "20"; + const totalOccupancy = "10"; + const doctorCapacity = "5"; + const totalDoctor = "10"; + const facilityName = "cypress facility"; + const facilityAddress = "cypress address"; + const facilityNumber = "9898469865"; + const facilityErrorMessage = [ + "Required", + "Invalid Pincode", + "Required", + "Required", + "Required", + "Required", + "Required", + "Required", + "Invalid Phone Number", + ]; + const bedErrorMessage = [ + "Field is required", + "Total capacity cannot be 0", + "Field is required", + ]; + const doctorErrorMessage = ["Field is required", "Field is required"]; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.viewport(1280, 720); + cy.restoreLocalStorage(); + cy.awaitUrl("/facility"); + }); + + it("Create a new facility with multiple bed and doctor capacity", () => { + // create facility with multiple capacity and verify form error message for facility form + facilityPage.visitCreateFacilityPage(); + facilityPage.submitForm(); + userCreationPage.verifyErrorMessages(facilityErrorMessage); + facilityPage.fillFacilityName(facilityName); + facilityPage.clickfacilityfeatureoption(); + facilityFeature.forEach((featureText) => { + cy.get("[role='option']").contains(featureText).click(); + }); + facilityPage.fillPincode("682001"); + 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.submitForm(); + // create multiple bed capacity and verify card reflection + facilityPage.selectBedType("Oxygen beds"); + facilityPage.fillTotalCapacity(bedCapacity); + facilityPage.fillCurrentlyOccupied(bedOccupancy); + facilityPage.clickbedcapcityaddmore(); + facilityPage.selectBedType("Ordinary Bed"); + facilityPage.fillTotalCapacity(bedCapacity); + facilityPage.fillCurrentlyOccupied(bedOccupancy); + facilityPage.clickbedcapcityaddmore(); + facilityPage.getTotalBedCapacity().contains(totalCapacity); + facilityPage.getTotalBedCapacity().contains(totalOccupancy); + facilityPage.clickcancelbutton(); + // create multiple bed capacity and verify card reflection + facilityPage.selectAreaOfSpecialization("General Medicine"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.clickdoctorcapacityaddmore(); + facilityPage.selectAreaOfSpecialization("Pulmonology"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.clickdoctorcapacityaddmore(); + facilityPage.getTotalDoctorCapacity().contains(doctorCapacity); + facilityPage.clickcancelbutton(); + facilityPage.verifyfacilitynewurl(); + // verify the facility card + facilityPage.getFacilityName().contains(facilityName).should("be.visible"); + facilityPage + .getAddressDetailsView() + .contains(facilityAddress) + .should("be.visible"); + facilityPage + .getPhoneNumberView() + .contains(facilityNumber) + .should("be.visible"); + facilityPage + .getFacilityAvailableFeatures() + .invoke("text") + .then((text) => { + facilityFeature.forEach((feature) => { + expect(text).to.contain(feature); + }); + }); + facilityPage.getFacilityOxygenInfo().scrollIntoView(); + facilityPage + .getFacilityOxygenInfo() + .contains(oxygenCapacity) + .should("be.visible"); + facilityPage.getFacilityTotalBedCapacity().scrollIntoView(); + facilityPage.getFacilityTotalBedCapacity().contains(totalCapacity); + facilityPage.getFacilityTotalBedCapacity().contains(totalOccupancy); + facilityPage.getFacilityTotalDoctorCapacity().scrollIntoView(); + facilityPage.getFacilityTotalDoctorCapacity().contains(totalDoctor); + }); + + it("Create a new facility with single bed and doctor capacity", () => { + facilityPage.visitCreateFacilityPage(); + facilityPage.fillFacilityName(facilityName); + facilityPage.fillPincode("682001"); + facilityPage.selectLocalBody("Aluva"); + facilityPage.selectWard("4"); + facilityPage.fillAddress(facilityAddress); + facilityPage.fillPhoneNumber(facilityNumber); + facilityPage.submitForm(); + // add the bed capacity + facilityPage.selectBedType("Oxygen beds"); + facilityPage.fillTotalCapacity(oxygenCapacity); + facilityPage.fillCurrentlyOccupied(oxygenExpected); + facilityPage.saveAndExitBedCapacityForm(); + // add the doctor capacity + facilityPage.selectAreaOfSpecialization("General Medicine"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.saveAndExitDoctorForm(); + facilityPage.verifyfacilitynewurl(); + // verify the created facility details + facilityPage.getFacilityName().contains(facilityName).should("be.visible"); + facilityPage + .getAddressDetailsView() + .contains(facilityAddress) + .should("be.visible"); + facilityPage + .getPhoneNumberView() + .contains(facilityNumber) + .should("be.visible"); + // verify the facility homepage + cy.visit("/facility"); + manageUserPage.typeFacilitySearch(facilityName); + facilityPage.verifyFacilityBadgeContent(facilityName); + manageUserPage.assertFacilityInCard(facilityName); + facilityHome.verifyURLContains(facilityName); + }); + + it("Create a new facility with no bed and doctor capacity", () => { + facilityPage.visitCreateFacilityPage(); + facilityPage.fillFacilityName(facilityName); + facilityPage.fillPincode("682001"); + facilityPage.selectLocalBody("Aluva"); + facilityPage.selectWard("4"); + facilityPage.fillAddress(facilityAddress); + facilityPage.fillPhoneNumber(facilityNumber); + facilityPage.submitForm(); + // add no bed capacity and verify form error message + facilityPage.isVisibleselectBedType(); + facilityPage.saveAndExitBedCapacityForm(); + userCreationPage.verifyErrorMessages(bedErrorMessage); + facilityPage.clickcancelbutton(); + // add no doctor capacity and verify form error message + facilityPage.isVisibleAreaOfSpecialization(); + facilityPage.clickdoctorcapacityaddmore(); + userCreationPage.verifyErrorMessages(doctorErrorMessage); + facilityPage.clickcancelbutton(); + cy.url().then((newUrl) => { + facilityUrl1 = newUrl; + }); + // verify the created facility details + facilityPage.getFacilityName().contains(facilityName).should("be.visible"); + facilityPage + .getAddressDetailsView() + .contains(facilityAddress) + .should("be.visible"); + facilityPage + .getPhoneNumberView() + .contains(facilityNumber) + .should("be.visible"); + }); + + it("Update the existing facility", () => { + facilityPage.visitUpdateFacilityPage(facilityUrl1); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickUpdateFacilityOption(); + facilityPage.clickUpdateFacilityType("Request Approving Center"); + facilityPage.fillFacilityName("cypress facility updated"); + facilityPage.fillAddress("Cypress Facility Updated Address"); + facilityPage.fillOxygenCapacity("100"); + facilityPage.fillExpectedOxygenRequirement("80"); + facilityPage.selectLocation("Kochi, Kerala"); + facilityPage.submitForm(); + cy.url().should("not.include", "/update"); + }); + + it("Configure the existing facility", () => { + facilityPage.visitUpdateFacilityPage(facilityUrl1); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickConfigureFacilityOption(); + facilityPage.fillMiddleWareAddress("dev_middleware.coronasafe.live"); + facilityPage.clickupdateMiddleWare(); + facilityPage.verifySuccessNotification("Facility updated successfully"); + }); + + it("Delete a facility", () => { + facilityPage.visitUpdateFacilityPage(facilityUrl1); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickDeleteFacilityOption(); + facilityPage.confirmDeleteFacility(); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 8c20b808c98..b4d3808d645 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -70,6 +70,10 @@ class FacilityPage { cy.get("[role='option']").contains(bedType).click(); } + isVisibleselectBedType() { + cy.get("div#bed-type button").should("be.visible"); + } + fillTotalCapacity(capacity: string) { cy.get("input#total-capacity").click().type(capacity); } @@ -87,6 +91,10 @@ class FacilityPage { cy.get("[role='option']").contains(area).click(); } + isVisibleAreaOfSpecialization() { + cy.get("div#area-of-specialization button").should("be.visible"); + } + fillDoctorCount(count: string) { cy.get("input#count").click().type(count); } @@ -99,6 +107,33 @@ class FacilityPage { cy.get("#expected_oxygen_requirement").click().clear().type(requirement); } + fillBTypeCylinderCapacity(capacity: string) { + cy.get("#type_b_cylinders").click().clear().type(capacity); + } + + fillExpectedBTypeCylinderRequirement(requirement: string) { + cy.get("#expected_type_b_cylinders").focus().clear(); + cy.get("#expected_type_b_cylinders").focus().type(requirement); + } + + fillCTypeCylinderCapacity(capacity: string) { + cy.get("#type_c_cylinders").click().clear().type(capacity); + } + + fillExpectedCTypeCylinderRequirement(requirement: string) { + cy.get("#expected_type_c_cylinders").focus().clear(); + cy.get("#expected_type_c_cylinders").focus().type(requirement); + } + + fillDTypeCylinderCapacity(capacity: string) { + cy.get("#type_d_cylinders").click().clear().type(capacity); + } + + fillExpectedDTypeCylinderRequirement(requirement: string) { + cy.get("#expected_type_d_cylinders").focus().clear(); + cy.get("#expected_type_d_cylinders").focus().type(requirement); + } + saveAndExitDoctorForm() { cy.intercept("GET", "**/api/v1/facility/**").as("createFacilities"); cy.get("button#save-and-exit").click(); @@ -138,6 +173,42 @@ class FacilityPage { cy.get("#inventory-management").click(); } + getTotalBedCapacity() { + return cy.get("#total-bed-capacity"); + } + + getFacilityTotalBedCapacity() { + return cy.get("#facility-bed-capacity-details"); + } + + getFacilityTotalDoctorCapacity() { + return cy.get("#facility-doctor-capacity-details"); + } + + getTotalDoctorCapacity() { + return cy.get("#total-doctor-capacity"); + } + + getFacilityName() { + return cy.get("#facility-name"); + } + + getAddressDetailsView() { + return cy.get("#address-details-view"); + } + + getPhoneNumberView() { + return cy.get("#phone-number-view"); + } + + getFacilityAvailableFeatures() { + return cy.get("#facility-available-features"); + } + + getFacilityOxygenInfo() { + return cy.get("#facility-oxygen-info"); + } + clickResourceRequestOption() { cy.get("#resource-request").contains("Resource Request").click(); } @@ -146,6 +217,22 @@ class FacilityPage { cy.get("#delete-facility").contains("Delete Facility").click(); } + clickfacilityfeatureoption() { + cy.get("#features").click(); + } + + clickbedcapcityaddmore() { + cy.get("#bed-capacity-save").click(); + } + + clickdoctorcapacityaddmore() { + cy.get("#doctor-save").click(); + } + + clickcancelbutton() { + cy.get("#cancel").click(); + } + verifyfacilitynewurl() { cy.url().should("match", /facility\/[a-z\d-]+/); } diff --git a/src/Components/ABDM/ConfigureHealthFacility.tsx b/src/Components/ABDM/ConfigureHealthFacility.tsx index a84e4b6d4b9..bccf58e47c2 100644 --- a/src/Components/ABDM/ConfigureHealthFacility.tsx +++ b/src/Components/ABDM/ConfigureHealthFacility.tsx @@ -178,7 +178,7 @@ export const ConfigureHealthFacility = (props: any) => { > {state.form.health_facility?.registered ? ( <> -
+
The ABDM health facility is successfully linked with care{" "} @@ -192,7 +192,7 @@ export const ConfigureHealthFacility = (props: any) => { ) : ( <> -
+
The ABDM health facility is successfully linked with care{" "} diff --git a/src/Components/Assets/AssetTypes.tsx b/src/Components/Assets/AssetTypes.tsx index 07ba37d520e..a894c87dcc5 100644 --- a/src/Components/Assets/AssetTypes.tsx +++ b/src/Components/Assets/AssetTypes.tsx @@ -8,6 +8,7 @@ export interface AssetLocationObject { description: string; created_date?: string; modified_date?: string; + middleware_address?: string; facility: { id: string; name: string; diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index d148b26e3f5..9aa365c7303 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -264,11 +264,11 @@ export default function ResultList() { value={qParams.name} placeholder="Search by name" /> -
Search by number
setPhoneNum(e.value)} error={phoneNumberError} diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 736a7c81575..bb584ae93e6 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -60,7 +60,10 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { setMonitorBedData(monitorBedData); const assetDataForMonitor = monitorBedData?.asset_object; const hl7Meta = assetDataForMonitor?.meta; - const hl7Middleware = hl7Meta?.middleware_hostname || middleware_address; + const hl7Middleware = + hl7Meta?.middleware_hostname || + assetDataForMonitor?.location_object?.middleware_address || + middleware_address; if (hl7Middleware && hl7Meta?.local_ip_address) { setHL7SocketUrl( `wss://${hl7Middleware}/observations/${hl7Meta.local_ip_address}` @@ -85,7 +88,9 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { setVentilatorBedData(ventilatorBedData); const ventilatorMeta = ventilatorBedData?.asset_object?.meta; const ventilatorMiddleware = - ventilatorMeta?.middleware_hostname || middleware_address; + ventilatorMeta?.middleware_hostname || + consultationBedVentilator?.location_object.middleware_address || + middleware_address; if (ventilatorMiddleware && ventilatorMeta?.local_ip_address) { setVentilatorSocketUrl( `wss://${ventilatorMiddleware}/observations/${ventilatorMeta?.local_ip_address}` diff --git a/src/Components/Facility/FacilityBedCapacity.tsx b/src/Components/Facility/FacilityBedCapacity.tsx index 33583840643..0c05fb022cb 100644 --- a/src/Components/Facility/FacilityBedCapacity.tsx +++ b/src/Components/Facility/FacilityBedCapacity.tsx @@ -82,7 +82,7 @@ export const FacilityBedCapacity = (props: any) => { } return ( -
+
Bed Capacity
@@ -114,6 +114,6 @@ export const FacilityBedCapacity = (props: any) => { /> )} -
+
); }; diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index e742caefb82..8a7887ebc25 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -570,7 +570,10 @@ export const FacilityCreate = (props: FacilityProps) => { }); capacityList = ( -
+
{
{t("doctors_list")}
-
{doctorList}
+
+ {doctorList} +
); diff --git a/src/Components/Facility/FacilityDoctorList.tsx b/src/Components/Facility/FacilityDoctorList.tsx index e6bbc7f7f3b..d9a8b0d1a37 100644 --- a/src/Components/Facility/FacilityDoctorList.tsx +++ b/src/Components/Facility/FacilityDoctorList.tsx @@ -83,7 +83,7 @@ export const FacilityDoctorList = (props: any) => { } return ( -
+
Doctors List
@@ -116,6 +116,6 @@ export const FacilityDoctorList = (props: any) => { /> )} -
+
); }; diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 6f2e4d8de5e..c6f3623ebb5 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -198,7 +198,7 @@ export const FacilityHome = (props: any) => { )} {editCoverImageTooltip}
-
+

{facilityData?.name}

{facilityData?.modified_date && ( {
-
+

Address

@@ -222,7 +222,7 @@ export const FacilityHome = (props: any) => {
-
+

Phone Number

@@ -270,7 +270,10 @@ export const FacilityHome = (props: any) => { ) && (

Available features

)} -
+
{facilityData?.features?.map( (feature: number, i: number) => FACILITY_FEATURE_TYPES.some((f) => f.id === feature) && ( @@ -430,7 +433,10 @@ export const FacilityHome = (props: any) => {

Oxygen Information

-
+
( -
+
{children}
);