diff --git a/cypress/e2e/facility_spec/facility_homepage.cy.ts b/cypress/e2e/facility_spec/facility_homepage.cy.ts new file mode 100644 index 00000000000..6f53f554835 --- /dev/null +++ b/cypress/e2e/facility_spec/facility_homepage.cy.ts @@ -0,0 +1,54 @@ +// FacilityCreation +import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import FacilityHome from "../../pageobject/Facility/FacilityHome"; + +describe("Facility Creation", () => { + const loginPage = new LoginPage(); + const facilityHome = new FacilityHome(); + const facilitiesAlias = "downloadFacilitiesCSV"; + const capacitiesAlias = "downloadCapacitiesCSV"; + const doctorsAlias = "downloadDoctorsCSV"; + const triagesAlias = "downloadTriagesCSV"; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.viewport(1280, 720); + cy.restoreLocalStorage(); + cy.awaitUrl("/facility"); + }); + + 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(); + }); +}); diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts new file mode 100644 index 00000000000..faf6747e024 --- /dev/null +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -0,0 +1,31 @@ +// 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); + } +} + +export default FacilityHome; diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 4fb299a4965..9c588f50c4e 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -203,7 +203,6 @@ export class PatientConsultationPage { } addDoctorsNotes(notes: string) { - cy.get("#expand_doctor_notes").click(); cy.get("#doctor_notes_textarea").type(notes); } diff --git a/src/Components/Common/Export.tsx b/src/Components/Common/Export.tsx index f991c476aac..7ddaca115bd 100644 --- a/src/Components/Common/Export.tsx +++ b/src/Components/Common/Export.tsx @@ -40,7 +40,7 @@ export const ExportMenu = ({ const { isExporting, exportFile } = useExport(); return ( -
+
{ : 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: @@ -1195,9 +1198,7 @@ export const ConsultationForm = (props: any) => {
@@ -1218,29 +1219,28 @@ export const ConsultationForm = (props: any) => {
)} - {state.form.route_to_facility && - [20, 30].includes(state.form.route_to_facility) && ( -
- -
- )} + {state.form.route_to_facility === 30 && ( +
+ +
+ )} {["A", "DC"].includes(state.form.suggestion) && !isUpdate && (