diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index 5d271a0c3bb..cc2d1b7f921 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -30,9 +30,13 @@ describe("Facility Creation", () => { const doctorCapacity = "5"; const totalDoctor = "10"; const facilityName = "cypress facility"; + const facilityName2 = "Dummy Facility 1"; const facilityAddress = "cypress address"; const facilityUpdateAddress = "cypress updated address"; const facilityNumber = "9898469865"; + const triageDate = "02122023"; + const initialTriageValue = "60"; + const modifiedTriageValue = "50"; const facilityErrorMessage = [ "Required", "Invalid Pincode", @@ -50,6 +54,7 @@ describe("Facility Creation", () => { "Field is required", ]; const doctorErrorMessage = ["Field is required", "Field is required"]; + const triageErrorMessage = ["Field is required"]; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -62,6 +67,48 @@ describe("Facility Creation", () => { cy.awaitUrl("/facility"); }); + it("Verify Facility Triage Function", () => { + // mandatory field error throw + manageUserPage.typeFacilitySearch(facilityName2); + facilityPage.verifyFacilityBadgeContent(facilityName2); + manageUserPage.assertFacilityInCard(facilityName2); + facilityHome.verifyURLContains(facilityName2); + facilityPage.visitAlreadyCreatedFacility(); + facilityPage.scrollToFacilityTriage(); + facilityPage.clickAddFacilityTriage(); + manageUserPage.clickSubmit(); + userCreationPage.verifyErrorMessages(triageErrorMessage); + // create a entry and verify reflection + facilityPage.fillEntryDate(triageDate); + facilityPage.fillTriageEntryFields( + initialTriageValue, + initialTriageValue, + initialTriageValue, + initialTriageValue, + initialTriageValue + ); + manageUserPage.clickSubmit(); + // edit the entry and verify reflection + facilityPage.scrollToFacilityTriage(); + facilityPage.verifyTriageTableContains(initialTriageValue); + facilityPage.clickEditButton(); + facilityPage.fillTriageEntryFields( + modifiedTriageValue, + modifiedTriageValue, + modifiedTriageValue, + modifiedTriageValue, + modifiedTriageValue + ); + manageUserPage.clickSubmit(); + facilityPage.scrollToFacilityTriage(); + facilityPage.verifyTriageTableContains(modifiedTriageValue); + // validate error of filling data on same date already data exist and verify reflection + facilityPage.scrollToFacilityTriage(); + facilityPage.clickAddFacilityTriage(); + facilityPage.fillEntryDate(triageDate); + facilityPage.clickButtonsMultipleTimes("button#submit"); + }); + it("Create a new facility with multiple bed and doctor capacity", () => { // create facility with multiple capacity and verify form error message for facility form facilityPage.visitCreateFacilityPage(); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index b4d3808d645..c13f5beac8e 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -217,6 +217,53 @@ class FacilityPage { cy.get("#delete-facility").contains("Delete Facility").click(); } + scrollToFacilityTriage() { + cy.get("#add-facility-triage").scrollIntoView(); + } + + fillTriageEntryFields( + visited, + homeQuarantine, + isolation, + referred, + confirmedPositive + ) { + cy.get("#num_patients_visited").clear().click().type(visited); + cy.get("#num_patients_home_quarantine") + .clear() + .click() + .type(homeQuarantine); + cy.get("#num_patients_isolation").clear().click().type(isolation); + cy.get("#num_patient_referred").clear().click().type(referred); + cy.get("#num_patient_confirmed_positive") + .clear() + .click() + .type(confirmedPositive); + } + + fillEntryDate(date) { + cy.get("#entry_date").click(); + cy.get("#date-input").click().type(date); + } + + clickEditButton() { + cy.get("#edit-button").click(); + } + + clickButtonsMultipleTimes(selector) { + cy.get(selector).each(($button) => { + cy.wrap($button).click(); + }); + } + + verifyTriageTableContains(value) { + cy.get("#triage-table").contains(value); + } + + clickAddFacilityTriage() { + cy.get("#add-facility-triage").click(); + } + clickfacilityfeatureoption() { cy.get("#features").click(); } diff --git a/src/Components/Facility/FacilityHomeTriage.tsx b/src/Components/Facility/FacilityHomeTriage.tsx index f96a5181cfc..ba1cd199044 100644 --- a/src/Components/Facility/FacilityHomeTriage.tsx +++ b/src/Components/Facility/FacilityHomeTriage.tsx @@ -30,6 +30,7 @@ export const FacilityHomeTriage = (props: any) => { ); temp.push( {
Corona Triage
navigate(`/facility/${props.facilityId}/triage`)} authorizeFor={props.NonReadOnlyUsers} @@ -60,7 +62,10 @@ export const FacilityHomeTriage = (props: any) => { Add Triage
-
+