Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Cypress Test | Verify Facility Detail Page redirection | Facility Module #7057

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
50 changes: 35 additions & 15 deletions cypress/e2e/facility_spec/facility_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand All @@ -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", () => {
Expand Down Expand Up @@ -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();
});
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
24 changes: 24 additions & 0 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-]+/);
}
Expand Down
10 changes: 9 additions & 1 deletion src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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}`}
Expand Down
Loading