Skip to content

Commit

Permalink
New Cypress Test | Facility Triage Functionality | Facility Tab (ohcn…
Browse files Browse the repository at this point in the history
…etwork#6795)

* facility update

* minor fix

* Facility Triage Test
  • Loading branch information
nihal467 authored Dec 5, 2023
1 parent 9504655 commit b4edef2
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
47 changes: 47 additions & 0 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ describe("Facility Creation", () => {
const doctorCapacity = "5";
const totalDoctor = "10";
const facilityName = "cypress facility";
const facilityName2 = "Dummy Facility 1";
const facilityAddress = "cypress address";
const facilityUpdateAddress = "cypress updated address";
const facilityNumber = "9898469865";
const triageDate = "02122023";
const initialTriageValue = "60";
const modifiedTriageValue = "50";
const facilityErrorMessage = [
"Required",
"Invalid Pincode",
Expand All @@ -50,6 +54,7 @@ describe("Facility Creation", () => {
"Field is required",
];
const doctorErrorMessage = ["Field is required", "Field is required"];
const triageErrorMessage = ["Field is required"];

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -62,6 +67,48 @@ describe("Facility Creation", () => {
cy.awaitUrl("/facility");
});

it("Verify Facility Triage Function", () => {
// mandatory field error throw
manageUserPage.typeFacilitySearch(facilityName2);
facilityPage.verifyFacilityBadgeContent(facilityName2);
manageUserPage.assertFacilityInCard(facilityName2);
facilityHome.verifyURLContains(facilityName2);
facilityPage.visitAlreadyCreatedFacility();
facilityPage.scrollToFacilityTriage();
facilityPage.clickAddFacilityTriage();
manageUserPage.clickSubmit();
userCreationPage.verifyErrorMessages(triageErrorMessage);
// create a entry and verify reflection
facilityPage.fillEntryDate(triageDate);
facilityPage.fillTriageEntryFields(
initialTriageValue,
initialTriageValue,
initialTriageValue,
initialTriageValue,
initialTriageValue
);
manageUserPage.clickSubmit();
// edit the entry and verify reflection
facilityPage.scrollToFacilityTriage();
facilityPage.verifyTriageTableContains(initialTriageValue);
facilityPage.clickEditButton();
facilityPage.fillTriageEntryFields(
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue
);
manageUserPage.clickSubmit();
facilityPage.scrollToFacilityTriage();
facilityPage.verifyTriageTableContains(modifiedTriageValue);
// validate error of filling data on same date already data exist and verify reflection
facilityPage.scrollToFacilityTriage();
facilityPage.clickAddFacilityTriage();
facilityPage.fillEntryDate(triageDate);
facilityPage.clickButtonsMultipleTimes("button#submit");
});

it("Create a new facility with multiple bed and doctor capacity", () => {
// create facility with multiple capacity and verify form error message for facility form
facilityPage.visitCreateFacilityPage();
Expand Down
47 changes: 47 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,53 @@ class FacilityPage {
cy.get("#delete-facility").contains("Delete Facility").click();
}

scrollToFacilityTriage() {
cy.get("#add-facility-triage").scrollIntoView();
}

fillTriageEntryFields(
visited,
homeQuarantine,
isolation,
referred,
confirmedPositive
) {
cy.get("#num_patients_visited").clear().click().type(visited);
cy.get("#num_patients_home_quarantine")
.clear()
.click()
.type(homeQuarantine);
cy.get("#num_patients_isolation").clear().click().type(isolation);
cy.get("#num_patient_referred").clear().click().type(referred);
cy.get("#num_patient_confirmed_positive")
.clear()
.click()
.type(confirmedPositive);
}

fillEntryDate(date) {
cy.get("#entry_date").click();
cy.get("#date-input").click().type(date);
}

clickEditButton() {
cy.get("#edit-button").click();
}

clickButtonsMultipleTimes(selector) {
cy.get(selector).each(($button) => {
cy.wrap($button).click();
});
}

verifyTriageTableContains(value) {
cy.get("#triage-table").contains(value);
}

clickAddFacilityTriage() {
cy.get("#add-facility-triage").click();
}

clickfacilityfeatureoption() {
cy.get("#features").click();
}
Expand Down
7 changes: 6 additions & 1 deletion src/Components/Facility/FacilityHomeTriage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const FacilityHomeTriage = (props: any) => {
);
temp.push(
<ButtonV2
id="edit-button"
variant="secondary"
ghost
border
Expand All @@ -52,6 +53,7 @@ export const FacilityHomeTriage = (props: any) => {
<div className="justify-between md:flex md:pb-2">
<div className="mb-2 text-xl font-bold">Corona Triage</div>
<ButtonV2
id="add-facility-triage"
className="w-full md:w-auto"
onClick={() => navigate(`/facility/${props.facilityId}/triage`)}
authorizeFor={props.NonReadOnlyUsers}
Expand All @@ -60,7 +62,10 @@ export const FacilityHomeTriage = (props: any) => {
Add Triage
</ButtonV2>
</div>
<div className="mt-4 overflow-x-auto overflow-y-hidden">
<div
className="mt-4 overflow-x-auto overflow-y-hidden"
id="triage-table"
>
<Table
rows={stats}
headings={[
Expand Down

0 comments on commit b4edef2

Please sign in to comment.