From 8e76e29947e98768aad476fa680566d14ad904b8 Mon Sep 17 00:00:00 2001 From: rohitlingarker Date: Mon, 25 Nov 2024 08:39:30 +0530 Subject: [PATCH] Moved facility-cover-image-test to a new file --- .../facility_spec/FacilityCoverImage.cy.ts | 56 +++ .../e2e/facility_spec/FacilityManage.cy.ts | 332 ++++++++---------- 2 files changed, 208 insertions(+), 180 deletions(-) create mode 100644 cypress/e2e/facility_spec/FacilityCoverImage.cy.ts diff --git a/cypress/e2e/facility_spec/FacilityCoverImage.cy.ts b/cypress/e2e/facility_spec/FacilityCoverImage.cy.ts new file mode 100644 index 00000000000..45faeff7ac0 --- /dev/null +++ b/cypress/e2e/facility_spec/FacilityCoverImage.cy.ts @@ -0,0 +1,56 @@ +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import FacilityManage from "../../pageobject/Facility/FacilityManage"; + +const roleUserFacilities = [ + { username: "devdistrictadmin", facilityName: "Dummy Facility 40" }, + { username: "devdoctor", facilityName: "Dummy Facility 4" }, +]; + +roleUserFacilities.forEach(({ username, facilityName }) => { + describe("Facility Cover Image Functionality", () => { + const facilityManage = new FacilityManage(); + const facilityPage = new FacilityPage(); + + before(() => { + cy.loginByApi(username, "Coronasafe@123"); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.viewport(1280, 720); + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/"); + facilityPage.typeFacilitySearch(facilityName); + facilityPage.verifyFacilityBadgeContent(facilityName); + facilityPage.visitAlreadyCreatedFacility(); + }); + + it("Facility Cover Image button functionality", () => { + // It's only button functionality because we can't access S3 bucket in local + // Check: Cancel button functionality + facilityManage.clickCoverImage(); + facilityManage.clickCancelButton(); + facilityManage.verifyCoverImageModalClosed(); + // Check: upload an image, verifying the API response. + facilityManage.clickCoverImage(); + facilityManage.verifyUploadButtonVisible(); + facilityManage.uploadCoverImage("facility-cover-image.jpg"); + facilityManage.clickSaveCoverImage(); + facilityManage.verifyCoverImageModalClosed(); + // //Check: Edit the current cover image by uploading a new one, and verify the API response. + facilityManage.clickCoverImage(); + facilityManage.verifyUploadButtonVisible(); + facilityManage.uploadCoverImage("new-facility-cover-image.jpg"); + facilityManage.clickSaveCoverImage(); + facilityManage.verifyCoverImageModalClosed(); + //Check: Delete the existing cover image, confirming the API response. + facilityManage.clickCoverImage(); + facilityManage.clickDeleteCoverImage(); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); + }); +}); diff --git a/cypress/e2e/facility_spec/FacilityManage.cy.ts b/cypress/e2e/facility_spec/FacilityManage.cy.ts index 08b777a0214..4e7e824a8e3 100644 --- a/cypress/e2e/facility_spec/FacilityManage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityManage.cy.ts @@ -1,192 +1,164 @@ import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import FacilityManage from "../../pageobject/Facility/FacilityManage"; +import LoginPage from "../../pageobject/Login/LoginPage"; -// import LoginPage from "../../pageobject/Login/LoginPage"; +describe("Facility Manage Functions", () => { + const loginPage = new LoginPage(); + const facilityManage = new FacilityManage(); + const facilityPage = new FacilityPage(); + const facilityName = "Dummy Facility 40"; + const facilityMiddlewareUpdateButton = "Update"; + const facilityMiddleware = "dev-middleware.coronasafe.live"; + const facilityUpdatedMiddleware = "updated.coronasafe.live"; + const facilityMiddlewareSuccessfullNotification = + "Facility middleware updated successfully"; + // const facilityHfridUpdateButton = "Link Health Facility"; + // const facilityHfridToastNotificationText = /Health Facility config updated successfully|Health ID registration failed/; + // const facilityHfrId = "IN180000018"; + // const facilityUpdatedHfrId = uuidv4(); + const doctorCapacity = "5"; + const doctorModifiedCapacity = "7"; + const totalCapacity = "100"; + const currentOccupied = "80"; + const totalUpdatedCapacity = "120"; + const currentUpdatedOccupied = "100"; -const roleUsernames = ["devdistrictadmin", "devdoctor"]; -roleUsernames.forEach((username) => { - describe("Facility Manage Functions", () => { - // const loginPage = new LoginPage(); - const facilityManage = new FacilityManage(); - const facilityPage = new FacilityPage(); - const facilityName = "Dummy Facility 40"; - const facilityMiddlewareUpdateButton = "Update"; - const facilityMiddleware = "dev-middleware.coronasafe.live"; - const facilityUpdatedMiddleware = "updated.coronasafe.live"; - const facilityMiddlewareSuccessfullNotification = - "Facility middleware updated successfully"; - // const facilityHfridUpdateButton = "Link Health Facility"; - // const facilityHfridToastNotificationText = /Health Facility config updated successfully|Health ID registration failed/; - // const facilityHfrId = "IN180000018"; - // const facilityUpdatedHfrId = uuidv4(); - const doctorCapacity = "5"; - const doctorModifiedCapacity = "7"; - const totalCapacity = "100"; - const currentOccupied = "80"; - const totalUpdatedCapacity = "120"; - const currentUpdatedOccupied = "100"; - - before(() => { - // loginPage.loginAsDistrictAdmin(); - cy.loginByApi(username, "Coronasafe@123"); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.viewport(1280, 720); - cy.restoreLocalStorage(); - cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/"); - facilityPage.typeFacilitySearch(facilityName); - facilityPage.verifyFacilityBadgeContent(facilityName); - facilityPage.visitAlreadyCreatedFacility(); - }); + before(() => { + loginPage.loginAsDistrictAdmin(); + cy.saveLocalStorage(); + }); - it("Facility Cover Image button functionality", () => { - // It's only button functionality because we can't access S3 bucket in local - // Check: Cancel button functionality - facilityManage.clickCoverImage(); - facilityManage.clickCancelButton(); - facilityManage.verifyCoverImageModalClosed(); - // Check: upload an image, verifying the API response. - facilityManage.clickCoverImage(); - facilityManage.verifyUploadButtonVisible(); - facilityManage.uploadCoverImage("facility-cover-image.jpg"); - facilityManage.clickSaveCoverImage(); - facilityManage.verifyCoverImageModalClosed(); - // //Check: Edit the current cover image by uploading a new one, and verify the API response. - facilityManage.clickCoverImage(); - facilityManage.verifyUploadButtonVisible(); - facilityManage.uploadCoverImage("new-facility-cover-image.jpg"); - facilityManage.clickSaveCoverImage(); - facilityManage.verifyCoverImageModalClosed(); - //Check: Delete the existing cover image, confirming the API response. - facilityManage.clickCoverImage(); - facilityManage.clickDeleteCoverImage(); - }); + beforeEach(() => { + cy.viewport(1280, 720); + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/"); + facilityPage.typeFacilitySearch(facilityName); + facilityPage.verifyFacilityBadgeContent(facilityName); + facilityPage.visitAlreadyCreatedFacility(); + }); - 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 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); + }); - // TODO: enable this test after configuring testing specs for plugs - // it("Configure Facility Health ID", () => { - // facilityPage.clickManageFacilityDropdown(); - // facilityManage.clickFacilityConfigureButton(); - // // verify mandatory field error message - // facilityManage.clearHfrId(); - // facilityManage.clickButtonWithText(facilityHfridUpdateButton); - // facilityManage.checkErrorMessageVisibility( - // "Health Facility Id is required", - // ); - // // add facility health ID and verify notification - // facilityManage.typeHfrId(facilityHfrId); - // facilityManage.clickButtonWithText(facilityHfridUpdateButton); - // facilityManage.verifySuccessMessageVisibilityAndContent( - // facilityHfridToastNotificationText, - // true, - // ); - // // update the existing middleware - // facilityPage.clickManageFacilityDropdown(); - // facilityManage.clickFacilityConfigureButton(); - // facilityManage.typeHfrId(facilityUpdatedHfrId); - // facilityManage.clickButtonWithText(facilityHfridUpdateButton); - // facilityManage.verifySuccessMessageVisibilityAndContent( - // facilityHfridToastNotificationText, - // true, - // ); - // // verify its reflection - // facilityPage.clickManageFacilityDropdown(); - // facilityManage.clickFacilityConfigureButton(); - // facilityManage.verifyHfrIdValue(facilityUpdatedHfrId); - // }); + // TODO: enable this test after configuring testing specs for plugs + // it("Configure Facility Health ID", () => { + // facilityPage.clickManageFacilityDropdown(); + // facilityManage.clickFacilityConfigureButton(); + // // verify mandatory field error message + // facilityManage.clearHfrId(); + // facilityManage.clickButtonWithText(facilityHfridUpdateButton); + // facilityManage.checkErrorMessageVisibility( + // "Health Facility Id is required", + // ); + // // add facility health ID and verify notification + // facilityManage.typeHfrId(facilityHfrId); + // facilityManage.clickButtonWithText(facilityHfridUpdateButton); + // facilityManage.verifySuccessMessageVisibilityAndContent( + // facilityHfridToastNotificationText, + // true, + // ); + // // update the existing middleware + // facilityPage.clickManageFacilityDropdown(); + // facilityManage.clickFacilityConfigureButton(); + // facilityManage.typeHfrId(facilityUpdatedHfrId); + // facilityManage.clickButtonWithText(facilityHfridUpdateButton); + // facilityManage.verifySuccessMessageVisibilityAndContent( + // facilityHfridToastNotificationText, + // true, + // ); + // // verify its reflection + // facilityPage.clickManageFacilityDropdown(); + // facilityManage.clickFacilityConfigureButton(); + // facilityManage.verifyHfrIdValue(facilityUpdatedHfrId); + // }); - it("Modify doctor capacity in Facility detail page", () => { - // Add a doctor capacity - facilityManage.clickFacilityAddDoctorTypeButton(); - facilityPage.selectAreaOfSpecialization("Pulmonology"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.saveAndExitDoctorForm(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff count added successfully", - ); - facilityManage.verifyTotalDoctorCapacity(doctorCapacity); - // edit a existing doctor - facilityManage.clickEditFacilityDoctorCapacity(); - facilityPage.fillDoctorCount(doctorModifiedCapacity); - facilityPage.clickdoctorcapacityaddmore(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff count updated successfully", - ); - facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity); - // delete a bed - facilityManage.clickDeleteFacilityDoctorCapacity(); - facilityManage.clickButtonWithText("Delete"); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff specialization type deleted successfully", - ); - }); + it("Modify doctor capacity in Facility detail page", () => { + // Add a doctor capacity + facilityManage.clickFacilityAddDoctorTypeButton(); + facilityPage.selectAreaOfSpecialization("Pulmonology"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.saveAndExitDoctorForm(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Staff count added successfully", + ); + facilityManage.verifyTotalDoctorCapacity(doctorCapacity); + // edit a existing doctor + facilityManage.clickEditFacilityDoctorCapacity(); + facilityPage.fillDoctorCount(doctorModifiedCapacity); + facilityPage.clickdoctorcapacityaddmore(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Staff count updated successfully", + ); + facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity); + // delete a bed + facilityManage.clickDeleteFacilityDoctorCapacity(); + facilityManage.clickButtonWithText("Delete"); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Staff specialization type deleted successfully", + ); + }); - it("Modify bed capacity in Facility detail page", () => { - // add multiple new bed capacity - facilityManage.clickFacilityAddBedTypeButton(); - facilityPage.selectBedType("Isolation Bed"); - facilityPage.fillTotalCapacity(totalCapacity); - facilityPage.fillCurrentlyOccupied(currentOccupied); - facilityPage.saveAndExitBedCapacityForm(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Bed capacity added successfully", - ); - cy.closeNotification(); - 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", - ); - cy.closeNotification(); - facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); - facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); - // delete a bed - facilityManage.clickDeleteFacilityBedCapacity(); - facilityManage.clickButtonWithText("Delete"); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Bed type deleted successfully", - ); - }); + it("Modify bed capacity in Facility detail page", () => { + // add multiple new bed capacity + facilityManage.clickFacilityAddBedTypeButton(); + facilityPage.selectBedType("Isolation Bed"); + facilityPage.fillTotalCapacity(totalCapacity); + facilityPage.fillCurrentlyOccupied(currentOccupied); + facilityPage.saveAndExitBedCapacityForm(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Bed capacity added successfully", + ); + cy.closeNotification(); + 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", + ); + cy.closeNotification(); + facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); + facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); + // delete a bed + facilityManage.clickDeleteFacilityBedCapacity(); + facilityManage.clickButtonWithText("Delete"); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Bed type deleted successfully", + ); + }); - afterEach(() => { - cy.saveLocalStorage(); - }); + afterEach(() => { + cy.saveLocalStorage(); }); });