-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into facility_delete
- Loading branch information
Showing
24 changed files
with
859 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// FacilityCreation | ||
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.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, ""); | ||
facilityHome.clickExportButton(); | ||
facilityHome.clickMenuItem("Facilities"); | ||
facilityHome.verifyDownload(facilitiesAlias); | ||
facilityHome.clickSearchButton(); // to avoid flaky test, as sometimes, the test is unable to focus on the object | ||
// Download the Capacities CSV | ||
facilityHome.csvDownloadIntercept(capacitiesAlias, "&capacity"); | ||
facilityHome.clickExportButton(); | ||
facilityHome.clickMenuItem("Capacities"); | ||
facilityHome.verifyDownload(capacitiesAlias); | ||
facilityHome.clickSearchButton(); | ||
// Download the Doctors CSV | ||
facilityHome.csvDownloadIntercept(doctorsAlias, "&doctors"); | ||
facilityHome.clickExportButton(); | ||
facilityHome.clickMenuItem("Doctors"); | ||
facilityHome.verifyDownload(doctorsAlias); | ||
facilityHome.clickSearchButton(); | ||
// Download the Triages CSV | ||
facilityHome.csvDownloadIntercept(triagesAlias, "&triage"); | ||
facilityHome.clickExportButton(); | ||
facilityHome.clickMenuItem("Triages"); | ||
facilityHome.verifyDownload(triagesAlias); | ||
facilityHome.clickSearchButton(); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.saveLocalStorage(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// cypress/support/pageObjects/FacilityHome.ts | ||
|
||
class FacilityHome { | ||
// Selectors | ||
exportButton = "#export-button"; | ||
searchButton = "#search"; | ||
menuItem = "[role='menuitem']"; | ||
|
||
// Operations | ||
clickExportButton() { | ||
cy.get(this.exportButton).click(); | ||
} | ||
|
||
clickSearchButton() { | ||
cy.get(this.searchButton).click(); | ||
} | ||
|
||
clickMenuItem(itemName: string) { | ||
cy.get(this.menuItem).contains(itemName).click(); | ||
} | ||
|
||
csvDownloadIntercept(alias: string, queryParam: string) { | ||
cy.intercept("GET", `**/api/v1/facility/?csv${queryParam}`).as(alias); | ||
} | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.