Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facility bed capacity verification test #9145

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 102 additions & 55 deletions cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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 @@ -58,6 +60,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.loginAsDistrictAdmin();
Expand Down Expand Up @@ -117,32 +174,13 @@ describe("Facility Creation", () => {
facilityPage.visitCreateFacilityPage();
facilityPage.submitForm();
userCreationPage.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.visitCreateFacilityPage();
facilityPage.fillBasicDetails(testFacilityData.basic);
facilityPage.fillLocationDetails(testFacilityData.location);
facilityPage.fillOxygenDetails(testFacilityData.oxygen);
facilityPage.submitForm();
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -205,27 +243,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 @@ -245,16 +288,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();
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
// add no bed capacity and verify form error message
facilityPage.isVisibleselectBedType();
Expand Down
134 changes: 134 additions & 0 deletions cypress/e2e/facility_spec/FacilityHomepage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// FacilityCreation
import { AssetPage } from "pageobject/Asset/AssetCreation";
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
import FacilityLocation from "pageobject/Facility/FacilityLocation";
import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation";
import { PatientData, PatientPage } from "pageobject/Patient/PatientCreation";
import PatientTreatmentPlan from "pageobject/Patient/PatientTreatmentPlan";

import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
Expand All @@ -16,6 +22,11 @@ describe("Facility Homepage Function", () => {
const manageUserPage = new ManageUserPage();
const userPage = new UserPage();
const assetPagination = new AssetPagination();
const patientPage = new PatientPage();
const patientConsultationPage = new PatientConsultationPage();
const patientTreatmentPlan = new PatientTreatmentPlan();
const facilityLocation = new FacilityLocation();
const assetPage = new AssetPage();
const facilitiesAlias = "downloadFacilitiesCSV";
const doctorsAlias = "downloadDoctorsCSV";
const triagesAlias = "downloadTriagesCSV";
Expand All @@ -27,6 +38,36 @@ describe("Facility Homepage Function", () => {
const facilityType = "Private Hospital";
const notificationErrorMsg = "Message cannot be empty";
const notificationMessage = "Test Notification";
const doctorName = "Dummy Doctor";
const facilityWithNoAvailableBeds = "Dummy Facility 12";
const usernameToLinkFacilityWithNoBeds = "dummydoctor12";
const newPatientData: PatientData = {
facility: facilityWithNoAvailableBeds,
phoneNumber: "9898464555",
isEmergencyNumber: true,
age: "20",
name: "Dummy Patient 42",
gender: "Male",
address: "42 is the answer to everything",
pincode: "682001",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
ward: "4",
occupation: "Student",
socioeconomicStatus: "MIDDLE_CLASS",
domesticHealthcareSupport: "FAMILY_MEMBER",
medicalHistory: {
presentHealth: "Good",
ongoingMedication: "None",
conditions: [{ index: 2, condition: "Diabetes" }],
allergies: "None",
},
bloodGroup: "O+",
};
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
const patientIpNumber = `${Math.floor(Math.random() * 90 + 10)}/${Math.floor(Math.random() * 9000 + 1000)}`;
const locationName = "Test-location";
const locationType = "WARD";

before(() => {
loginPage.loginAsDistrictAdmin();
Expand Down Expand Up @@ -181,6 +222,99 @@ describe("Facility Homepage Function", () => {
facilityNotify.closeNotificationSlide();
loginPage.ensureLoggedIn();
loginPage.clickSignOutBtn();
loginPage.loginManuallyAsDistrictAdmin();
loginPage.ensureLoggedIn();
});

it("Verify the bed capacity badge reflection", () => {
manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds);
facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds);
manageUserPage.assertFacilityInCard(facilityWithNoAvailableBeds);
facilityHome.verifyOccupancyBadgeVisibility();
manageUserPage.assertFacilityBadgeContent("0", "0");

// link dummy doctor 12 to the facility
cy.awaitUrl("/users");
userPage.typeInSearchInput(usernameToLinkFacilityWithNoBeds);
userPage.checkUsernameText(usernameToLinkFacilityWithNoBeds);

cy.get("#home_facility").then(($homeFacility) => {
const homeFacilityText = $homeFacility.text().trim();
if (homeFacilityText.includes("No Home Facility")) {
// Link facility if no home facility exists
manageUserPage.clickFacilitiesTab();
manageUserPage.selectFacilityFromDropdown(facilityWithNoAvailableBeds);
manageUserPage.clickLinkFacility();
manageUserPage.clickHomeFacilityIcon();
manageUserPage.assertnotLinkedFacility(facilityWithNoAvailableBeds);
manageUserPage.assertHomeFacilitylink(facilityWithNoAvailableBeds);
manageUserPage.clickCloseSlideOver();
} else {
// Assert if facility is already linked
manageUserPage.assertHomeFacility(facilityWithNoAvailableBeds);
}
});

// create a new patient in the facility
cy.visit("/patients");
patientPage.createPatientWithData(newPatientData);
// navigate to facility page and verify the occupancy badge
cy.visit("/facility");
manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds);
facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds);
facilityHome.verifyOccupancyBadgeVisibility();
manageUserPage.assertFacilityBadgeContent("1", "0");
manageUserPage.assertFacilityBadgeBackgroundColor("rgb(239, 68, 68)");
// create a new location and add a bed to the facility
facilityPage.visitAlreadyCreatedFacility();
cy.get("[id='manage-facility-dropdown']").scrollIntoView().click();
cy.get("[id=location-management]").click();
// create new location and add a bed to the facility
cy.get("body").then(($body) => {
if ($body.find("#manage-bed-button").length > 0) {
facilityLocation.clickManageBedButton();
} else {
facilityLocation.clickAddNewLocationButton();
facilityPage.fillFacilityName(locationName);
facilityLocation.selectLocationType(locationType);
assetPage.clickassetupdatebutton();
facilityLocation.clickNotification();
facilityLocation.clickManageBedButton();
}
});
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
facilityLocation.clickAddBedButton();
facilityLocation.addBed("Bed 1", "Test Description", "Regular", 2);
// navigate to patient page, and click create consultation
cy.visit("/facility");
manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds);
facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds);
// visit facility patients page
manageUserPage.clickFacilityPatients();
facilityHome.verifyPatientListVisibility();
facilityHome.verifyPatientListUrl();
// type patient name and click create consultation
patientPage.visitPatientWithNoConsultation(newPatientData.name);
// create patient consultation and add bed to the consultation
patientConsultationPage.selectConsultationStatus(
"Outpatient/Emergency Room",
);
cy.get("#is_asymptomatic").click();
patientConsultationPage.selectPatientCategory("Mild");
patientConsultationPage.typePatientNumber(patientIpNumber);
patientConsultationPage.selectPatientDiagnosis(
"1A00",
"add-icd11-diagnosis-as-unconfirmed",
);
patientTreatmentPlan.fillTreatingPhysician(doctorName);
patientConsultationPage.selectBed("Bed 1");
cy.submitButton("Create Consultation");
cy.verifyNotification("Consultation created successfully");
// verify the occupancy badge reflection
cy.visit("/facility");
manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds);
facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds);
facilityHome.verifyOccupancyBadgeVisibility();
manageUserPage.assertFacilityBadgeContent("1", "2");
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
});

afterEach(() => {
Expand Down
Loading
Loading