Skip to content

Commit

Permalink
test for search facility (#6733)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Nov 27, 2023
1 parent 13fd680 commit 466d4ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cypress/e2e/facility_spec/facility_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";

describe("Facility Creation", () => {
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();
const facilityPage = new FacilityPage();
const manageUserPage = new ManageUserPage();
const facilitiesAlias = "downloadFacilitiesCSV";
const capacitiesAlias = "downloadCapacitiesCSV";
const doctorsAlias = "downloadDoctorsCSV";
const triagesAlias = "downloadTriagesCSV";
const facilityname = "Dummy Facility 1";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.viewport(1280, 720);
cy.restoreLocalStorage();
cy.awaitUrl("/facility");
});

it("Search a facility in homepage", () => {
manageUserPage.typeFacilitySearch(facilityname);
facilityPage.verifyFacilityBadgeContent(facilityname);
manageUserPage.assertFacilityInCard(facilityname);
facilityHome.verifyURLContains(facilityname);
});

it("Verify Facility Export Functionality", () => {
// Download the Facilities CSV
facilityHome.csvDownloadIntercept(facilitiesAlias, "");
Expand All @@ -48,6 +59,7 @@ describe("Facility Creation", () => {
facilityHome.verifyDownload(triagesAlias);
facilityHome.clickSearchButton();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
9 changes: 9 additions & 0 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class FacilityHome {
verifyDownload(alias: string) {
cy.wait(`@${alias}`).its("response.statusCode").should("eq", 200);
}

getURL() {
return cy.url();
}

verifyURLContains(searchText) {
const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+");
this.getURL().should("include", `search=${encodedText}`);
}
}

export default FacilityHome;

0 comments on commit 466d4ed

Please sign in to comment.