Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6771
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevildude authored Jan 20, 2024
2 parents a61ae30 + f6159eb commit d3c1a9f
Show file tree
Hide file tree
Showing 38 changed files with 545 additions and 110 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/death_report_spec/death_report.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ describe("Death Report", () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
cy.awaitUrl("/patients");
cy.intercept("**/api/v1/patient/**").as("getPatients");
cy.get("#facility-patients").contains("Patients").click({ force: true });
cy.url().should("include", "/patients");
cy.wait("@getPatients").get("a[data-cy=patient]").first().click();
cy.url().then((url) => {
Expand Down
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
175 changes: 175 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityManage from "../../pageobject/Facility/FacilityManage";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { v4 as uuidv4 } from "uuid";

describe("Facility Manage Functions", () => {
const loginPage = new LoginPage();
const facilityManage = new FacilityManage();
const facilityPage = new FacilityPage();
const facilityMiddlewareUpdateButton = "Update";
const facilityMiddleware = "dev-middleware.coronasafe.live";
const facilityUpdatedMiddleware = "updated.coronasafe.live";
const facilityMiddlewareSuccessfullNotification =
"Facility updated successfully";
const facilityHrfidUpdateButton = "Link Health Facility";
const facilityHrfidSuccessfullNotification =
"Health Facility config updated successfully";
const facilityHrfId = uuidv4();
const facilityUpdatedHrfId = uuidv4();
const doctorCapacity = "5";
const doctorModifiedCapacity = "7";
const totalCapacity = "100";
const currentOccupied = "80";
const totalUpdatedCapacity = "120";
const currentUpdatedOccupied = "100";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.viewport(1280, 720);
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
facilityPage.visitAlreadyCreatedFacility();
});

it("Facility Cover Image button functionality", () => {
// It's only button functionality because we can't access S3 bucket in local
facilityManage.clickCoverImage();
facilityManage.verifyUploadButtonVisible();
facilityManage.uploadCoverImage("facilitycoverimage.jpg");
facilityManage.clickSaveCoverImage();
});

it("Configure Facility Middleware", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressVisible();
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Middleware Address is required"
);
// add middleware and verify the notification
facilityManage.typeMiddlewareAddress(facilityMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressVisible();
facilityManage.typeMiddlewareAddress(facilityUpdatedMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
);
// verify the updated middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressValue(facilityUpdatedMiddleware);
});

it("Configure Facility Health ID", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Health Facility Id is required"
);
// add facility health ID and verify notification
facilityManage.typeHrfId(facilityHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.typeHrfId(facilityUpdatedHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
);
// verify its reflection
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyHrfIdValue(facilityUpdatedHrfId);
});

it("Modify doctor capacity in Facility detail page", () => {
// Add a doctor capacity
facilityManage.clickFacilityAddDoctorTypeButton();
facilityPage.selectAreaOfSpecialization("General Medicine");
facilityPage.fillDoctorCount(doctorCapacity);
facilityPage.saveAndExitDoctorForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count added successfully"
);
facilityManage.verifyTotalDoctorCapacity(doctorCapacity);
// edit a existing doctor
facilityManage.clickEditFacilityDoctorCapacity();
facilityPage.fillDoctorCount(doctorModifiedCapacity);
facilityPage.clickdoctorcapacityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count updated successfully"
);
facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity);
// delete a bed
facilityManage.clickDeleteFacilityDoctorCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor specialization type deleted successfully"
);
});

it("Modify bed capacity in Facility detail page", () => {
// add multiple new bed capacity
facilityManage.clickFacilityAddBedTypeButton();
facilityPage.selectBedType("Oxygen beds");
facilityPage.fillTotalCapacity(totalCapacity);
facilityPage.fillCurrentlyOccupied(currentOccupied);
facilityPage.saveAndExitBedCapacityForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity added successfully"
);
facilityManage.verifyFacilityBedCapacity(totalCapacity);
facilityManage.verifyFacilityBedCapacity(currentOccupied);
// edit a existing bed
facilityManage.clickEditFacilityBedCapacity();
facilityPage.fillTotalCapacity(totalUpdatedCapacity);
facilityPage.fillCurrentlyOccupied(currentUpdatedOccupied);
facilityPage.clickbedcapcityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed capacity updated successfully"
);
facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity);
facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied);
// delete a bed
facilityManage.clickDeleteFacilityBedCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Bed type deleted successfully"
);
});

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();
});
});
10 changes: 3 additions & 7 deletions cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ describe("Location Management Section", () => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-details']").first().click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
cy.get("#manage-facility-dropdown button").should("be.visible");
cy.get("[id='manage-facility-dropdown']").scrollIntoView().click();
cy.get("[id=location-management]").click();
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityLocation.clickFacilityLocationManagement();
});

it("Add a Bed to facility location along with duplication and deleting a bed", () => {
Expand Down
Binary file added cypress/fixtures/facilitycoverimage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class FacilityPage {
}

fillTotalCapacity(capacity: string) {
cy.get("input#total-capacity").click().type(capacity);
cy.get("input#total-capacity").click().clear().click().type(capacity);
}

fillCurrentlyOccupied(occupied: string) {
cy.get("input#currently-occupied").click().type(occupied);
cy.get("input#currently-occupied").click().clear().click().type(occupied);
}

saveAndExitBedCapacityForm() {
Expand All @@ -96,7 +96,7 @@ class FacilityPage {
}

fillDoctorCount(count: string) {
cy.get("input#count").click().type(count);
cy.get("input#count").click().clear().click().type(count);
}

fillOxygenCapacity(capacity: string) {
Expand Down Expand Up @@ -321,6 +321,7 @@ class FacilityPage {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-details']").first().click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
}

verifyFacilityBadgeContent(expectedText: string) {
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
4 changes: 4 additions & 0 deletions cypress/pageobject/Facility/FacilityLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class FacilityLocation {
cy.get("#add-new-location").click();
}

clickFacilityLocationManagement() {
cy.get("[id=location-management]").click();
}

clickEditLocationButton() {
cy.get("#edit-location-button").click();
}
Expand Down
Loading

0 comments on commit d3c1a9f

Please sign in to comment.