diff --git a/cypress/e2e/patient_spec/patient_consultation.cy.ts b/cypress/e2e/patient_spec/patient_consultation.cy.ts index 3bffa0081ce..f4e3b1f91de 100644 --- a/cypress/e2e/patient_spec/patient_consultation.cy.ts +++ b/cypress/e2e/patient_spec/patient_consultation.cy.ts @@ -59,7 +59,7 @@ describe("Patient Consultation in multiple combination", () => { patientConsultationPage.selectConsultationStatus( "Outpatient/Emergency Room" ); - patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); + cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC"); patientConsultationPage.typePatientIllnessHistory(patientIllnessHistory); patientConsultationPage.typePatientExaminationHistory( patientExaminationHistory @@ -175,7 +175,7 @@ describe("Patient Consultation in multiple combination", () => { "Outpatient/Emergency Room" ); // Asymptomatic - patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); + cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC"); // CRITICAL category patientConsultationPage.selectPatientCategory("Critical"); patientConsultationPage.selectPatientSuggestion("Declare Death"); @@ -233,7 +233,7 @@ describe("Patient Consultation in multiple combination", () => { ); patientConsultationPage.selectPatientWard("Dummy Location 1"); // Asymptomatic - patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); + cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC"); // Abnormal category patientConsultationPage.selectPatientCategory("Abnormal"); patientConsultationPage.selectPatientSuggestion("Domiciliary Care"); diff --git a/cypress/e2e/users_spec/user_manage.cy.ts b/cypress/e2e/users_spec/user_manage.cy.ts index 05e84715be1..af3b9149b2f 100644 --- a/cypress/e2e/users_spec/user_manage.cy.ts +++ b/cypress/e2e/users_spec/user_manage.cy.ts @@ -38,8 +38,7 @@ describe("Manage User", () => { userPage.typeInSearchInput(usernameforworkinghour); userPage.checkUsernameText(usernameforworkinghour); manageUserPage.clicklinkedskillbutton(); - manageUserPage.typeSkill(linkedskill); - manageUserPage.selectFacilityFromDropdown(linkedskill); + manageUserPage.selectSkillFromDropdown(linkedskill); manageUserPage.clickAddSkillButton(); manageUserPage.clickCloseSlideOver(); cy.wait(5000); @@ -60,8 +59,7 @@ describe("Manage User", () => { userPage.typeInSearchInput(usernametolinkskill); userPage.checkUsernameText(usernametolinkskill); manageUserPage.clicklinkedskillbutton(); - manageUserPage.typeSkill(linkedskill); - manageUserPage.selectFacilityFromDropdown(linkedskill); + manageUserPage.selectSkillFromDropdown(linkedskill); manageUserPage.clickAddSkillButton(); manageUserPage.clickCloseSlideOver(); cy.wait(5000); // temporary hack to fix the failure @@ -69,8 +67,7 @@ describe("Manage User", () => { manageUserPage.assertSkillInAddedUserSkills(linkedskill); manageUserPage.clickUnlinkSkill(); manageUserPage.clickSubmit(); - manageUserPage.typeSkill(linkedskill); - manageUserPage.selectFacilityFromDropdown(linkedskill); + manageUserPage.selectSkillFromDropdown(linkedskill); manageUserPage.clickAddSkillButton(); manageUserPage.clickCloseSlideOver(); // verifying the doctor connect @@ -105,7 +102,6 @@ describe("Manage User", () => { manageUserPage.assertHomeFacility("No Home Facility"); // Link a new facility and ensure it is under linked facility - doctor username (1) manageUserPage.clickFacilitiesTab(); - manageUserPage.typeFacilityName(facilitytolinkusername); manageUserPage.selectFacilityFromDropdown(facilitytolinkusername); manageUserPage.clickLinkFacility(); manageUserPage.assertLinkedFacility(facilitytolinkusername); @@ -117,7 +113,6 @@ describe("Manage User", () => { userPage.typeInSearchInput(usernametolinkfacilitydoc2); userPage.checkUsernameText(usernametolinkfacilitydoc2); manageUserPage.clickFacilitiesTab(); - manageUserPage.typeFacilityName(facilitytolinkusername); manageUserPage.selectFacilityFromDropdown(facilitytolinkusername); manageUserPage.clickLinkFacility(); manageUserPage.clickHomeFacilityIcon(); @@ -134,7 +129,6 @@ describe("Manage User", () => { userPage.typeInSearchInput(usernametolinkfacilitydoc3); userPage.checkUsernameText(usernametolinkfacilitydoc3); manageUserPage.clickFacilitiesTab(); - manageUserPage.typeFacilityName(facilitytolinkusername); manageUserPage.selectFacilityFromDropdown(facilitytolinkusername); manageUserPage.clickLinkFacility(); manageUserPage.clickUnlinkFacilityButton(); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index f799197b7cb..8cc340ce217 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -66,8 +66,7 @@ class FacilityPage { } selectBedType(bedType: string) { - cy.get("div#bed-type button").click(); - cy.get("[role='option']").contains(bedType).click(); + cy.clickAndSelectOption("div#bed-type button", bedType); } isVisibleselectBedType() { diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index 622229745f7..b0b466e3f13 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -7,12 +7,12 @@ export class ManageUserPage { cy.get("#facilities").click(); } - typeFacilityName(facilityName) { - cy.get("input[name='facility']").click().type(facilityName); + selectFacilityFromDropdown(facilityName) { + cy.searchAndSelectOption("input[name='facility']", facilityName); } - selectFacilityFromDropdown(facilityName) { - cy.get("[role='option']").contains(facilityName).click(); + selectSkillFromDropdown(skill) { + cy.searchAndSelectOption("input[name='skill']", skill); } clickLinkFacility() { @@ -36,7 +36,7 @@ export class ManageUserPage { } assertFacilityNotInDropdown(facilityName) { - this.typeFacilityName(facilityName); + cy.get("input[name='facility']").click().type(facilityName); cy.get("[role='option']").should("not.exist"); } @@ -129,10 +129,6 @@ export class ManageUserPage { .should("have.length", 1); } - typeSkill(skillName) { - cy.get("#select-skill").click().type(skillName); - } - clickDoctorConnectButton() { cy.get("#doctor-connect-patient-button").click(); } diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 60530cb0634..19c00a6fb01 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -272,7 +272,7 @@ export const REVIEW_AT_CHOICES: Array = [ ]; export const SYMPTOM_CHOICES = [ - { id: 1, text: "ASYMPTOMATIC" }, + { id: 1, text: "ASYMPTOMATIC", isSingleSelect: true }, { id: 2, text: "FEVER" }, { id: 3, text: "SORE THROAT" }, { id: 4, text: "COUGH" }, @@ -689,20 +689,20 @@ export const MOTOR_RESPONSE_SCALE = [ { value: 2, text: "Abnormal Extension(decerebrate)" }, { value: 1, text: "No Response" }, ]; -export const CONSULTATION_TABS: Array = [ - { id: 1, text: "UPDATES", desc: "Updates" }, - { id: 13, text: "FEED", desc: "Feed" }, - { id: 2, text: "SUMMARY", desc: "Summary" }, - { id: 3, text: "MEDICINES", desc: "Medicines" }, - { id: 4, text: "FILES", desc: "Files" }, - { id: 5, text: "INVESTIGATIONS", desc: "Investigations" }, - { id: 6, text: "ABG", desc: "ABG" }, - { id: 7, text: "NURSING", desc: "Nursing" }, - { id: 8, text: "NEUROLOGICAL_MONITORING", desc: "Neurological Monitoring" }, - { id: 9, text: "VENTILATOR", desc: "Respiratory Support" }, - { id: 10, text: "NUTRITION", desc: "Nutrition" }, - { id: 11, text: "PRESSURE_SORE", desc: "Pressure Sore" }, - { id: 12, text: "DIALYSIS", desc: "Dialysis" }, +export const CONSULTATION_TABS = [ + { text: "UPDATES", desc: "Overview" }, + { text: "FEED", desc: "Feed" }, + { text: "SUMMARY", desc: "Vitals" }, + { text: "ABG", desc: "ABG" }, + { text: "MEDICINES", desc: "Medicines" }, + { text: "FILES", desc: "Files" }, + { text: "INVESTIGATIONS", desc: "Investigations" }, + { text: "NEUROLOGICAL_MONITORING", desc: "Neuro" }, + { text: "VENTILATOR", desc: "Ventilation" }, + { text: "NUTRITION", desc: "Nutrition" }, + { text: "PRESSURE_SORE", desc: "Pressure Sore" }, + { text: "NURSING", desc: "Nursing" }, + { text: "DIALYSIS", desc: "Dialysis" }, ]; export const RHYTHM_CHOICES: Array = [ diff --git a/src/Components/Form/MultiSelectMenuV2.tsx b/src/Components/Form/MultiSelectMenuV2.tsx index 25cd226e09e..7a976b86bb7 100644 --- a/src/Components/Form/MultiSelectMenuV2.tsx +++ b/src/Components/Form/MultiSelectMenuV2.tsx @@ -2,7 +2,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon"; import { DropdownTransition } from "../Common/components/HelperComponents"; import { Listbox } from "@headlessui/react"; import { classNames } from "../../Utils/utils"; -import { ReactNode } from "react"; +import { ReactNode, useRef } from "react"; type OptionCallback = (option: T) => R; @@ -61,9 +61,18 @@ const MultiSelectMenuV2 = (props: Props) => { if (selectedOptions.length === 0) return placeholder; if (props.renderSelectedOptions) return props.renderSelectedOptions(selectedOptions.map((o) => o.option)); - return ( - {`${selectedOptions.length} item(s) selected`} - ); + }; + + const buttonRef = useRef(null); + + const handleSingleSelect = (o: any) => { + if ( + o.option?.isSingleSelect === true && + !selectedOptions.includes(o) && + buttonRef.current + ) { + buttonRef.current.click(); + } }; return ( @@ -83,23 +92,39 @@ const MultiSelectMenuV2 = (props: Props) => {
- +

+ + {selectedOptions.length !== 0 && ( +
+ {selectedOptions.map((option) => ( + { + const updatedOptions = selectedOptions.filter( + (selectedOption) => + selectedOption.value !== option.value + ); + props.onChange( + updatedOptions.map((o) => o.value) as any + ); + }} + /> + ))} +
+ )}
- {selectedOptions.length !== 0 && ( -
- {selectedOptions.map((option) => ( - - ))} -
- )}
@@ -109,6 +134,7 @@ const MultiSelectMenuV2 = (props: Props) => { key={index} className={dropdownOptionClassNames} value={option} + onClick={() => handleSingleSelect(option)} > {({ active }) => (
@@ -154,7 +180,7 @@ interface MultiSelectOptionChipProps { export const MultiSelectOptionChip = (props: MultiSelectOptionChipProps) => { return ( -

{props.label}

+

{props.label}

{props.onRemove && (