diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts new file mode 100644 index 00000000000..67439e636dd --- /dev/null +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -0,0 +1,104 @@ +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(); + + 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); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index d39464ce14b..1f2726c79ab 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -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", () => { diff --git a/cypress/fixtures/facilitycoverimage.jpg b/cypress/fixtures/facilitycoverimage.jpg new file mode 100644 index 00000000000..95923ab68fb Binary files /dev/null and b/cypress/fixtures/facilitycoverimage.jpg differ diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index bb6cf0e19f2..4297179050b 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -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) { diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index 8924119510f..f836b0773f6 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -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(); } diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts new file mode 100644 index 00000000000..a7eab2884b4 --- /dev/null +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -0,0 +1,58 @@ +class FacilityManage { + clickCoverImage() { + cy.get("#facility-coverimage").click({ force: true }); + } + + verifyUploadButtonVisible() { + cy.get("#upload-cover-image").should("be.visible"); + } + + uploadCoverImage(fileName) { + cy.get("#upload-cover-image") + .selectFile(`cypress/fixtures/${fileName}`, { force: true }) + .wait(100); // Adjust the wait time as needed + } + + clickSaveCoverImage() { + cy.get("#save-cover-image").scrollIntoView(); + cy.get("#save-cover-image").click(); + } + + clickFacilityConfigureButton() { + cy.get("#configure-facility").should("be.visible"); + cy.get("#configure-facility").click(); + } + + verifyMiddlewareAddressVisible() { + cy.get("#middleware_address").should("be.visible"); + } + + clickButtonWithText(text) { + cy.get("button#submit").contains(text).click(); + } + + checkErrorMessageVisibility(text) { + cy.get(".error-text").contains(text).should("be.visible"); + } + + typeMiddlewareAddress(address) { + cy.get("#middleware_address").click().clear().click().type(address); + } + + typeHrfId(address) { + cy.get("#hf_id").click().clear().click().type(address); + } + + verifySuccessMessageVisibilityAndContent(text) { + cy.get(".pnotify-text").should("be.visible").and("contain", text); + } + + verifyMiddlewareAddressValue(expectedValue) { + cy.get("#middleware_address").should("have.value", expectedValue); + } + + verifyHrfIdValue(expectedValue) { + cy.get("#hf_id").should("have.value", expectedValue); + } +} +export default FacilityManage; diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index 4d723214604..11fd8b57107 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -248,7 +248,10 @@ const CoverImageEditModal = ({
-