From 7f0d302c6068f88ec5a99596bc5af25395bde8ae Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 29 Apr 2024 11:16:33 +0530 Subject: [PATCH 1/6] Update README to specify to use local backend for cypress tests --- README.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6e36f52b3f1..dbb306a1bd8 100644 --- a/README.md +++ b/README.md @@ -73,12 +73,33 @@ Authenticate to staging API with any of the following credentials #### 🧪 Run cypress tests -Ensure that the development server is running and then run the cypress tests in either of the ways described below. +To run cypress tests locally, you'll need to setup the backend to run locally and load dummy data required for cypress to the database. See [docs](https://github.com/coronasafe/care#self-hosting). + +Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `CARE_API` env. + +```env +#.env +CARE_API=http://127.0.0.1:9000 +``` + +Once done, start the development server by running + +```sh +npm run dev +``` + +Once development server is running, then run the cypress tests in either of the ways described below. + +```sh +npm run cypress:run # To run all tests in headless mode. +``` + +```sh +npm run cypress:run:gui # To run all tests in headed mode. +``` ```sh -$ npm run cypress:run # To run all tests in headless mode. -$ npm run cypress:run:gui # To run all tests in headed mode. -$ npm run cypress:open # To debug and run tests individually. +npm run cypress:open # To debug and run tests individually. ``` - Failed test screenshots are saved in `cypress/screenshots` From 283d0983a698ce4db3a1160310a468c7b9b19b86 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed <98876115+AshrafMd-1@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:19:56 +0530 Subject: [PATCH 2/6] add loader (#7720) --- src/Components/ExternalResult/ResultList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index 9d34b397026..0759b47d73a 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -194,7 +194,7 @@ export default function ResultList() { }); } - if (loading) { + if (loading || !data) { manageResults = ( From e28f92d35a54e78727a8d9defb9ca7c806e60a82 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:21:52 +0530 Subject: [PATCH 3/6] Change home facility indicator in linked facilities slideover (#7710) * Change home facility indicator in linked facilitites slideover * Update home facility indicator styling in ManageUsers.tsx --- src/Components/Users/ManageUsers.tsx | 33 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index b4fb9e8b10a..76940fefc79 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -465,7 +465,7 @@ export default function ManageUsers() { open={expandFacilityList} setOpen={setExpandFacilityList} slideFrom="right" - title={t("facilities")} + title={t("linked_facilities")} dialogClass="md:w-[400px]" > @@ -728,6 +728,7 @@ export function UserFacilities(props: { user: any }) { handleOk={handleUnlinkFacilitySubmit} /> )} +
+
+ {isLoading || userFacilitiesLoading ? (
@@ -757,13 +760,23 @@ export function UserFacilities(props: { user: any }) {
{/* Home Facility section */} {user?.home_facility_object && ( -
-
- {t("home_facility")} -
+
-
- {user?.home_facility_object?.name} +
+
+ {user?.home_facility_object?.name}{" "} + + + Home Facility + +
-
)} {/* Linked Facilities section */} {!!userFacilities?.results.length && ( -
-
- {t("linked_facilities")} -
+
{userFacilities.results.map( (facility: FacilityModel, i: number) => { From 63c90b90512a2cab4d3dc7e2e3aefe72916a4977 Mon Sep 17 00:00:00 2001 From: Ayush Chauhan <77507609+ayushchauhan12@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:22:53 +0530 Subject: [PATCH 4/6] changes made in i18n files (#7688) --- src/Components/Facility/ConsultationForm.tsx | 3 ++- src/Components/Patient/PatientInfoCard.tsx | 2 +- src/Locale/en/Common.json | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 6a33d1d1bdf..e0c79823434 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -64,6 +64,7 @@ import ConfirmDialog from "../Common/ConfirmDialog.js"; import request from "../../Utils/request/request.js"; import routes from "../../Redux/api.js"; import useQuery from "../../Utils/request/useQuery.js"; +import { t } from "i18next"; const Loading = lazy(() => import("../Common/Loading")); const PageTitle = lazy(() => import("../Common/PageTitle")); @@ -1477,7 +1478,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { > - Treating Physician:{" "} + {t("treating_doctor")}:{" "} {consultation?.treating_physician_object ? `${consultation?.treating_physician_object.first_name} ${consultation?.treating_physician_object.last_name}` diff --git a/src/Locale/en/Common.json b/src/Locale/en/Common.json index 84466c99a72..e2556587e96 100644 --- a/src/Locale/en/Common.json +++ b/src/Locale/en/Common.json @@ -162,5 +162,6 @@ "DD/MM/YYYY": "DD/MM/YYYY", "clear_all_filters": "Clear All Filters", "summary": "Summary", - "report": "Report" + "report": "Report", + "treating_doctor":"Treating Doctor" } \ No newline at end of file From 1ae0f334ca02401df88d9e3dd5626d3d64b928d2 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 30 Apr 2024 11:53:02 +0530 Subject: [PATCH 5/6] Adds missing required validation for death confirmed doctor in discharge as expired popup (#7683) * Adds missing required validation for death confirmed doctor in discharge as expired popup * fix error * fix error not shown --- src/Components/Facility/DischargeModal.tsx | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index c81ab2cf74e..e2dd14dce79 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -24,6 +24,7 @@ import CircularProgress from "../Common/components/CircularProgress"; import { FacilitySelect } from "../Common/FacilitySelect"; import { FacilityModel } from "./models"; import dayjs from "../../Utils/dayjs"; +import { FieldError } from "../Form/FieldValidators"; interface PreDischargeFormInterface { new_discharge_reason: number | null; @@ -121,15 +122,22 @@ const DischargeModal = ({ if ( preDischargeForm.new_discharge_reason == - DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && - !preDischargeForm.discharge_notes.trim() + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ) { - setErrors({ - ...errors, - discharge_notes: "Please enter the cause of death", - }); - setIsSendingDischargeApi(false); - return; + const newErrors: Record = {}; + + if (!preDischargeForm.discharge_notes.trim()) { + newErrors["discharge_notes"] = "Please enter the cause of death"; + } + if (!preDischargeForm.death_confirmed_doctor?.trim()) { + newErrors["death_confirmed_doctor"] = "Field is required"; + } + + if (Object.entries(newErrors).length) { + setErrors({ ...errors, ...newErrors }); + setIsSendingDischargeApi(false); + return; + } } const dischargeDetails = { @@ -310,6 +318,7 @@ const DischargeModal = ({ { setPreDischargeForm((form) => { From 4568e5ffcf60b28d64e7f938bfd0e60ebba1337f Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 1 May 2024 00:01:36 +0530 Subject: [PATCH 6/6] Fixes issue preventing from administering down titration prescriptions (#7743) * Fixes issues with administering down titration prescriptions * fix for create prescription form --- src/Components/Medicine/CreatePrescriptionForm.tsx | 2 +- src/Components/Medicine/EditPrescriptionForm.tsx | 2 +- .../AdministrationTableRow.tsx | 2 +- src/Components/Medicine/PrescriptionBuilder.tsx | 2 +- src/Components/Medicine/validators.ts | 14 ++++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Components/Medicine/CreatePrescriptionForm.tsx b/src/Components/Medicine/CreatePrescriptionForm.tsx index fcc9443eaa3..b918d5781fe 100644 --- a/src/Components/Medicine/CreatePrescriptionForm.tsx +++ b/src/Components/Medicine/CreatePrescriptionForm.tsx @@ -92,7 +92,7 @@ export default function CreatePrescriptionForm(props: { optionValue={(key) => key} /> {field("dosage_type").value === "TITRATED" ? ( -
+
key} /> {field("dosage_type").value === "TITRATED" ? ( -
+
{t("edit_caution_note")}
} - className="w-full max-w-3xl lg:min-w-[600px]" + className="w-full max-w-4xl lg:min-w-[768px]" > {t("modification_caution_note")}
} - className="w-full max-w-3xl lg:min-w-[600px]" + className="w-full max-w-4xl lg:min-w-[768px]" > targetDosage) - ) - return "Dosage should be between start and target dosage"; + if (baseDosage && targetDosage) { + const [min, max] = [baseDosage, targetDosage].sort((a, b) => a - b); + + if (!(min <= valueDosage && valueDosage <= max)) { + return "Dosage should be between start and target dosage"; + } + } }; };