diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index d2893166745..4a07a665896 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -65,7 +65,6 @@ describe("Facility Creation with multiple user roles", () => { beforeEach(() => { cy.viewport(1280, 720); cy.restoreLocalStorage(); - cy.awaitUrl("/facility"); }); it("Create a new facility with all fields | Edit Existing Data | Verify its reflection", () => { diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 2ea72acc5eb..969023c6dc0 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -21,7 +21,7 @@ export interface FacilityData { class FacilityPage { visitCreateFacilityPage() { cy.intercept("GET", "**/facility/create").as("getCreateFacilities"); - cy.visit("/facility/create"); + cy.awaitUrl("/facility/create"); cy.wait("@getCreateFacilities") .its("response.statusCode") .should("eq", 200); @@ -44,8 +44,7 @@ class FacilityPage { } selectWard(ward: string) { - cy.get("div#ward button").click(); - cy.get("[role='option']").contains(ward).click(); + advanceFilters.selectWard(ward); } typeFacilityAddress(address: string, clearBeforeTyping: boolean = false) { @@ -275,39 +274,12 @@ class FacilityPage { .should("eq", 201); } - getStateElement() { - return cy.get("#state"); - } - - getDistrictElement() { - return cy.get("#district"); - } - selectStateOnPincode(stateName: string) { - this.getStateElement() - .scrollIntoView() - .wait(2000) - .should("be.visible") - .then(($element) => { - const text = $element.text(); - if (!text.includes(stateName)) { - this.getStateElement().click(); - cy.get("li[role=option]").contains(stateName).click(); - } - }); + advanceFilters.selectState(stateName); } selectDistrictOnPincode(districtName: string) { - this.getDistrictElement().as("district").scrollIntoView().wait(2000); - cy.get("@district") - .should("be.visible") - .then(($element) => { - const text = $element.text(); - if (!text.includes(districtName)) { - this.getDistrictElement().click(); - cy.get("li[role=option]").contains(districtName).click(); - } - }); + advanceFilters.selectDistrict(districtName); } verifyPpeQuantity(text: string) { diff --git a/cypress/pageobject/utils/advanceFilterHelpers.ts b/cypress/pageobject/utils/advanceFilterHelpers.ts index 22925fc2c23..613f4af2f23 100644 --- a/cypress/pageobject/utils/advanceFilterHelpers.ts +++ b/cypress/pageobject/utils/advanceFilterHelpers.ts @@ -4,17 +4,25 @@ export const advanceFilters = { }, selectState(state: string) { + cy.wait(200); cy.clickAndSelectOption("#state", state); }, selectDistrict(district: string) { + cy.wait(200); cy.clickAndSelectOption("#district", district); }, selectLocalBody(localBody: string) { + cy.wait(200); cy.clickAndSelectOption("#local_body", localBody); }, + selectWard(ward: string) { + cy.wait(200); + cy.clickAndSelectOption("#ward", ward); + }, + applySelectedFilter() { cy.verifyAndClickElement("#apply-filter", "Apply"); },