From 102534718b46bab42ddf07b1834afaa83be9d505 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:54:08 +0530 Subject: [PATCH] facility page redirection (#7057) --- .../e2e/facility_spec/facility_creation.cy.ts | 7 --- .../e2e/facility_spec/facility_homepage.cy.ts | 50 +++++++++++++------ .../e2e/facility_spec/facility_manage.cy.ts | 9 ++++ cypress/pageobject/Facility/FacilityHome.ts | 24 +++++++++ src/Components/Facility/FacilityHome.tsx | 10 +++- 5 files changed, 77 insertions(+), 23 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index f8001584ac3..ab9d72f430f 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -297,13 +297,6 @@ describe("Facility Creation", () => { facilityPage.verifySuccessNotification("Facility updated successfully"); }); - it("Delete a facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl1); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickDeleteFacilityOption(); - facilityPage.confirmDeleteFacility(); - }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/facility_spec/facility_homepage.cy.ts b/cypress/e2e/facility_spec/facility_homepage.cy.ts index 7269c3a2581..5d1cef4efcf 100644 --- a/cypress/e2e/facility_spec/facility_homepage.cy.ts +++ b/cypress/e2e/facility_spec/facility_homepage.cy.ts @@ -18,11 +18,12 @@ describe("Facility Homepage Function", () => { const capacitiesAlias = "downloadCapacitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; const triagesAlias = "downloadTriagesCSV"; - const facilityname = "Dummy Facility 1"; - const statename = "Kerala"; + const facilityName = "Dummy Facility 1"; + const facilityLocaion = "Dummy Location"; + const stateName = "Kerala"; const district = "Ernakulam"; - const localbody = "Aikaranad"; - const facilitytype = "Private Hospital"; + const localBody = "Aikaranad"; + const facilityType = "Private Hospital"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -58,16 +59,16 @@ describe("Facility Homepage Function", () => { it("Verify the functionality of advance filter", () => { userPage.clickAdvancedFilters(); - facilityPage.selectState(statename); + facilityPage.selectState(stateName); facilityPage.selectDistrict(district); - facilityPage.selectLocalBody(localbody); - facilityPage.clickUpdateFacilityType(facilitytype); + facilityPage.selectLocalBody(localBody); + facilityPage.clickUpdateFacilityType(facilityType); userPage.applyFilter(); - facilityPage.verifyStateBadgeContent(statename); + facilityPage.verifyStateBadgeContent(stateName); facilityPage.verifyDistrictBadgeContent(district); - facilityPage.verifyLocalBodyBadgeContent(localbody); - facilityPage.verifyFacilityTypeBadgeContent(facilitytype); - manageUserPage.assertFacilityInCard(facilityname); + facilityPage.verifyLocalBodyBadgeContent(localBody); + facilityPage.verifyFacilityTypeBadgeContent(facilityType); + manageUserPage.assertFacilityInCard(facilityName); userPage.clearFilters(); userPage.verifyDataTestIdNotVisible("State"); userPage.verifyDataTestIdNotVisible("District"); @@ -80,10 +81,10 @@ describe("Facility Homepage Function", () => { assetPagination.navigateToNextPage(); assetPagination.navigateToPreviousPage(); // search for a facility - manageUserPage.typeFacilitySearch(facilityname); - facilityPage.verifyFacilityBadgeContent(facilityname); - manageUserPage.assertFacilityInCard(facilityname); - facilityHome.verifyURLContains(facilityname); + manageUserPage.typeFacilitySearch(facilityName); + facilityPage.verifyFacilityBadgeContent(facilityName); + manageUserPage.assertFacilityInCard(facilityName); + facilityHome.verifyURLContains(facilityName); }); it("Verify Facility Export Functionality", () => { @@ -113,6 +114,25 @@ describe("Facility Homepage Function", () => { facilityHome.clickSearchButton(); }); + it("Verify Facility Detail page redirection to CNS and Live Minitoring ", () => { + userPage.clickAdvancedFilters(); + facilityPage.selectState(stateName); + facilityPage.selectDistrict(district); + facilityPage.selectLocalBody(localBody); + userPage.applyFilter(); + // go to cns page in the facility details page + manageUserPage.assertFacilityInCard(facilityName); + facilityHome.clickViewFacilityDetails(); + facilityHome.clickFacilityCnsButton(); + facilityHome.verifyCnsUrl(); + facilityHome.navigateBack(); + // go to live monitoring page in the facility details page + facilityHome.clickFacilityLiveMonitorButton(); + facilityHome.selectLocation(facilityLocaion); + facilityHome.clickLiveMonitorButton(); + facilityHome.verifyLiveMonitorUrl(); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts index 15323281de6..11c75949af1 100644 --- a/cypress/e2e/facility_spec/facility_manage.cy.ts +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -160,6 +160,15 @@ describe("Facility Manage Functions", () => { ); }); + it("Delete a existing facility and verify the error message", () => { + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickDeleteFacilityOption(); + facilityPage.confirmDeleteFacility(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "You do not have permission to perform this action." + ); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index 03f2be9b19b..fa163757584 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -31,10 +31,34 @@ class FacilityHome { cy.url().should("include", "/cns"); } + verifyLiveMonitorUrl() { + cy.url().should("include", "/live-monitoring?location="); + } + clickFacilityNotifyButton() { cy.get("#facility-notify").first().click(); } + clickLiveMonitorButton() { + cy.get("#live-monitoring-button").scrollIntoView(); + cy.get("#live-monitoring-button").click(); + } + + clickFacilityLiveMonitorButton() { + cy.get("#facility-detailspage-livemonitoring").scrollIntoView(); + cy.get("#facility-detailspage-livemonitoring").click(); + } + + clickFacilityCnsButton() { + cy.get("#facility-detailspage-cns").scrollIntoView(); + cy.get("#facility-detailspage-cns").click(); + } + + selectLocation(location) { + cy.get("#location").click().type(location); + cy.get("li[role=option]").contains(location).click(); + } + verifyFacilityDetailsUrl() { cy.url().should("match", /\/facility\/[\w-]+/); } diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index acf6324f5a5..6f42dab00a6 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -394,6 +394,7 @@ export const FacilityHome = (props: any) => {