Skip to content

Commit

Permalink
patient date based test
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Oct 12, 2024
1 parent 5777eed commit c514fe1
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 2 deletions.
37 changes: 35 additions & 2 deletions cypress/e2e/patient_spec/PatientHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ describe("Patient Homepage present functionalities", () => {
const facilityType = "Private Hospital";
const facilityLsgBody = "Aikaranad Grama Panchayat, Ernakulam District";
const facilityDistrict = "Ernakulam";
const patientBeforeDate = "01122023";
const patientAfterDate = "07122023";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -30,17 +32,42 @@ describe("Patient Homepage present functionalities", () => {
cy.awaitUrl("/patients");
});

it("Date based advance filters applied in the patient tab", () => {
patientHome.clickPatientAdvanceFilters();
patientHome.typePatientCreatedBeforeDate(patientBeforeDate);
patientHome.typePatientCreatedAfterDate(patientAfterDate);
patientHome.typePatientModifiedBeforeDate(patientBeforeDate);
patientHome.typePatientModifiedAfterDate(patientAfterDate);
patientHome.typePatientAdmitedBeforeDate(patientBeforeDate);
patientHome.typePatientAdmitedAfterDate(patientAfterDate);
patientHome.clickPatientFilterApply();
patientHome.verifyTotalPatientCount("1");
// verify the badge and clear the count
patientHome.verifyPatientCreatedBeforeDate(patientBeforeDate);
patientHome.verifyPatientCreatedAfterDate(patientAfterDate);
patientHome.verifyPatientModifiedBeforeDate(patientBeforeDate);
patientHome.verifyPatientModifiedAfterDate(patientAfterDate);
patientHome.verifyPatientAdmittedBeforeDate(patientBeforeDate);
patientHome.verifyPatientAdmittedAfterDate(patientAfterDate);
cy.clearAllFilters();
patientHome.verifyTotalPatientCount("1");
});

it("Facility Geography based advance filters applied in the patient tab", () => {
patientHome.clickPatientAdvanceFilters();
patientHome.typeFacilityName(facilityName);
patientHome.selectFacilityType(facilityType);
patientHome.typeFacilityLsgBody(facilityLsgBody);
patientHome.typeFacilityDistrict(facilityDistrict);
patientHome.clickPatientFilterApply();
patientHome.verifyTotalPatientCount("17");
patientHome.verifyTotalPatientCount("1");
// Clear the badges and verify the patient count along with badges
patientHome.verifyFacilityNameBadgeContent(facilityName);
patientHome.verifyFacilityTypeBadgeContent(facilityType);
patientHome.verifyFacilityLsgBadgeContent(facilityLsgBody);
patientHome.verifyFacilityDistrictContent(facilityDistrict);
cy.clearAllFilters();
patientHome.verifyTotalPatientCount("18");
patientHome.verifyTotalPatientCount("1");
});

it("Patient diagnosis based advance filters applied in the patient tab", () => {
Expand All @@ -65,6 +92,12 @@ describe("Patient Homepage present functionalities", () => {
);
patientHome.clickPatientFilterApply();
patientHome.verifyTotalPatientCount("0");
// verify the badges presence in the platform
patientHome.verifyAnyDiagnosisBadgeContent(patientIcdDiagnosis);
patientHome.verifyConfirmedDiagnosisBadgeContent(patientIcdDiagnosis);
patientHome.verifyUnconfirmedDiagnosisBadgeContent(patientIcdDiagnosis);
patientHome.verifyProvisionalDiagnosisBadgeContent(patientIcdDiagnosis);
patientHome.verifyDifferentialDiagnosisBadgeContent(patientIcdDiagnosis);
// Clear the badges and verify the patient count along with badges
cy.clearAllFilters();
patientHome.verifyTotalPatientCount("1");
Expand Down
92 changes: 92 additions & 0 deletions cypress/pageobject/Patient/PatientHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ class PatientHome {
});
}

typePatientCreatedBeforeDate(startDate: string) {
cy.clickAndTypeDate("input[name='created_date_start']", startDate);
}

typePatientCreatedAfterDate(endDate: string) {
cy.clickAndTypeDate("input[name='created_date_end']", endDate);
}

typePatientModifiedBeforeDate(startDate: string) {
cy.clickAndTypeDate("input[name='modified_date_start']", startDate);
}
Expand All @@ -42,6 +50,20 @@ class PatientHome {
cy.clickAndTypeDate("input[name='modified_date_end']", endDate);
}

typePatientAdmitedBeforeDate(startDate: string) {
cy.clickAndTypeDate(
"input[name='last_consultation_encounter_date_start']",
startDate,
);
}

typePatientAdmitedAfterDate(endDate: string) {
cy.clickAndTypeDate(
"input[name='last_consultation_encounter_date_end']",
endDate,
);
}

clickPatientAdvanceFilters() {
cy.get("#advanced-filter").click();
}
Expand Down Expand Up @@ -163,5 +185,75 @@ class PatientHome {
typeFacilityDistrict(district: string) {
cy.typeAndSelectOption("#facility-district", district);
}

verifyAnyDiagnosisBadgeContent(expectedText: string) {
cy.get("[data-testid='Diagnoses (of any verification status)']").should(
"contain",
expectedText,
);
}

verifyConfirmedDiagnosisBadgeContent(expectedText: string) {
cy.get("[data-testid='Confirmed Diagnoses']").should(
"contain",
expectedText,
);
}

verifyUnconfirmedDiagnosisBadgeContent(expectedText: string) {
cy.get("[data-testid='Unconfirmed Diagnoses']").should(
"contain",
expectedText,
);
}

verifyProvisionalDiagnosisBadgeContent(expectedText: string) {
cy.get("[data-testid='Provisional Diagnoses']").should(
"contain",
expectedText,
);
}

verifyDifferentialDiagnosisBadgeContent(expectedText: string) {
cy.get("[data-testid='Differential Diagnoses']").should(
"contain",
expectedText,
);
}

verifyFacilityNameBadgeContent(expectedText: string) {
cy.get("[data-testid='Facility']").should("contain", expectedText);
}

verifyFacilityTypeBadgeContent(expectedText: string) {
cy.get("[data-testid='Facility Type']").should("contain", expectedText);
}

verifyFacilityLsgBadgeContent(expectedText: string) {
cy.get("[data-testid='LSG Body']").should("contain", expectedText);
}

verifyFacilityDistrictContent(expectedText: string) {
cy.get("[data-testid='District']").should("contain", expectedText);
}

verifyPatientCreatedBeforeDate(expectedText: string) {
cy.get("[data-testid='Created before']").should("contain", expectedText);
}
verifyPatientCreatedAfterDate(expectedText: string) {
cy.get("[data-testid='Created after']").should("contain", expectedText);
}
verifyPatientModifiedBeforeDate(expectedText: string) {
cy.get("[data-testid='Modified before']").should("contain", expectedText);
}
verifyPatientModifiedAfterDate(expectedText: string) {
cy.get("[data-testid='Modified after']").should("contain", expectedText);
}
verifyPatientAdmittedAfterDate(expectedText: string) {
cy.get("[data-testid='Admitted after']").should("contain", expectedText);
}
verifyPatientAdmittedBeforeDate(expectedText: string) {
cy.get("[data-testid='Admitted before']").should("contain", expectedText);
}
}
export default PatientHome;

0 comments on commit c514fe1

Please sign in to comment.