diff --git a/cypress/e2e/assets_spec/AssetHomepage.cy.ts b/cypress/e2e/assets_spec/AssetHomepage.cy.ts index 906cd9b2edc..67ad50e832f 100644 --- a/cypress/e2e/assets_spec/AssetHomepage.cy.ts +++ b/cypress/e2e/assets_spec/AssetHomepage.cy.ts @@ -1,3 +1,4 @@ +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; import { v4 as uuidv4 } from "uuid"; import { AssetPage } from "../../pageobject/Asset/AssetCreation"; @@ -65,13 +66,13 @@ describe("Asset Tab", () => { "ONVIF Camera", "Camera Loc", ); - assetFilters.clickadvancefilter(); + advanceFilters.clickAdvancedFiltersButton(); assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters assetFilters.assertFacilityText("Dummy Facility 40"); assetFilters.assertAssetClassText("ONVIF"); assetFilters.assertStatusText("ACTIVE"); assetFilters.assertLocationText("Camera Loc"); - assetFilters.clickadvancefilter(); + advanceFilters.clickAdvancedFiltersButton(); assetFilters.clearFilters(); }); diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index fff1311fdd6..5e644238999 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -57,6 +57,7 @@ describe("Facility Creation", () => { "This field is required", ]; const triageErrorMessage = ["This field is required"]; + const facilityType = "Primary Health Centres"; before(() => { loginPage.loginAsDistrictAdmin(); @@ -117,7 +118,7 @@ describe("Facility Creation", () => { facilityPage.submitForm(); userCreationPage.verifyErrorMessages(facilityErrorMessage); facilityPage.fillFacilityName(facilityName); - facilityPage.clickUpdateFacilityType("Primary Health Centres"); + facilityPage.selectFacilityType(facilityType); facilityPage.clickfacilityfeatureoption(); facilityFeature.forEach((featureText) => { cy.get("[role='option']").contains(featureText).click(); @@ -206,7 +207,7 @@ describe("Facility Creation", () => { it("Create a new facility with single bed and doctor capacity", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); - facilityPage.clickUpdateFacilityType("Primary Health Centres"); + facilityPage.selectFacilityType(facilityType); facilityPage.fillPincode("682001"); facilityPage.selectStateOnPincode("Kerala"); facilityPage.selectDistrictOnPincode("Ernakulam"); @@ -246,7 +247,7 @@ describe("Facility Creation", () => { it("Create a new facility with no bed and doctor capacity", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); - facilityPage.clickUpdateFacilityType("Primary Health Centres"); + facilityPage.selectFacilityType(facilityType); facilityPage.fillPincode("682001"); facilityPage.selectStateOnPincode("Kerala"); facilityPage.selectDistrictOnPincode("Ernakulam"); @@ -285,7 +286,7 @@ describe("Facility Creation", () => { facilityPage.visitUpdateFacilityPage(facilityUrl1); facilityPage.clickManageFacilityDropdown(); facilityPage.clickUpdateFacilityOption(); - facilityPage.clickUpdateFacilityType("Primary Health Centres"); + facilityPage.selectFacilityType(facilityType); facilityPage.fillAddress(facilityUpdateAddress); facilityPage.fillOxygenCapacity(oxygenCapacity); facilityPage.fillExpectedOxygenRequirement(oxygenExpected); diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 7db3b308a53..08ea39ee2c9 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -6,6 +6,7 @@ import FacilityNotify from "../../pageobject/Facility/FacilityNotify"; import LoginPage from "../../pageobject/Login/LoginPage"; import ManageUserPage from "../../pageobject/Users/ManageUserPage"; import { UserPage } from "../../pageobject/Users/UserSearch"; +import { advanceFilters } from "../../pageobject/utils/advanceFilterHelpers"; describe("Facility Homepage Function", () => { const loginPage = new LoginPage(); @@ -61,18 +62,19 @@ describe("Facility Homepage Function", () => { }); it("Verify the functionality of advance filter", () => { - userPage.clickAdvancedFilters(); - facilityPage.selectState(stateName); - facilityPage.selectDistrict(district); - facilityPage.selectLocalBody(localBody); - facilityPage.clickUpdateFacilityType(facilityType); - userPage.applyFilter(); + advanceFilters.clickAdvancedFiltersButton(); + advanceFilters.selectState(stateName); + advanceFilters.selectDistrict(district); + advanceFilters.selectLocalBody(localBody); + advanceFilters.selectFacilityType(facilityType); + advanceFilters.applySelectedFilter(); facilityPage.verifyStateBadgeContent(stateName); facilityPage.verifyDistrictBadgeContent(district); facilityPage.verifyLocalBodyBadgeContent(localBody); facilityPage.verifyFacilityTypeBadgeContent(facilityType); manageUserPage.assertFacilityInCard(facilityName); - userPage.clearFilters(); + advanceFilters.clickAdvancedFiltersButton(); + advanceFilters.clickClearAdvanceFilters(); userPage.verifyDataTestIdNotVisible("State"); userPage.verifyDataTestIdNotVisible("District"); userPage.verifyDataTestIdNotVisible("Facility type"); @@ -116,11 +118,11 @@ describe("Facility Homepage Function", () => { }); it("Verify Facility Detail page redirection to CNS and Live Minitoring ", () => { - userPage.clickAdvancedFilters(); - facilityPage.selectState(stateName); - facilityPage.selectDistrict(district); - facilityPage.selectLocalBody(localBody); - userPage.applyFilter(); + advanceFilters.clickAdvancedFiltersButton(); + advanceFilters.selectState(stateName); + advanceFilters.selectDistrict(district); + advanceFilters.selectLocalBody(localBody); + advanceFilters.applySelectedFilter(); // go to cns page in the facility details page manageUserPage.typeFacilitySearch(facilityName); facilityPage.verifyFacilityBadgeContent(facilityName); diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index d2dbb2a3619..e4e0f927952 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -1,3 +1,5 @@ +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; + import LoginPage from "../../pageobject/Login/LoginPage"; import PatientHome from "../../pageobject/Patient/PatientHome"; @@ -35,7 +37,7 @@ describe("Patient Homepage present functionalities", () => { }); it("Date based advance filters applied in the patient tab", () => { - patientHome.clickPatientAdvanceFilters(); + advanceFilters.clickAdvancedFiltersButton(); patientHome.typePatientCreatedBeforeDate(patientFromDate); patientHome.typePatientCreatedAfterDate(patientToDate); patientHome.typePatientModifiedBeforeDate(patientFromDate); @@ -55,7 +57,7 @@ describe("Patient Homepage present functionalities", () => { }); it("Facility Geography based advance filters applied in the patient tab", () => { - patientHome.clickPatientAdvanceFilters(); + advanceFilters.clickAdvancedFiltersButton(); patientHome.typeFacilityName(facilityName); patientHome.selectFacilityType(facilityType); patientHome.typeFacilityLsgBody(facilityLsgBody); @@ -73,7 +75,7 @@ describe("Patient Homepage present functionalities", () => { it("Patient diagnosis based advance filters applied in the patient tab", () => { // Patient Filtering based on icd-11 data - patientHome.clickPatientAdvanceFilters(); + advanceFilters.clickAdvancedFiltersButton(); patientHome.selectAnyIcdDiagnosis(patientIcdDiagnosis, patientIcdDiagnosis); patientHome.selectConfirmedIcdDiagnosis( patientIcdDiagnosis, @@ -103,7 +105,7 @@ describe("Patient Homepage present functionalities", () => { cy.clearAllFilters(); patientHome.verifyTotalPatientCount("1"); // Apply Any and confirmed diagonsis to verify patient count 17 - patientHome.clickPatientAdvanceFilters(); + advanceFilters.clickAdvancedFiltersButton(); patientHome.selectAnyIcdDiagnosis(patientIcdDiagnosis, patientIcdDiagnosis); patientHome.selectConfirmedIcdDiagnosis( patientIcdDiagnosis, @@ -115,7 +117,7 @@ describe("Patient Homepage present functionalities", () => { it("Patient Details based advance filters applied in the patient tab", () => { // Patient Filtering based on patient details - patientHome.clickPatientAdvanceFilters(); + advanceFilters.clickAdvancedFiltersButton(); patientHome.selectPatientGenderfilter(patientGender); patientHome.selectPatientCategoryfilter(patientCategory); patientHome.typePatientMinimumAgeFilter(patientMinimumAge); diff --git a/cypress/e2e/shifting_spec/ShiftingAdvanceFilters.cy.ts b/cypress/e2e/shifting_spec/ShiftingAdvanceFilters.cy.ts index bb536a1865c..01c1cbebd3a 100644 --- a/cypress/e2e/shifting_spec/ShiftingAdvanceFilters.cy.ts +++ b/cypress/e2e/shifting_spec/ShiftingAdvanceFilters.cy.ts @@ -1,3 +1,5 @@ +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; + import ShiftingPage from "../../pageobject/Shift/ShiftFilters"; describe("Shifting section filter", () => { @@ -12,7 +14,7 @@ describe("Shifting section filter", () => { cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); cy.awaitUrl("/shifting"); - shiftingPage.advancedFilterButton().click(); + advanceFilters.clickAdvancedFiltersButton(); }); it("filter by facility", () => { diff --git a/cypress/e2e/users_spec/UsersHomepage.cy.ts b/cypress/e2e/users_spec/UsersHomepage.cy.ts index 0dd03c74304..d5825f58f20 100644 --- a/cypress/e2e/users_spec/UsersHomepage.cy.ts +++ b/cypress/e2e/users_spec/UsersHomepage.cy.ts @@ -1,3 +1,5 @@ +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; + import LoginPage from "../../pageobject/Login/LoginPage"; import { UserPage } from "../../pageobject/Users/UserSearch"; @@ -28,7 +30,7 @@ describe("User Homepage", () => { }); it("User advance filter functionality", () => { - userPage.clickAdvancedFilters(); + advanceFilters.clickAdvancedFiltersButton(); userPage.typeInFirstName(firstName); userPage.typeInLastName(lastName); userPage.selectRole(role); @@ -37,7 +39,7 @@ describe("User Homepage", () => { userPage.typeInPhoneNumber(phoneNumber); userPage.typeInAltPhoneNumber(altPhoneNumber); userPage.selectHomeFacility(homeFacility); - userPage.applyFilter(); + advanceFilters.applySelectedFilter(); userPage.checkUsernameText(nurseUserName); // Verify the badges related to the data userPage.verifyDataTestIdText("First Name", `First Name: ${firstName}`); @@ -55,7 +57,8 @@ describe("User Homepage", () => { "Home Facility", `Home Facility: ${homeFacility}`, ); - userPage.clearFilters(); + advanceFilters.clickAdvancedFiltersButton(); + advanceFilters.clickClearAdvanceFilters(); userPage.verifyDataTestIdNotVisible("First Name"); userPage.verifyDataTestIdNotVisible("Last Name"); userPage.verifyDataTestIdNotVisible("Phone Number"); diff --git a/cypress/e2e/users_spec/UsersManage.cy.ts b/cypress/e2e/users_spec/UsersManage.cy.ts index 8899d951175..f3a04ca4410 100644 --- a/cypress/e2e/users_spec/UsersManage.cy.ts +++ b/cypress/e2e/users_spec/UsersManage.cy.ts @@ -1,3 +1,5 @@ +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; + import LoginPage from "../../pageobject/Login/LoginPage"; import ManageUserPage from "../../pageobject/Users/ManageUserPage"; import { UserCreationPage } from "../../pageobject/Users/UserCreation"; @@ -55,10 +57,10 @@ describe("Manage User", () => { it("linking skills for a doctor users and verify its reflection in doctor connect", () => { // select a doctor user and link and unlink same skill twice and verify the badge is only shown once in doctor connect - userPage.clickAdvancedFilters(); + advanceFilters.clickAdvancedFiltersButton(); userPage.typeInFirstName(firstNameUserSkill); userPage.typeInLastName(lastNameUserSkill); - userPage.applyFilter(); + advanceFilters.applySelectedFilter(); userPage.checkUsernameText(usernameToLinkSkill); manageUserPage.clicklinkedskillbutton(); manageUserPage.selectSkillFromDropdown(linkedskill); diff --git a/cypress/pageobject/Asset/AssetFilters.ts b/cypress/pageobject/Asset/AssetFilters.ts index 5a942b22f47..7e7b5013d5d 100644 --- a/cypress/pageobject/Asset/AssetFilters.ts +++ b/cypress/pageobject/Asset/AssetFilters.ts @@ -49,9 +49,6 @@ export class AssetFilters { expect(allEmpty).to.be.true; }); } - clickadvancefilter() { - cy.get("#advanced-filter").click(); - } clickslideoverbackbutton() { cy.get("#close-slide-over").click(); } diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index a48ffe0856b..6ce0cc6270e 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -1,4 +1,4 @@ -// FacilityPage.ts +import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; class FacilityPage { visitCreateFacilityPage() { @@ -14,6 +14,14 @@ class FacilityPage { cy.get("#search").click().type(facilityName); } + selectFacilityType(facility: string) { + advanceFilters.selectFacilityType(facility); + } + + selectLocalBody(localBody: string) { + advanceFilters.selectLocalBody(localBody); + } + visitUpdateFacilityPage(url: string) { cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); cy.visit(url); @@ -21,14 +29,6 @@ class FacilityPage { cy.get("#manage-facility-dropdown button").should("be.visible"); } - clickUpdateFacilityType(facilityType: string) { - cy.get("#facility_type") - .click() - .then(() => { - cy.get("[role='option']").contains(facilityType).click(); - }); - } - fillFacilityName(name: string) { cy.get("#name").click().clear().click().type(name); } @@ -37,21 +37,6 @@ class FacilityPage { cy.get("#pincode").click().type(pincode); } - selectState(state: string) { - cy.get("div#state button").click(); - cy.get("[role='option']").contains(state).click(); - } - - selectDistrict(district: string) { - cy.get("div#district button").click(); - cy.get("[role='option']").contains(district).click(); - } - - selectLocalBody(localBody: string) { - cy.get("div#local_body button").click(); - cy.get("[role='option']").contains(localBody).click(); - } - selectWard(ward: string) { cy.get("div#ward button").click(); cy.get("[role='option']").contains(ward).click(); diff --git a/cypress/pageobject/Patient/PatientHome.ts b/cypress/pageobject/Patient/PatientHome.ts index a69a96c3f77..bc27977d561 100644 --- a/cypress/pageobject/Patient/PatientHome.ts +++ b/cypress/pageobject/Patient/PatientHome.ts @@ -60,10 +60,6 @@ class PatientHome { ); } - clickPatientAdvanceFilters() { - cy.get("#advanced-filter").click(); - } - selectPatientGenderfilter(gender: string) { cy.clickAndSelectOption("#gender-advancefilter", gender); } diff --git a/cypress/pageobject/Shift/ShiftFilters.ts b/cypress/pageobject/Shift/ShiftFilters.ts index fe20b97bd9f..d191436c0e9 100644 --- a/cypress/pageobject/Shift/ShiftFilters.ts +++ b/cypress/pageobject/Shift/ShiftFilters.ts @@ -1,8 +1,4 @@ class ShiftingPage { - advancedFilterButton() { - return cy.get("#advanced-filter"); - } - originFacilityInput() { return cy.get("input[name='origin_facility']"); } diff --git a/cypress/pageobject/Users/UserSearch.ts b/cypress/pageobject/Users/UserSearch.ts index 1292395fce3..85575398d0d 100644 --- a/cypress/pageobject/Users/UserSearch.ts +++ b/cypress/pageobject/Users/UserSearch.ts @@ -35,10 +35,6 @@ export class UserPage { cy.get(this.removeIcon).click(); } - clickAdvancedFilters() { - cy.get("#advanced-filter").contains("Advanced Filters").click(); - } - typeInFirstName(firstName: string) { cy.get("#first_name").click().type(firstName); } @@ -72,19 +68,10 @@ export class UserPage { cy.typeAndSelectOption("input[name='home_facility']", facility); } - applyFilter() { - cy.get("#apply-filter").click(); - } - verifyDataTestIdText(testId: string, text: string) { cy.get(`[data-testid="${testId}"]`).contains(text).should("be.visible"); } - clearFilters() { - this.clickAdvancedFilters(); - cy.get("#clear-filter").contains("Clear").click(); - } - verifyDataTestIdNotVisible(testId: string) { cy.get(`[data-testid="${testId}"]`).should("not.be.visible"); } diff --git a/cypress/pageobject/utils/advanceFilterHelpers.ts b/cypress/pageobject/utils/advanceFilterHelpers.ts new file mode 100644 index 00000000000..a624311c197 --- /dev/null +++ b/cypress/pageobject/utils/advanceFilterHelpers.ts @@ -0,0 +1,29 @@ +export const advanceFilters = { + clickAdvancedFiltersButton() { + cy.verifyAndClickElement("#advanced-filter", "Advanced Filters"); + }, + + selectState(state: string) { + cy.clickAndSelectOption("#state", state); + }, + + selectDistrict(district: string) { + cy.clickAndSelectOption("#district", district); + }, + + selectLocalBody(localBody: string) { + cy.clickAndSelectOption("#local_body", localBody); + }, + + applySelectedFilter() { + cy.verifyAndClickElement("#apply-filter", "Apply"); + }, + + selectFacilityType(facilityType: string) { + cy.clickAndSelectOption("#facility_type", facilityType); + }, + + clickClearAdvanceFilters() { + cy.verifyAndClickElement("#clear-filter", "Clear"); + }, +};