Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6657
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharsh05 authored Nov 28, 2023
2 parents dff93a1 + 5cde457 commit 08777ef
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 31 deletions.
66 changes: 66 additions & 0 deletions cypress/e2e/facility_spec/facility_homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// FacilityCreation
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";

describe("Facility Creation", () => {
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();
const facilityPage = new FacilityPage();
const manageUserPage = new ManageUserPage();
const facilitiesAlias = "downloadFacilitiesCSV";
const capacitiesAlias = "downloadCapacitiesCSV";
const doctorsAlias = "downloadDoctorsCSV";
const triagesAlias = "downloadTriagesCSV";
const facilityname = "Dummy Facility 1";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.awaitUrl("/facility");
});

it("Search a facility in homepage", () => {
manageUserPage.typeFacilitySearch(facilityname);
facilityPage.verifyFacilityBadgeContent(facilityname);
manageUserPage.assertFacilityInCard(facilityname);
facilityHome.verifyURLContains(facilityname);
});

it("Verify Facility Export Functionality", () => {
// Download the Facilities CSV
facilityHome.csvDownloadIntercept(facilitiesAlias, "");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Facilities");
facilityHome.verifyDownload(facilitiesAlias);
facilityHome.clickSearchButton(); // to avoid flaky test, as sometimes, the test is unable to focus on the object
// Download the Capacities CSV
facilityHome.csvDownloadIntercept(capacitiesAlias, "&capacity");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Capacities");
facilityHome.verifyDownload(capacitiesAlias);
facilityHome.clickSearchButton();
// Download the Doctors CSV
facilityHome.csvDownloadIntercept(doctorsAlias, "&doctors");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Doctors");
facilityHome.verifyDownload(doctorsAlias);
facilityHome.clickSearchButton();
// Download the Triages CSV
facilityHome.csvDownloadIntercept(triagesAlias, "&triage");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Triages");
facilityHome.verifyDownload(triagesAlias);
facilityHome.clickSearchButton();
});

afterEach(() => {
cy.saveLocalStorage();
});
});
40 changes: 40 additions & 0 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// cypress/support/pageObjects/FacilityHome.ts

class FacilityHome {
// Selectors
exportButton = "#export-button";
searchButton = "#search";
menuItem = "[role='menuitem']";

// Operations
clickExportButton() {
cy.get(this.exportButton).click();
}

clickSearchButton() {
cy.get(this.searchButton).click();
}

clickMenuItem(itemName: string) {
cy.get(this.menuItem).contains(itemName).click();
}

csvDownloadIntercept(alias: string, queryParam: string) {
cy.intercept("GET", `**/api/v1/facility/?csv${queryParam}`).as(alias);
}

verifyDownload(alias: string) {
cy.wait(`@${alias}`).its("response.statusCode").should("eq", 200);
}

getURL() {
return cy.url();
}

verifyURLContains(searchText) {
const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+");
this.getURL().should("include", `search=${encodedText}`);
}
}

export default FacilityHome;
1 change: 0 additions & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export class PatientConsultationPage {
}

addDoctorsNotes(notes: string) {
cy.get("#expand_doctor_notes").click();
cy.get("#doctor_notes_textarea").type(notes);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ExportMenu = ({
const { isExporting, exportFile } = useExport();

return (
<div key="export-menu">
<div key="export-menu" id="export-button">
<DropdownMenu
disabled={isExporting || disabled}
title={isExporting ? "Exporting..." : label}
Expand Down
56 changes: 28 additions & 28 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,10 @@ export const ConsultationForm = (props: any) => {
: undefined,
consultation_notes: state.form.consultation_notes,
is_telemedicine: state.form.is_telemedicine,
icu_admission_date: state.form.icu_admission_date,
icu_admission_date:
state.form.route_to_facility === 30
? state.form.icu_admission_date
: undefined,
action: state.form.action,
review_interval: state.form.review_interval,
assigned_to:
Expand Down Expand Up @@ -947,7 +950,7 @@ export const ConsultationForm = (props: any) => {
required
label="Route to Facility"
{...field("route_to_facility")}
disabled={isUpdate}
disabled={isUpdate && !!state.form.route_to_facility} // For backwards compatibility; Allow in edit form only if route_to_facility is not set previously
/>
</div>

Expand Down Expand Up @@ -1199,9 +1202,7 @@ export const ConsultationForm = (props: any) => {
<div
className={classNames(
"col-span-6",
state.form.route_to_facility &&
[20, 30].includes(state.form.route_to_facility) &&
"xl:col-span-3"
state.form.route_to_facility === 30 && "xl:col-span-3"
)}
ref={fieldRef["admission_date"]}
>
Expand All @@ -1222,29 +1223,28 @@ export const ConsultationForm = (props: any) => {
</div>
)}

{state.form.route_to_facility &&
[20, 30].includes(state.form.route_to_facility) && (
<div
className={classNames(
"col-span-6",
["A", "DC"].includes(state.form.suggestion) &&
"xl:col-span-3"
)}
ref={fieldRef["icu_admission_date"]}
>
<TextFormField
{...field("icu_admission_date")}
label="Date & Time of admission to the ICU"
type="datetime-local"
value={
state.form.icu_admission_date &&
dayjs(state.form.icu_admission_date).format(
"YYYY-MM-DDTHH:mm"
)
}
/>
</div>
)}
{state.form.route_to_facility === 30 && (
<div
className={classNames(
"col-span-6",
["A", "DC"].includes(state.form.suggestion) &&
"xl:col-span-3"
)}
ref={fieldRef["icu_admission_date"]}
>
<TextFormField
{...field("icu_admission_date")}
label="Date & Time of admission to the ICU"
type="datetime-local"
value={
state.form.icu_admission_date &&
dayjs(state.form.icu_admission_date).format(
"YYYY-MM-DDTHH:mm"
)
}
/>
</div>
)}

{["A", "DC"].includes(state.form.suggestion) && !isUpdate && (
<div className="col-span-6 mb-6" ref={fieldRef["bed"]}>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/PatientNotesSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface PatientNotesProps {
}

export default function PatientNotesSlideover(props: PatientNotesProps) {
const [show, setShow] = useState(false);
const [show, setShow] = useState(true);
const [patientActive, setPatientActive] = useState(true);
const [noteField, setNoteField] = useState("");
const [reload, setReload] = useState(false);
Expand Down

0 comments on commit 08777ef

Please sign in to comment.