Skip to content

Commit

Permalink
cypress tests for patient details page
Browse files Browse the repository at this point in the history
  • Loading branch information
MjStar24 committed Mar 31, 2024
1 parent 4cea768 commit f823862
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 0 deletions.
102 changes: 102 additions & 0 deletions cypress/e2e/patient_spec/patient_details.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import { PatientSampleRequest } from "../../pageobject/Patient/PatientSampleRequest";
import { AssignToVolunteer } from "../../pageobject/Patient/AssignToVolunteer";
import { ShiftPatient } from "../../pageobject/Patient/ShiftPatient";

describe("patient details", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientSampleRequest = new PatientSampleRequest();
const assignToVolunteer = new AssignToVolunteer();
const shiftPatient = new ShiftPatient();

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

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

const patientName = "Gigin";
const ICMRlabel = "ICMR";
const fastTrackRequired = true;
const fastTrackReason = "dummy reason";
const atypicalPresentation = true;
const atypicalDetails = "dummy details";
const doctorName = "dummy doctor";
const diagnosis = "dummy diagnosis";
const etiology = "dummy etiology";
const differentialDiagnosis = "dummy diagnosis";
const ari = true;
const sari = true;
const isUnusual = true;

it("Create Patient Sample Test Request", () => {
patientPage.visitPatient(patientName);
patientSampleRequest.visitPatientDetails();
patientSampleRequest.visitSampleRequest();
patientSampleRequest.selectSampleTestType();
patientSampleRequest.selectICMRCategory();
patientSampleRequest.typeICMRLabel(ICMRlabel);
patientSampleRequest.selectIsFastTrackRequired(fastTrackRequired);
patientSampleRequest.fastTrackReason(fastTrackRequired, fastTrackReason);
patientSampleRequest.selectIsATypicalPresentation(atypicalPresentation);
patientSampleRequest.atypicalDetails(atypicalPresentation, atypicalDetails);
patientSampleRequest.typeDoctorName(doctorName);
patientSampleRequest.typeDiagnosis(diagnosis);
patientSampleRequest.typeEtiologyIdentified(etiology);
patientSampleRequest.typeDifferentialDiagnosis(differentialDiagnosis);
patientSampleRequest.selectHasAri(ari);
patientSampleRequest.selectHasSari(sari);
patientSampleRequest.selectIsUnusual(isUnusual);
// patientSampleRequest.clickCancelButton();
patientSampleRequest.clickSubmitButton();
});

const contactPersonName = "Manas";
const phoneNumber = "9650244789";
const facilityName = "Govt";
const patientCategory = "Comfort";
const shiftReason = "dummy reason";
const driverName = "Mohit";
const ambulancePhoneNumber = "7845968745";
const ambulanceNumber = "201301";
const comment = "dummy comment";

it("Create Patient Shift Patient Request", () => {
patientPage.visitPatient(patientName);
patientSampleRequest.visitPatientDetails();
shiftPatient.visitShiftPatient();
shiftPatient.typeContactPersonName(contactPersonName);
shiftPatient.typePhoneNumber(phoneNumber);
shiftPatient.selectFacility(facilityName);
shiftPatient.selectPatientCategory(patientCategory);
shiftPatient.typeReasonForShift(shiftReason);
shiftPatient.typeNameOfDriver(driverName);
shiftPatient.typeAmbulancePhoneNumber(ambulancePhoneNumber);
shiftPatient.typeAmbulanceNumber(ambulanceNumber);
shiftPatient.typeOtherComments(comment);
shiftPatient.clickSubmitButton();
// shiftPatient.clickCancelButton();
});

const volunteerName = "Volunteer";

it("assign volunteer", () => {
patientPage.visitPatient(patientName);
patientSampleRequest.visitPatientDetails();
assignToVolunteer.visitAssignToVolunteer();
assignToVolunteer.selectVolunteer(volunteerName);
assignToVolunteer.clickCancelButton();
});

afterEach(() => {
cy.saveLocalStorage();
});
});
15 changes: 15 additions & 0 deletions cypress/pageobject/Patient/AssignToVolunteer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { cy } from "local-cypress";
export class AssignToVolunteer {
visitAssignToVolunteer() {
cy.get("#volunteer_assign").click({ force: true });
}
selectVolunteer(volunteer: string) {
cy.searchAndSelectOption("#assign_volunteer input", volunteer);
}
clickSubmitButton() {
cy.get("#submit").click();
}
clickCancelButton() {
cy.get("#cancel").click();
}
}
76 changes: 76 additions & 0 deletions cypress/pageobject/Patient/PatientSampleRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { cy } from "local-cypress";
export class PatientSampleRequest {
visitPatientDetails() {
cy.get("#patient-details").click();
}
visitSampleRequest() {
cy.get("#sample-request").click({ force: true });
}
selectSampleTestType() {
cy.get("#sample_type").click();
cy.get("#sample_type ul").first().click();
}
selectICMRCategory() {
cy.get("#icmr_category").click();
cy.get("#icmr_category ul").first().click();
}
typeICMRLabel(name: string) {
cy.get("input[name=icmr_label]").type(name);
}
selectIsFastTrackRequired(bool: boolean) {
if (bool) cy.get("input[name=isFastTrack]").click();
else return;
}
fastTrackReason(bool: boolean, reason: string) {
if (bool) cy.get("#fast_track").type(reason);
else return;
}
selectTestingFacility(facility: string) {
cy.searchAndSelectOption("input[name=testing_facility]", facility);
}
typeDoctorName(name: string) {
cy.get("#doctor_name").type(name);
}
selectIsATypicalPresentation(bool: boolean) {
if (bool) cy.get("input[name=is_atypical_presentation]").click();
else return;
}

atypicalDetails(bool: boolean, details: string) {
if (bool) cy.get("#atypical_presentation").type(details);
else return;
}
typeDiagnosis(diagnosis: string) {
cy.get("#diagnosis").type(diagnosis);
}
typeEtiologyIdentified(etiology: string) {
cy.get("#etiology_identified").type(etiology);
}
typeDifferentialDiagnosis(diagnosis: string) {
cy.get("#diff_diagnosis").type(diagnosis);
}
selectHasSari(bool: boolean) {
if (bool) cy.get("input[name=has_sari]").click();
else return;
}
selectHasAri(bool: boolean) {
if (bool) cy.get("input[name=has_ari]").click();
else return;
}
selectIsUnusual(bool: boolean) {
if (bool) cy.get("input[name=is_unusual_course]").click();
else return;
}
clickSubmitButton() {
cy.intercept("POST", "**/api/v1/patient/*/test_sample").as(
"createSampleRequest"
);
cy.get("#submit").click();
cy.wait("@createSampleRequest")
.its("response.statusCode")
.should("eq", 201);
}
clickCancelButton() {
cy.get("#cancel").click();
}
}
43 changes: 43 additions & 0 deletions cypress/pageobject/Patient/ShiftPatient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { cy } from "local-cypress";
export class ShiftPatient {
visitShiftPatient() {
cy.get("#shift_patient").click({ force: true });
}
typeContactPersonName(name: string) {
cy.get("#refering_facility_contact_name").type(name);
}
typePhoneNumber(phone: string) {
cy.get("#refering_facility_contact_number").type(phone);
}
selectFacility(facility: string) {
cy.searchAndSelectOption("input[name=assigned_facility]", facility);
}
selectPatientCategory(category: string) {
cy.clickAndSelectOption("#patient_category", category);
}
typeReasonForShift(reason: string) {
cy.get("textarea[name=reason]").type(reason);
}
typeNameOfDriver(name: string) {
cy.get("input[name=ambulance_driver_name]").type(name);
}
typeAmbulancePhoneNumber(phone: string) {
cy.get("#ambulance_phone_number").type(phone);
}
typeAmbulanceNumber(num: string) {
cy.get("#ambulance_number").type(num);
}
typeOtherComments(comment: string) {
cy.get("textarea[name=comments]").type(comment);
}
clickSubmitButton() {
cy.intercept("POST", "**/api/v1/shift/").as("createSampleRequest");
cy.get("#submit").click();
cy.wait("@createSampleRequest")
.its("response.statusCode")
.should("eq", 201);
}
clickCancelButton() {
cy.get("#cancel").click();
}
}
1 change: 1 addition & 0 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export const ConsultationDetails = (props: any) => {
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}`}
className="btn btn-primary m-1 w-full hover:text-white"
id="patient-details"
>
Patient Details
</Link>
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ export const PatientHome = (props: any) => {

<div>
<p
id="shift_patient"
className={`${
isPatientInactive(patientData, facilityId) &&
"text-gray-700"
Expand Down Expand Up @@ -1149,6 +1150,7 @@ export const PatientHome = (props: any) => {
</div>
<div>
<p
id="sample-request"
className={`${
isPatientInactive(patientData, facilityId) &&
" text-gray-700 "
Expand Down Expand Up @@ -1210,6 +1212,7 @@ export const PatientHome = (props: any) => {
</div>
<div>
<p
id="volunteer_assign"
className={classNames(
"text-center text-sm font-medium",
isPatientInactive(patientData, facilityId)
Expand Down

0 comments on commit f823862

Please sign in to comment.