Skip to content

Commit

Permalink
debug the facility creation
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Dec 18, 2024
1 parent c4ace63 commit 266e1c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
1 change: 0 additions & 1 deletion cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
36 changes: 4 additions & 32 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions cypress/pageobject/utils/advanceFilterHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
},
Expand Down

0 comments on commit 266e1c5

Please sign in to comment.