From 86d985d11eceda757f14be1aba5fd03279378b4b Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Fri, 15 Nov 2024 13:09:18 +0530 Subject: [PATCH 1/3] Facility bed capacity badge tests - Added logic to test for facility badge behavior - Added reusable function for patient and facility creation --- .../e2e/facility_spec/FacilityCreation.cy.ts | 180 ++++++++++-------- .../e2e/facility_spec/FacilityHomepage.cy.ts | 45 +++++ .../patient_spec/PatientRegistration.cy.ts | 75 ++++---- .../pageobject/Facility/FacilityCreation.ts | 143 ++++++++++++++ cypress/pageobject/Patient/PatientCreation.ts | 91 +++++++++ cypress/pageobject/Users/ManageUserPage.ts | 15 ++ src/components/Facility/FacilityCard.tsx | 2 +- 7 files changed, 430 insertions(+), 121 deletions(-) diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index 5e644238999..c3fefc0dc97 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -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"; @@ -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(); @@ -117,57 +174,7 @@ 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.submitForm(); - cy.closeNotification(); - // create multiple bed capacity and verify card reflection - facilityPage.selectBedType("Oxygen Supported Bed"); - facilityPage.fillTotalCapacity(bedCapacity); - facilityPage.fillCurrentlyOccupied(bedOccupancy); - facilityPage.clickbedcapcityaddmore(); - cy.closeNotification(); - facilityPage.selectBedType("Ordinary Bed"); - facilityPage.fillTotalCapacity(bedCapacity); - facilityPage.fillCurrentlyOccupied(bedOccupancy); - facilityPage.clickbedcapcityaddmore(); - cy.closeNotification(); - 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(); - cy.closeNotification(); - facilityPage.selectAreaOfSpecialization("Pulmonology"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.clickdoctorcapacityaddmore(); - cy.closeNotification(); - facilityPage.getTotalDoctorCapacity().contains(doctorCapacity); - facilityPage.clickcancelbutton(); - facilityPage.verifyfacilitynewurl(); + facilityPage.createNewFacility(testFacilityData); // verify the facility card facilityPage.getFacilityName().contains(facilityName).should("be.visible"); facilityPage @@ -205,27 +212,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 @@ -245,16 +257,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(); diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 08ea39ee2c9..edfd16387b1 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -1,4 +1,6 @@ // FacilityCreation +import { PatientData, PatientPage } from "pageobject/Patient/PatientCreation"; + import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import FacilityHome from "../../pageobject/Facility/FacilityHome"; @@ -16,6 +18,7 @@ describe("Facility Homepage Function", () => { const manageUserPage = new ManageUserPage(); const userPage = new UserPage(); const assetPagination = new AssetPagination(); + const patientPage = new PatientPage(); const facilitiesAlias = "downloadFacilitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; const triagesAlias = "downloadTriagesCSV"; @@ -27,6 +30,31 @@ describe("Facility Homepage Function", () => { const facilityType = "Private Hospital"; const notificationErrorMsg = "Message cannot be empty"; const notificationMessage = "Test Notification"; + const facilityWithNoAvailableBeds = "Dummy Facility 12"; + 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+", + }; before(() => { loginPage.loginAsDistrictAdmin(); @@ -183,6 +211,23 @@ describe("Facility Homepage Function", () => { loginPage.clickSignOutBtn(); }); + it("Verify the bed capacity badge reflection", () => { + manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds); + facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds); + manageUserPage.assertFacilityInCard(facilityWithNoAvailableBeds); + facilityHome.verifyOccupancyBadgeVisibility(); + manageUserPage.assertFacilityBadgeContent("0", "0"); + // create a new patient in the facility + cy.awaitUrl("/patients"); + patientPage.createPatientWithData(newPatientData); + cy.awaitUrl("/facility"); + manageUserPage.typeFacilitySearch(facilityWithNoAvailableBeds); + facilityPage.verifyFacilityBadgeContent(facilityWithNoAvailableBeds); + facilityHome.verifyOccupancyBadgeVisibility(); + manageUserPage.assertFacilityBadgeContent("1", "0"); + manageUserPage.assertFacilityBadgeBackgroundColor("rgb(239, 68, 68)"); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index 91810ffd273..3ee0b6b92e4 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -1,6 +1,8 @@ -import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import LoginPage from "../../pageobject/Login/LoginPage"; -import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { + PatientData, + PatientPage, +} from "../../pageobject/Patient/PatientCreation"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; @@ -30,7 +32,6 @@ const getRelativeDateString = (deltaDays = 0) => { describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); - const facilityPage = new FacilityPage(); const patientTransfer = new PatientTransfer(); const patientInsurance = new PatientInsurance(); const patientMedicalHistory = new PatientMedicalHistory(); @@ -66,6 +67,38 @@ describe("Patient Creation with consultation", () => { const patientTransferFacility = "Dummy Shifting Center"; const patientTransferName = "Dummy Patient 10"; const patientOccupation = "Student"; + const newPatientData: PatientData = { + facility: patientFacility, + phoneNumber: phone_number, + isEmergencyNumber: true, + age: age.toString(), + name: patientOneName, + gender: patientOneGender, + address: patientOneAddress, + pincode: patientOnePincode, + state: patientOneState, + district: patientOneDistrict, + localBody: patientOneLocalbody, + ward: patientOneWard, + occupation: patientOccupation, + socioeconomicStatus: "MIDDLE_CLASS", + domesticHealthcareSupport: "FAMILY_MEMBER", + medicalHistory: { + presentHealth: patientOnePresentHealth, + ongoingMedication: patientOneOngoingMedication, + conditions: [ + { index: 2, condition: "Diabetes" }, + { index: 3, condition: "Heart Disease" }, + { index: 4, condition: "HyperTension" }, + { index: 5, condition: "Kidney Diseases" }, + { index: 6, condition: "Lung Diseases/Asthma" }, + { index: 7, condition: "Cancer" }, + { index: 8, condition: "Other" }, + ], + allergies: patientOneAllergies, + }, + bloodGroup: patientOneBloodGroup, + }; before(() => { loginPage.loginAsDistrictAdmin(); @@ -79,41 +112,7 @@ describe("Patient Creation with consultation", () => { }); it("Create a new patient with all field in registration form and no consultation", () => { - // patient details with all the available fields except covid - patientPage.createPatient(); - patientPage.selectFacility(patientFacility); - patientPage.patientformvisibility(); - // Patient Details page - patientPage.typePatientPhoneNumber(phone_number); - patientPage.checkPhoneNumberIsEmergencyNumber(); - patientPage.typePatientAge(age.toString()); - patientPage.typePatientName(patientOneName); - patientPage.selectPatientGender(patientOneGender); - patientPage.typePatientAddress(patientOneAddress); - facilityPage.fillPincode(patientOnePincode); - facilityPage.selectStateOnPincode(patientOneState); - facilityPage.selectDistrictOnPincode(patientOneDistrict); - facilityPage.selectLocalBody(patientOneLocalbody); - facilityPage.selectWard(patientOneWard); - patientPage.selectPatientOccupation(patientOccupation); - patientPage.selectSocioeconomicStatus("MIDDLE_CLASS"); - patientPage.selectDomesticHealthcareSupport("FAMILY_MEMBER"); - // Patient Medical History - patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth); - patientMedicalHistory.typePatientOngoingMedication( - patientOneOngoingMedication, - ); - patientMedicalHistory.typeMedicalHistory(2, "Diabetes"); - patientMedicalHistory.typeMedicalHistory(3, "Heart Disease"); - patientMedicalHistory.typeMedicalHistory(4, "HyperTension"); - patientMedicalHistory.typeMedicalHistory(5, "Kidney Diseases"); - patientMedicalHistory.typeMedicalHistory(6, "Lung Diseases/Asthma"); - patientMedicalHistory.typeMedicalHistory(7, "Cancer"); - patientMedicalHistory.typeMedicalHistory(8, "Other"); - patientMedicalHistory.typePatientAllergies(patientOneAllergies); - patientPage.selectPatientBloodGroup(patientOneBloodGroup); - patientPage.clickCreatePatient(); - patientPage.verifyPatientIsCreated(); + patientPage.createPatientWithData(newPatientData); // Verify the patient details patientPage.clickCancelButton(); cy.wait(3000); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 6ce0cc6270e..b6289bab4e9 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -1,5 +1,48 @@ import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; +export interface FacilityData { + basic: { + name: string; + type: string; + features?: string[]; + address: string; + phoneNumber: string; + location?: string; + }; + location: { + pincode: string; + state: string; + district: string; + localBody: string; + ward: string; + }; + oxygen?: { + capacity: string; + expected: string; + bType?: { + capacity: string; + expected: string; + }; + cType?: { + capacity: string; + expected: string; + }; + dType?: { + capacity: string; + expected: string; + }; + }; + beds?: Array<{ + type: string; + totalCapacity: string; + occupied: string; + }>; + doctors?: Array<{ + specialization: string; + count: string; + }>; +} + class FacilityPage { visitCreateFacilityPage() { cy.intercept("GET", "**/facility/create").as("getCreateFacilities"); @@ -481,6 +524,106 @@ class FacilityPage { clickSetMinimumQuantity() { cy.get("#set-minimum-quantity").click(); } + + createNewFacility(data: FacilityData) { + this.visitCreateFacilityPage(); + + // Fill basic details + this.fillBasicDetails(data.basic); + + // Fill location details + this.fillLocationDetails(data.location); + + // Fill oxygen details if provided + if (data.oxygen) { + this.fillOxygenDetails(data.oxygen); + } + + this.submitForm(); + cy.closeNotification(); + + // Add bed capacity if provided + if (data.beds) { + this.addBedCapacities(data.beds); + } + + // Add doctor capacity if provided + if (data.doctors) { + this.addDoctorCapacities(data.doctors); + } + + this.verifyfacilitynewurl(); + return this; + } + + fillBasicDetails(basic: FacilityData["basic"]) { + this.fillFacilityName(basic.name); + this.selectFacilityType(basic.type); + + if (basic.features?.length) { + this.clickfacilityfeatureoption(); + basic.features.forEach((feature) => { + cy.get("[role='option']").contains(feature).click(); + }); + this.clickfacilityfeatureoption(); + } + + this.fillAddress(basic.address); + this.fillPhoneNumber(basic.phoneNumber); + + if (basic.location) { + this.selectLocation(basic.location); + } + } + + fillLocationDetails(location: FacilityData["location"]) { + this.fillPincode(location.pincode); + this.selectStateOnPincode(location.state); + this.selectDistrictOnPincode(location.district); + this.selectLocalBody(location.localBody); + this.selectWard(location.ward); + } + + fillOxygenDetails(oxygen: NonNullable) { + this.fillOxygenCapacity(oxygen.capacity); + this.fillExpectedOxygenRequirement(oxygen.expected); + + if (oxygen.bType) { + this.fillBTypeCylinderCapacity(oxygen.bType.capacity); + this.fillExpectedBTypeCylinderRequirement(oxygen.bType.expected); + } + + if (oxygen.cType) { + this.fillCTypeCylinderCapacity(oxygen.cType.capacity); + this.fillExpectedCTypeCylinderRequirement(oxygen.cType.expected); + } + + if (oxygen.dType) { + this.fillDTypeCylinderCapacity(oxygen.dType.capacity); + this.fillExpectedDTypeCylinderRequirement(oxygen.dType.expected); + } + } + + addBedCapacities(beds: NonNullable) { + beds.forEach((bed) => { + this.selectBedType(bed.type); + this.fillTotalCapacity(bed.totalCapacity); + this.fillCurrentlyOccupied(bed.occupied); + this.clickbedcapcityaddmore(); + cy.closeNotification(); + }); + this.clickcancelbutton(); + } + + addDoctorCapacities(doctors: NonNullable) { + doctors.forEach((doctor) => { + this.selectAreaOfSpecialization(doctor.specialization); + this.fillDoctorCount(doctor.count); + this.clickdoctorcapacityaddmore(); + cy.closeNotification(); + }); + this.clickcancelbutton(); + } } export default FacilityPage; diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 8f46dec5560..232caa0bda5 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -1,6 +1,36 @@ // PatientPage.ts +import FacilityPage from "pageobject/Facility/FacilityCreation"; + +import PatientMedicalHistory from "./PatientMedicalHistory"; let patient_url = ""; +const facilityPage = new FacilityPage(); +const patientMedicalHistory = new PatientMedicalHistory(); + +export interface PatientData { + facility: string; + phoneNumber: string; + isEmergencyNumber?: boolean; + age: string | number; + name: string; + gender: string; + address: string; + pincode: string; + state: string; + district: string; + localBody: string; + ward: string; + occupation?: string; + socioeconomicStatus?: string; + domesticHealthcareSupport?: string; + medicalHistory?: { + presentHealth?: string; + ongoingMedication?: string; + conditions?: { index: number; condition: string }[]; + allergies?: string; + }; + bloodGroup?: string; +} export class PatientPage { createPatient() { @@ -235,4 +265,65 @@ export class PatientPage { patientformvisibility() { cy.get("[data-testid='current-address']").scrollIntoView(); } + + createPatientWithData(data: PatientData) { + this.createPatient(); + this.selectFacility(data.facility); + this.patientformvisibility(); + + this.typePatientPhoneNumber(data.phoneNumber); + if (data.isEmergencyNumber) { + this.checkPhoneNumberIsEmergencyNumber(); + } + this.typePatientAge(data.age.toString()); + this.typePatientName(data.name); + this.selectPatientGender(data.gender); + this.typePatientAddress(data.address); + + facilityPage.fillPincode(data.pincode); + facilityPage.selectStateOnPincode(data.state); + facilityPage.selectDistrictOnPincode(data.district); + facilityPage.selectLocalBody(data.localBody); + facilityPage.selectWard(data.ward); + + if (data.occupation) { + this.selectPatientOccupation(data.occupation); + } + if (data.socioeconomicStatus) { + this.selectSocioeconomicStatus(data.socioeconomicStatus); + } + if (data.domesticHealthcareSupport) { + this.selectDomesticHealthcareSupport(data.domesticHealthcareSupport); + } + + if (data.medicalHistory) { + if (data.medicalHistory.presentHealth) { + patientMedicalHistory.typePatientPresentHealth( + data.medicalHistory.presentHealth, + ); + } + if (data.medicalHistory.ongoingMedication) { + patientMedicalHistory.typePatientOngoingMedication( + data.medicalHistory.ongoingMedication, + ); + } + if (data.medicalHistory.conditions) { + data.medicalHistory.conditions.forEach(({ index, condition }) => { + patientMedicalHistory.typeMedicalHistory(index, condition); + }); + } + if (data.medicalHistory.allergies) { + patientMedicalHistory.typePatientAllergies( + data.medicalHistory.allergies, + ); + } + } + + if (data.bloodGroup) { + this.selectPatientBloodGroup(data.bloodGroup); + } + + this.clickCreatePatient(); + this.verifyPatientIsCreated(); + } } diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index a3a6e72fbc3..fcd3d27a185 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -161,6 +161,21 @@ export class ManageUserPage { ); } + assertFacilityBadgeContent(occupied: string, total: string) { + cy.get('[data-test-id="occupancy-badge-text"]').should( + "contain.text", + `Occupancy: ${occupied} / ${total}`, + ); + } + + assertFacilityBadgeBackgroundColor(color: string) { + cy.get('[data-test-id="occupancy-badge"]').should( + "have.css", + "background-color", + color, + ); + } + assertVideoConnectLink(docName: string, link: string) { cy.get("ul#options") .find("li") diff --git a/src/components/Facility/FacilityCard.tsx b/src/components/Facility/FacilityCard.tsx index 0d9c5678d4c..fbebe8a8d0a 100644 --- a/src/components/Facility/FacilityCard.tsx +++ b/src/components/Facility/FacilityCard.tsx @@ -106,7 +106,7 @@ export const FacilityCard = (props: { {t("live_patients_total_beds")} {" "} -
+
{t("occupancy")}: {facility.patient_count} /{" "} {facility.bed_count}{" "}
From 6edf2b0e629a355150807035c286bbc4465b2f36 Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Sun, 17 Nov 2024 14:43:26 +0530 Subject: [PATCH 2/3] Facility Badge verification tests --- .../e2e/facility_spec/FacilityHomepage.cy.ts | 94 ++++++++++++++++++- .../e2e/facility_spec/FacilityLocation.cy.ts | 48 ++++------ .../pageobject/Facility/FacilityCreation.ts | 5 +- cypress/pageobject/Facility/FacilityHome.ts | 5 +- .../pageobject/Facility/FacilityLocation.ts | 31 +++++- cypress/pageobject/Facility/FacilityManage.ts | 8 ++ cypress/pageobject/Patient/PatientCreation.ts | 15 +++ cypress/pageobject/Patient/PatientHome.ts | 4 + src/components/Patient/PatientHome.tsx | 6 +- 9 files changed, 176 insertions(+), 40 deletions(-) diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index edfd16387b1..1c1780dabc6 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -1,5 +1,9 @@ // FacilityCreation +import { AssetPage } from "pageobject/Asset/AssetCreation"; +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"; @@ -19,6 +23,10 @@ describe("Facility Homepage Function", () => { 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"; @@ -30,7 +38,9 @@ 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", @@ -55,6 +65,9 @@ describe("Facility Homepage Function", () => { }, bloodGroup: "O+", }; + const patientIpNumber = `${Math.floor(Math.random() * 90 + 10)}/${Math.floor(Math.random() * 9000 + 1000)}`; + const locationName = "Test-location"; + const locationType = "WARD"; before(() => { loginPage.loginAsDistrictAdmin(); @@ -209,6 +222,8 @@ describe("Facility Homepage Function", () => { facilityNotify.closeNotificationSlide(); loginPage.ensureLoggedIn(); loginPage.clickSignOutBtn(); + loginPage.loginManuallyAsDistrictAdmin(); + loginPage.ensureLoggedIn(); }); it("Verify the bed capacity badge reflection", () => { @@ -217,15 +232,90 @@ describe("Facility Homepage Function", () => { 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.awaitUrl("/patients"); + cy.visit("/patients"); patientPage.createPatientWithData(newPatientData); - cy.awaitUrl("/facility"); + // 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.document().then(($doc) => { + const manageBedButton = $doc.querySelector("#manage-bed-button"); + if (manageBedButton) { + facilityLocation.clickManageBedButton(); + } else { + facilityLocation.clickAddNewLocationButton(); + facilityPage.fillFacilityName(locationName); + facilityLocation.selectLocationType(locationType); + assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); + facilityLocation.clickManageBedButton(); + } + }); + 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.fillTreatingPhysican(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"); }); afterEach(() => { diff --git a/cypress/e2e/facility_spec/FacilityLocation.cy.ts b/cypress/e2e/facility_spec/FacilityLocation.cy.ts index b700f5c75ae..a110969b29b 100644 --- a/cypress/e2e/facility_spec/FacilityLocation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityLocation.cy.ts @@ -59,13 +59,13 @@ describe("Location Management Section", () => { }); it("Add a Bed to facility location along with duplication and deleting a bed", () => { + cy.wait(2000); // mandatory field verification in bed creation - cy.get("body").then(($body) => { - if ($body.find("#manage-bed-button:visible").length) { - // If the '#manage-bed-button' is visible + cy.document().then(($doc) => { + const manageBedButton = $doc.querySelector("#manage-bed-button"); + if (manageBedButton) { facilityLocation.clickManageBedButton(); } else { - // If the '#manage-bed-button' is not visible facilityLocation.clickAddNewLocationButton(); facilityPage.fillFacilityName(locationName); facilityLocation.selectLocationType(locationType); @@ -78,29 +78,24 @@ describe("Location Management Section", () => { assetPage.clickassetupdatebutton(); userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); // create a new single bed and verify - facilityLocation.enterBedName(bedName); - facilityLocation.enterBedDescription(bedDescrption); - facilityLocation.selectBedType(bedType); - assetPage.clickassetupdatebutton(); + facilityLocation.addBed(bedName, bedDescrption, bedType); // Verify the bed creation facilityLocation.verifyBedNameBadge(bedName); facilityLocation.verifyBedBadge(bedType); facilityLocation.verifyBedBadge(bedStatus); // Try to create duplication bed and verify the error facilityLocation.clickAddBedButton(); - facilityLocation.enterBedName(bedName); - facilityLocation.selectBedType(bedType); - assetPage.clickassetupdatebutton(); + facilityLocation.addBed(bedName, bedDescrption, bedType); facilityLocation.verifyNotification( "Name - Bed with same name already exists in location", ); facilityHome.verifyAndCloseNotifyModal(); // edit the created bed - facilityLocation.clickEditBedButton(); - facilityLocation.enterBedName(bedModifiedName); - facilityLocation.enterBedDescription(bedModifiedDescrption); - facilityLocation.selectBedType(bedModifiedType); - assetPage.clickassetupdatebutton(); + facilityLocation.editBed( + bedModifiedName, + bedModifiedDescrption, + bedModifiedType, + ); // verify the modification facilityLocation.verifyBedNameBadge(bedModifiedName); facilityLocation.verifyBedBadge(bedModifiedType); @@ -144,11 +139,7 @@ describe("Location Management Section", () => { // create multiple bed and verify facilityLocation.clickManageBedButton(); facilityLocation.clickAddBedButton(); - facilityLocation.enterBedName(bedName); - facilityLocation.enterBedDescription(bedDescrption); - facilityLocation.selectBedType(bedType); - facilityLocation.setMultipleBeds(numberOfBeds); - assetPage.clickassetupdatebutton(); + facilityLocation.addBed(bedName, bedDescrption, bedType, numberOfBeds); facilityLocation.clickNotification(); // verify the bed creation facilityLocation.verifyBedBadge(bedType); @@ -166,11 +157,12 @@ describe("Location Management Section", () => { // bed creation facilityLocation.clickManageBedButton(); facilityLocation.clickAddBedButton(); - facilityLocation.enterBedName(bedModifiedName); - facilityLocation.enterBedDescription(bedModifiedDescrption); - facilityLocation.selectBedType(bedModifiedType); - facilityLocation.setMultipleBeds(numberOfModifiedBeds); - assetPage.clickassetupdatebutton(); + facilityLocation.addBed( + bedModifiedName, + bedModifiedDescrption, + bedModifiedType, + numberOfModifiedBeds, + ); // pagination assetPagination.navigateToNextPage(); assetPagination.navigateToPreviousPage(); @@ -199,9 +191,7 @@ describe("Location Management Section", () => { cy.closeNotification(); facilityLocation.clickManageBedButton(); facilityLocation.clickAddBedButton(); - facilityLocation.enterBedName("Bed 1"); - facilityLocation.selectBedType("Regular"); - cy.submitButton("Add Bed(s)"); + facilityLocation.addBed("Bed 1", "Test Description", "Regular"); cy.verifyNotification("1 Bed created successfully"); cy.closeNotification(); facilityLocation.loadLocationManagementPage("Dummy Shifting Center"); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index b6289bab4e9..8aec3511dd7 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -472,9 +472,8 @@ class FacilityPage { } selectDistrictOnPincode(districtName: string) { - this.getDistrictElement() - .scrollIntoView() - .wait(2000) + this.getDistrictElement().as("district").scrollIntoView().wait(2000); + cy.get("@district") .should("be.visible") .then(($element) => { const text = $element.text(); diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index 30f51052370..77a1790eab6 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -35,8 +35,9 @@ class FacilityHome { } clickFacilityNotifyButton() { - cy.get("#facility-notify", { timeout: 10000 }).should("be.visible"); - cy.get("#facility-notify").focus().click(); + cy.get("#facility-notify").as("facilityNotify"); + cy.get("@facilityNotify", { timeout: 10000 }).should("be.visible"); + cy.get("@facilityNotify").first().click(); } clickLiveMonitorButton() { diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index 31bc30290f7..277a267b208 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -19,7 +19,7 @@ class FacilityLocation { } clickAddNewLocationButton() { - cy.get("#add-new-location").click(); + cy.get("#add-new-location").click({ force: true }); } clickFacilityLocationManagement() { @@ -76,17 +76,42 @@ class FacilityLocation { } clickManageBedButton() { - cy.get("#manage-bed-button").first().click(); + cy.intercept("/api/v1/bed/?facility=*").as("getBeds"); + cy.get("#manage-bed-button").first().click({}); + cy.wait("@getBeds").its("response.statusCode").should("eq", 200); } clickAddBedButton() { - cy.get("#add-new-bed").click(); + cy.get("#add-new-bed").click({ force: true }); } clickNotification() { cy.get(".pnotify-container").click(); } + addBed( + bedName: string, + bedDescrption: string, + bedType: string, + multipleBeds?: number, + ) { + this.enterBedName(bedName); + this.enterBedDescription(bedDescrption); + this.selectBedType(bedType); + if (multipleBeds) { + this.setMultipleBeds(multipleBeds); + } + cy.get("#submit").click(); + } + + editBed(bedName: string, bedDescrption: string, bedType: string) { + this.clickEditBedButton(); + this.enterBedName(bedName); + this.enterBedDescription(bedDescrption); + this.selectBedType(bedType); + cy.get("#submit").click(); + } + enterBedName(name: string) { cy.get("#bed-name").click().clear().click().type(name); } diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts index 9a32a5be36f..e7eecddab3c 100644 --- a/cypress/pageobject/Facility/FacilityManage.ts +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -99,5 +99,13 @@ class FacilityManage { cy.get("#facility-add-bedtype").scrollIntoView(); cy.get("#facility-add-bedtype").click(); } + + visitViewPatients() { + cy.intercept("GET", "**/api/v1/facility/**").as("getFacilityPatients"); + cy.get("#view-patient-facility-list").scrollIntoView().click(); + cy.wait("@getFacilityPatients") + .its("response.statusCode") + .should("eq", 200); + } } export default FacilityManage; diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 232caa0bda5..d1884d6add2 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -51,6 +51,17 @@ export class PatientPage { .contains(patientName); } + visitPatientWithNoConsultation(patientName: string) { + cy.get("#name").click().type(patientName); + cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); + cy.get("#patient-name-list").contains(patientName).click(); + cy.wait(2000); + cy.wait("@getPatient").its("response.statusCode").should("eq", 200); + cy.get("#patient-name-age").should("be.visible").contains(patientName); + cy.get("#create-consultation").should("be.visible"); + this.clickCreateConsultationOnPatientPageWithNoConsultation(); + } + selectFacility(facilityName: string) { cy.typeAndSelectOption("input[name='facilities']", facilityName); cy.submitButton("Select"); @@ -182,6 +193,10 @@ export class PatientPage { cy.wait("@updatePatient").its("response.statusCode").should("eq", 200); } + clickCreateConsultationOnPatientPageWithNoConsultation() { + cy.get("#create-consultation").should("be.visible").click(); + } + verifyPatientUpdated() { cy.url().should("include", "/patient"); } diff --git a/cypress/pageobject/Patient/PatientHome.ts b/cypress/pageobject/Patient/PatientHome.ts index bc27977d561..ef60b9f678d 100644 --- a/cypress/pageobject/Patient/PatientHome.ts +++ b/cypress/pageobject/Patient/PatientHome.ts @@ -30,6 +30,10 @@ class PatientHome { cy.wait("@getPatients").its("response.statusCode").should("eq", 200); } + typePatientName(patientName: string) { + cy.typeAndSelectOption("input[name='name']", patientName); + } + typePatientCreatedBeforeDate(startDate: string) { cy.clickAndTypeDate("input[name='created_date_start']", startDate); } diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 3b5924009bb..82fa5116a28 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -334,6 +334,7 @@ export const PatientHome = (props: any) => { `/facility/${patientData?.facility}/patient/${id}/consultation`, ) } + id="create-consultation" > {t("create_consultation")} @@ -346,7 +347,10 @@ export const PatientHome = (props: any) => {
-

+

{patientData.name} - {formatPatientAge(patientData, true)}

From f322b8a818c18258cb231d526566d46dbe48d7b1 Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Mon, 18 Nov 2024 11:44:01 +0530 Subject: [PATCH 3/3] suggested changes and minor fixes --- .../e2e/facility_spec/FacilityCreation.cy.ts | 33 ++++++++++++++++++- .../e2e/facility_spec/FacilityHomepage.cy.ts | 7 ++-- .../e2e/facility_spec/FacilityLocation.cy.ts | 5 ++- .../PatientConsultationCreation.cy.ts | 8 ++--- cypress/pageobject/Patient/PatientCreation.ts | 1 - .../Patient/PatientTreatmentPlan.ts | 2 +- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index c3fefc0dc97..f35cc7e582a 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -174,7 +174,38 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.submitForm(); userCreationPage.verifyErrorMessages(facilityErrorMessage); - facilityPage.createNewFacility(testFacilityData); + facilityPage.visitCreateFacilityPage(); + facilityPage.fillBasicDetails(testFacilityData.basic); + facilityPage.fillLocationDetails(testFacilityData.location); + facilityPage.fillOxygenDetails(testFacilityData.oxygen); + facilityPage.submitForm(); + cy.closeNotification(); + // add the bed capacity + facilityPage.selectBedType("Oxygen Supported Bed"); + facilityPage.fillTotalCapacity(bedCapacity); + facilityPage.fillCurrentlyOccupied(bedOccupancy); + facilityPage.clickbedcapcityaddmore(); + cy.closeNotification(); + facilityPage.selectBedType("Ordinary Bed"); + facilityPage.fillTotalCapacity(bedCapacity); + facilityPage.fillCurrentlyOccupied(bedOccupancy); + facilityPage.clickbedcapcityaddmore(); + cy.closeNotification(); + 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(); + cy.closeNotification(); + facilityPage.selectAreaOfSpecialization("Pulmonology"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.clickdoctorcapacityaddmore(); + cy.closeNotification(); + facilityPage.getTotalDoctorCapacity().contains(doctorCapacity); + facilityPage.clickcancelbutton(); + facilityPage.verifyfacilitynewurl(); // verify the facility card facilityPage.getFacilityName().contains(facilityName).should("be.visible"); facilityPage diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 1c1780dabc6..d6d62362211 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -270,9 +270,8 @@ describe("Facility Homepage Function", () => { 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.document().then(($doc) => { - const manageBedButton = $doc.querySelector("#manage-bed-button"); - if (manageBedButton) { + cy.get("body").then(($body) => { + if ($body.find("#manage-bed-button").length > 0) { facilityLocation.clickManageBedButton(); } else { facilityLocation.clickAddNewLocationButton(); @@ -306,7 +305,7 @@ describe("Facility Homepage Function", () => { "1A00", "add-icd11-diagnosis-as-unconfirmed", ); - patientTreatmentPlan.fillTreatingPhysican(doctorName); + patientTreatmentPlan.fillTreatingPhysician(doctorName); patientConsultationPage.selectBed("Bed 1"); cy.submitButton("Create Consultation"); cy.verifyNotification("Consultation created successfully"); diff --git a/cypress/e2e/facility_spec/FacilityLocation.cy.ts b/cypress/e2e/facility_spec/FacilityLocation.cy.ts index a110969b29b..ab93ef2804a 100644 --- a/cypress/e2e/facility_spec/FacilityLocation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityLocation.cy.ts @@ -61,9 +61,8 @@ describe("Location Management Section", () => { it("Add a Bed to facility location along with duplication and deleting a bed", () => { cy.wait(2000); // mandatory field verification in bed creation - cy.document().then(($doc) => { - const manageBedButton = $doc.querySelector("#manage-bed-button"); - if (manageBedButton) { + cy.get("body").then(($body) => { + if ($body.find("#manage-bed-button").length > 0) { facilityLocation.clickManageBedButton(); } else { facilityLocation.clickAddNewLocationButton(); diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index 4c84f7fad8f..1ee5d567023 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -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.submitButton("Create Consultation"); // the above submit should fail as IP number is missing patientConsultationPage.typePatientNumber(patientIpNumber); @@ -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"); @@ -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.submitButton("Create Consultation"); cy.verifyNotification("Patient discharged successfully"); // verify the Discharge Reason, Diagnosis, treatment physican @@ -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.submitButton("Create Consultation"); // Create a shifting request diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index d1884d6add2..6d6c36b5aa0 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -55,7 +55,6 @@ export class PatientPage { cy.get("#name").click().type(patientName); cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); cy.get("#patient-name-list").contains(patientName).click(); - cy.wait(2000); cy.wait("@getPatient").its("response.statusCode").should("eq", 200); cy.get("#patient-name-age").should("be.visible").contains(patientName); cy.get("#create-consultation").should("be.visible"); diff --git a/cypress/pageobject/Patient/PatientTreatmentPlan.ts b/cypress/pageobject/Patient/PatientTreatmentPlan.ts index 02b2f9b150d..7b4e08c8071 100644 --- a/cypress/pageobject/Patient/PatientTreatmentPlan.ts +++ b/cypress/pageobject/Patient/PatientTreatmentPlan.ts @@ -3,7 +3,7 @@ class PatientTreatmentPlan { cy.get("#consultation_notes").type(instruction); } - fillTreatingPhysican(doctor: string) { + fillTreatingPhysician(doctor: string) { cy.typeAndSelectOption("#treating_physician", doctor); }