From 79acd4da8c939bc9247474601c886bed4e87eeb9 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:31:53 +0530 Subject: [PATCH] facility pagination and redirection --- .../e2e/facility_spec/facility_homepage.cy.ts | 35 +++++++++- cypress/e2e/facility_spec/locations.cy.ts | 69 +++++++++++-------- .../pageobject/Facility/FacilityCreation.ts | 4 ++ cypress/pageobject/Facility/FacilityHome.ts | 43 ++++++++++++ .../pageobject/Facility/FacilityLocation.ts | 6 +- cypress/pageobject/Users/ManageUserPage.ts | 1 + src/Components/Facility/FacilityCard.tsx | 2 + 7 files changed, 128 insertions(+), 32 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_homepage.cy.ts b/cypress/e2e/facility_spec/facility_homepage.cy.ts index 3d916b4ba47..7269c3a2581 100644 --- a/cypress/e2e/facility_spec/facility_homepage.cy.ts +++ b/cypress/e2e/facility_spec/facility_homepage.cy.ts @@ -5,6 +5,7 @@ import FacilityHome from "../../pageobject/Facility/FacilityHome"; import ManageUserPage from "../../pageobject/Users/ManageUserPage"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { UserPage } from "../../pageobject/Users/UserSearch"; +import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; describe("Facility Homepage Function", () => { const loginPage = new LoginPage(); @@ -12,6 +13,7 @@ describe("Facility Homepage Function", () => { const facilityPage = new FacilityPage(); const manageUserPage = new ManageUserPage(); const userPage = new UserPage(); + const assetPagination = new AssetPagination(); const facilitiesAlias = "downloadFacilitiesCSV"; const capacitiesAlias = "downloadCapacitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; @@ -19,6 +21,7 @@ describe("Facility Homepage Function", () => { const facilityname = "Dummy Facility 1"; const statename = "Kerala"; const district = "Ernakulam"; + const localbody = "Aikaranad"; const facilitytype = "Private Hospital"; before(() => { @@ -31,24 +34,52 @@ describe("Facility Homepage Function", () => { cy.awaitUrl("/facility"); }); + it("Verify the Facility card button redirection", () => { + // view cns button + facilityHome.clickViewCnsButton(); + facilityHome.verifyCnsUrl(); + facilityHome.navigateBack(); + // view notify button + facilityHome.clickFacilityNotifyButton(); + facilityHome.verifyAndCloseNotifyModal(); + // view facility button + facilityHome.clickViewFacilityDetails(); + facilityPage.getFacilityName().should("be.visible"); + facilityHome.verifyFacilityDetailsUrl(); + facilityHome.navigateBack(); + // view patient button + manageUserPage.clickFacilityPatients(); + facilityHome.verifyPatientListVisibility(); + facilityHome.verifyPatientListUrl(); + facilityHome.navigateBack(); + // occupancy badge + facilityHome.verifyOccupancyBadgeVisibility(); + }); + it("Verify the functionality of advance filter", () => { userPage.clickAdvancedFilters(); facilityPage.selectState(statename); facilityPage.selectDistrict(district); - // facilityPage.selectLocalBody("Anthikad Grama"); current dummy data have issue in local body + facilityPage.selectLocalBody(localbody); facilityPage.clickUpdateFacilityType(facilitytype); userPage.applyFilter(); facilityPage.verifyStateBadgeContent(statename); facilityPage.verifyDistrictBadgeContent(district); + facilityPage.verifyLocalBodyBadgeContent(localbody); facilityPage.verifyFacilityTypeBadgeContent(facilitytype); manageUserPage.assertFacilityInCard(facilityname); userPage.clearFilters(); userPage.verifyDataTestIdNotVisible("State"); userPage.verifyDataTestIdNotVisible("District"); userPage.verifyDataTestIdNotVisible("Facility type"); + userPage.verifyDataTestIdNotVisible("Local Body"); }); - it("Search a facility in homepage", () => { + it("Search a facility in homepage and pagination", () => { + // pagination of the facility page + assetPagination.navigateToNextPage(); + assetPagination.navigateToPreviousPage(); + // search for a facility manageUserPage.typeFacilitySearch(facilityname); facilityPage.verifyFacilityBadgeContent(facilityname); manageUserPage.assertFacilityInCard(facilityname); diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index 26364048ca2..b9d26ee3100 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -3,6 +3,7 @@ import { AssetPage } from "../../pageobject/Asset/AssetCreation"; import { UserCreationPage } from "../../pageobject/Users/UserCreation"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import FacilityLocation from "../../pageobject/Facility/FacilityLocation"; +import FacilityHome from "../../pageobject/Facility/FacilityHome"; // import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; describe("Location Management Section", () => { @@ -10,6 +11,7 @@ describe("Location Management Section", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const facilityLocation = new FacilityLocation(); + const facilityHome = new FacilityHome(); // const assetPagination = new AssetPagination(); const EXPECTED_LOCATION_ERROR_MESSAGES = [ "Name is required", @@ -27,7 +29,7 @@ describe("Location Management Section", () => { const locationModifiedDescription = "Test Modified Description"; const locationModifiedType = "ICU"; const locationModifiedMiddleware = "dev-middleware.coronasafe.live"; - const bedName = "Test Bed"; + const bedName = "Test-Bed"; const bedDescrption = "test description"; const bedType = "ICU"; const bedStatus = "Vacant"; @@ -56,6 +58,42 @@ describe("Location Management Section", () => { cy.get("[id=location-management]").click(); }); + it("Add a Bed to facility location along with duplication and deleting a bed", () => { + // mandatory field verification in bed creation + facilityLocation.clickManageBedButton(); + facilityLocation.clickAddBedButton(); + assetPage.clickassetupdatebutton(); + userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); + // create a new single bed and verify + facilityLocation.enterBedName(bedName); + facilityLocation.enterBedDescription(bedDescrption); + facilityLocation.selectBedType(bedType); + assetPage.clickassetupdatebutton(); + // Verify the bed creation + facilityLocation.verifyBedNameBadge(bedName); + facilityLocation.verifyBedBadge(bedType); + facilityLocation.verifyBedBadge(bedStatus); + // Try to create duplication bed and verify the error + facilityLocation.clickAddBedButton(); + facilityLocation.enterBedName(bedName); + facilityLocation.selectBedType(bedType); + assetPage.clickassetupdatebutton(); + facilityLocation.verifyNotification( + "Name - Bed with same name already exists in location" + ); + facilityHome.verifyAndCloseNotifyModal(); + // edit the created bed + facilityLocation.clickEditBedButton(); + facilityLocation.enterBedName(bedModifiedName); + facilityLocation.enterBedDescription(bedModifiedDescrption); + facilityLocation.selectBedType(bedModifiedType); + assetPage.clickassetupdatebutton(); + // verify the modification + facilityLocation.verifyBedNameBadge(bedModifiedName); + facilityLocation.verifyBedBadge(bedModifiedType); + facilityLocation.verifyBedBadge(bedStatus); + }); + it("Adds Location to a facility and modify it", () => { // add a new location form mandatory error facilityLocation.clickAddNewLocationButton(); @@ -86,7 +124,7 @@ describe("Location Management Section", () => { facilityLocation.verifyLocationMiddleware(locationModifiedMiddleware); }); - it("Add Multiple Bed to a facility location and delete a bed", () => { + it("Multiple Bed to a facility location and delete a bed", () => { // create multiple bed and verify facilityLocation.clickManageBedButton(); facilityLocation.clickAddBedButton(); @@ -120,33 +158,6 @@ describe("Location Management Section", () => { // assetPagination.navigateToPreviousPage(); // }); need to be unblocked upon issue #6906 is solved - it("Add Single Bed to a facility location and modify it", () => { - // mandatory field verification in bed creation - facilityLocation.clickManageBedButton(); - facilityLocation.clickAddBedButton(); - assetPage.clickassetupdatebutton(); - userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); - // create a new single bed and verify - facilityLocation.enterBedName(bedName); - facilityLocation.enterBedDescription(bedDescrption); - facilityLocation.selectBedType(bedType); - assetPage.clickassetupdatebutton(); - // Verify the bed creation - facilityLocation.verifyBedNameBadge(bedName); - facilityLocation.verifyBedBadge(bedType); - facilityLocation.verifyBedBadge(bedStatus); - // edit the created bed - facilityLocation.clickEditBedButton(); - facilityLocation.enterBedName(bedModifiedName); - facilityLocation.enterBedDescription(bedModifiedDescrption); - facilityLocation.selectBedType(bedModifiedType); - assetPage.clickassetupdatebutton(); - // verify the modification - facilityLocation.verifyBedNameBadge(bedModifiedName); - facilityLocation.verifyBedBadge(bedModifiedType); - facilityLocation.verifyBedBadge(bedStatus); - }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 608dd9c357b..e3639388620 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -337,6 +337,10 @@ class FacilityPage { cy.get("[data-testid='District']").should("contain", expectedText); } + verifyLocalBodyBadgeContent(expectedText: string) { + cy.get("[data-testid='Local Body']").should("contain", expectedText); + } + verifyFacilityTypeBadgeContent(expectedText: string) { cy.get("[data-testid='Facility type']").should("contain", expectedText); } diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index 04dfe94d002..03f2be9b19b 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -23,6 +23,49 @@ class FacilityHome { cy.intercept("GET", `**/api/v1/facility/?csv${queryParam}`).as(alias); } + clickViewCnsButton() { + cy.get("#view-cns-button").first().click(); + } + + verifyCnsUrl() { + cy.url().should("include", "/cns"); + } + + clickFacilityNotifyButton() { + cy.get("#facility-notify").first().click(); + } + + verifyFacilityDetailsUrl() { + cy.url().should("match", /\/facility\/[\w-]+/); + } + + verifyPatientListVisibility() { + cy.get("#patient-name-list").scrollIntoView(); + cy.get("#patient-name-list").should("be.visible"); + } + + verifyPatientListUrl() { + cy.url().should("match", /\/patients\?facility=.+/); + } + + verifyOccupancyBadgeVisibility() { + cy.get("#occupany-badge").should("be.visible"); + } + + verifyAndCloseNotifyModal() { + cy.get("#cancel").should("be.visible"); + cy.get("#cancel").click(); + } + + navigateBack() { + cy.go(-1); + } + + clickViewFacilityDetails() { + cy.get("#facility-details").should("be.visible"); + cy.get("#facility-details").first().click(); + } + verifyDownload(alias: string) { cy.wait(`@${alias}`).its("response.statusCode").should("eq", 200); } diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index d3eebdaf4ff..8924119510f 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -32,6 +32,10 @@ class FacilityLocation { cy.get("#location-type").contains(type); } + verifyNotification(message: string) { + cy.get(".pnotify-container").should("contain", message).and("be.visible"); + } + verifyLocationDescription(description: string) { cy.get("#view-location-description").contains(description); } @@ -49,7 +53,7 @@ class FacilityLocation { } enterBedName(name: string) { - cy.get("#bed-name").clear().click().type(name); + cy.get("#bed-name").click().clear().click().type(name); } enterBedDescription(description: string) { diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index d3f7e17e7d5..2d1ebbc14f0 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -103,6 +103,7 @@ export class ManageUserPage { } clickFacilityPatients() { + cy.get("#facility-patients").should("be.visible"); cy.get("#facility-patients").click(); } diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index c34fed49a6e..1424a657de4 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -98,6 +98,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => { {facility.name} {
0.85 ? "button-danger-border bg-red-500"