-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cypress tests for patient details page
- Loading branch information
Showing
6 changed files
with
240 additions
and
0 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
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(); | ||
}); | ||
}); |
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,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(); | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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