Skip to content

Commit

Permalink
facility page redirection (#7057)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Jan 19, 2024
1 parent cee0aef commit 1025347
Showing 5 changed files with 77 additions and 23 deletions.
7 changes: 0 additions & 7 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});
50 changes: 35 additions & 15 deletions cypress/e2e/facility_spec/facility_homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});
9 changes: 9 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});
24 changes: 24 additions & 0 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
@@ -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-]+/);
}
10 changes: 9 additions & 1 deletion src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
@@ -394,6 +394,7 @@ export const FacilityHome = (props: any) => {
</div>
<div className="flex flex-col justify-end">
<ButtonV2
id="facility-detailspage-cns"
variant="primary"
ghost
border
@@ -486,7 +487,13 @@ const LiveMonitoringButton = () => {
<Popover className="relative">
{permittedUserTypes.includes(authUser.user_type) && (
<Popover.Button className="mt-2 w-full">
<ButtonV2 variant="primary" ghost border className="w-full">
<ButtonV2
variant="primary"
ghost
border
className="w-full"
id="facility-detailspage-livemonitoring"
>
<CareIcon icon="l-video" className="text-lg" />
<span>Live Monitoring</span>
</ButtonV2>
@@ -524,6 +531,7 @@ const LiveMonitoringButton = () => {
</div>
</div>
<ButtonV2
id="live-monitoring-button"
disabled={!location}
className="w-full"
href={`/facility/${facilityId}/live-monitoring?location=${location}`}

0 comments on commit 1025347

Please sign in to comment.