-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// FacilityCreation | ||
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; | ||
import LoginPage from "../../pageobject/Login/LoginPage"; | ||
import FacilityHome from "../../pageobject/Facility/FacilityHome"; | ||
|
||
describe("Facility Creation", () => { | ||
const loginPage = new LoginPage(); | ||
const facilityHome = new FacilityHome(); | ||
const facilitiesAlias = "downloadFacilitiesCSV"; | ||
const capacitiesAlias = "downloadCapacitiesCSV"; | ||
const doctorsAlias = "downloadDoctorsCSV"; | ||
const triagesAlias = "downloadTriagesCSV"; | ||
|
||
before(() => { | ||
loginPage.loginAsDisctrictAdmin(); | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.viewport(1280, 720); | ||
cy.restoreLocalStorage(); | ||
cy.awaitUrl("/facility"); | ||
}); | ||
|
||
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,31 @@ | ||
// 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); | ||
} | ||
} | ||
|
||
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