-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into serachinput_design…
…_update
- Loading branch information
Showing
42 changed files
with
1,111 additions
and
413 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,74 @@ | ||
import { patientCreation } from "pageObject/Patients/PatientCreation"; | ||
import { patientDashboard } from "pageObject/Patients/PatientDashboard"; | ||
import { patientVerify } from "pageObject/Patients/PatientVerify"; | ||
|
||
import { | ||
generateAddress, | ||
generatePatientName, | ||
generatePhoneNumber, | ||
} from "../../utils/commonUtils"; | ||
|
||
const ENCOUNTER_TYPE = "Observation"; | ||
const ENCOUNTER_STATUS = "In Progress"; | ||
const ENCOUNTER_PRIORITY = "ASAP"; | ||
|
||
describe("Patient Management", () => { | ||
const TEST_PHONE = "9495031234"; | ||
const PATIENT_DETAILS = { | ||
name: "Nihal", | ||
sex: "Male", | ||
phone: TEST_PHONE, | ||
}; | ||
|
||
const testPatientData = { | ||
name: generatePatientName(), | ||
phoneNumber: generatePhoneNumber(), | ||
gender: "male", | ||
bloodGroup: "B+", | ||
dateOfBirth: "01-01-1990", | ||
address: generateAddress(), | ||
pincode: "682001", | ||
state: "Kerala", | ||
district: "Ernakulam", | ||
localBody: "Aluva", | ||
ward: "4", | ||
}; | ||
|
||
beforeEach(() => { | ||
cy.visit("/login"); | ||
}); | ||
|
||
it("create a new patient and verify details", () => { | ||
cy.loginByApi("doctor"); | ||
patientCreation | ||
.selectFacility("Arike") | ||
.clickSearchPatients() | ||
.clickCreateNewPatient() | ||
.fillPatientDetails(testPatientData) | ||
.submitPatientForm() | ||
.assertPatientRegistrationSuccess(); | ||
patientVerify | ||
.verifyPatientName(testPatientData.name) | ||
.verifyCreateEncounterButton() | ||
.clickCreateEncounter() | ||
.selectEncounterType(ENCOUNTER_TYPE) | ||
.selectEncounterStatus(ENCOUNTER_STATUS) | ||
.selectEncounterPriority(ENCOUNTER_PRIORITY) | ||
.clickSubmitEncounter() | ||
.assertEncounterCreationSuccess(); | ||
patientDashboard.verifyEncounterPatientInfo([ | ||
ENCOUNTER_TYPE, | ||
ENCOUNTER_STATUS, | ||
ENCOUNTER_PRIORITY, | ||
]); | ||
}); | ||
|
||
it("search patient with phone number and verifies details", () => { | ||
cy.loginByApi("staff"); | ||
patientCreation | ||
.selectFacility("Arike") | ||
.clickSearchPatients() | ||
.searchPatient(TEST_PHONE) | ||
.verifySearchResults(PATIENT_DETAILS); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
interface PatientFormData { | ||
name: string; | ||
phoneNumber: string; | ||
dateOfBirth: string; | ||
gender: string; | ||
bloodGroup: string; | ||
address: string; | ||
pincode: string; | ||
state: string; | ||
district: string; | ||
localBody: string; | ||
ward: string; | ||
} | ||
|
||
export class PatientCreation { | ||
// Selectors | ||
private selectors = { | ||
patientsButton: '[data-cy="patients-button"]', | ||
searchInput: "#patient-search", | ||
patientCard: "#patient-search-results", | ||
patientName: '[data-cy="patient-name"]', | ||
patientDetails: "#patient-search-results", | ||
createNewPatientButton: '[data-cy="create-new-patient-button"]', | ||
}; | ||
|
||
// Actions | ||
clickCreateNewPatient() { | ||
cy.get(this.selectors.createNewPatientButton).click(); | ||
cy.url().should("include", "/patient/create"); | ||
return this; | ||
} | ||
|
||
searchPatient(searchQuery: string) { | ||
cy.get(this.selectors.searchInput).type(searchQuery); | ||
|
||
// Wait for results to load | ||
cy.get(this.selectors.patientCard).should("be.visible"); | ||
return this; | ||
} | ||
|
||
verifySearchResults(patientDetails: { | ||
name: string; | ||
sex: string; | ||
phone: string; | ||
}) { | ||
// Convert object values to an array of strings | ||
const detailsArray = Object.values(patientDetails); | ||
cy.verifyContentPresence(this.selectors.patientDetails, detailsArray); | ||
} | ||
|
||
selectFacility(facilityName: string) { | ||
cy.verifyAndClickElement("[data-cy='facility-list']", facilityName); | ||
return this; | ||
} | ||
|
||
clickSearchPatients() { | ||
cy.get('[data-sidebar="content"]').contains("Search Patients").click(); | ||
return this; | ||
} | ||
|
||
enterName(name: string) { | ||
cy.typeIntoField('[data-cy="patient-name-input"]', name); | ||
return this; | ||
} | ||
|
||
enterPhoneNumber(phoneNumber: string) { | ||
cy.typeIntoField('[data-cy="patient-phone-input"]', phoneNumber, { | ||
skipVerification: true, | ||
}); | ||
return this; | ||
} | ||
|
||
enterDateOfBirth(dateString: string) { | ||
// Split the date string (expected format: "DD-MM-YYYY") | ||
const [day, month, year] = dateString.split("-"); | ||
|
||
cy.get('[data-cy="dob-day-input"]').type(day); | ||
cy.get('[data-cy="dob-month-input"]').type(month); | ||
cy.get('[data-cy="dob-year-input"]').type(year); | ||
|
||
return this; | ||
} | ||
|
||
selectGender(gender: string) { | ||
const lowercaseGender = gender.toLowerCase(); | ||
cy.get(`[data-cy="gender-radio-${lowercaseGender}"]`).click(); | ||
return this; | ||
} | ||
|
||
selectBloodGroup(bloodGroup: string) { | ||
cy.clickAndSelectOption('[data-cy="blood-group-select"]', bloodGroup); | ||
return this; | ||
} | ||
|
||
enterAddress(address: string) { | ||
cy.typeIntoField('[data-cy="current-address-input"]', address); | ||
return this; | ||
} | ||
|
||
enterPincode(pincode: string) { | ||
cy.typeIntoField('[data-cy="pincode-input"]', pincode); | ||
return this; | ||
} | ||
|
||
fillPatientDetails(patient: PatientFormData) { | ||
return this.enterName(patient.name) | ||
.enterPhoneNumber(patient.phoneNumber) | ||
.clickSamePhoneNumberCheckbox() | ||
.selectGender(patient.gender) | ||
.selectBloodGroup(patient.bloodGroup) | ||
.enterDateOfBirth(patient.dateOfBirth) | ||
.enterAddress(patient.address) | ||
.enterPincode(patient.pincode) | ||
.selectState(patient.state) | ||
.selectDistrict(patient.district) | ||
.selectLocalBody(patient.localBody) | ||
.selectWard(patient.ward); | ||
} | ||
|
||
selectState(state: string) { | ||
cy.typeAndSelectOption('[data-cy="select-state"]', state); | ||
return this; | ||
} | ||
|
||
selectDistrict(district: string) { | ||
cy.typeAndSelectOption('[data-cy="select-district"]', district); | ||
return this; | ||
} | ||
|
||
selectLocalBody(localBody: string) { | ||
cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody); | ||
return this; | ||
} | ||
|
||
selectWard(ward: string) { | ||
cy.typeAndSelectOption('[data-cy="select-ward"]', ward); | ||
return this; | ||
} | ||
|
||
submitPatientForm() { | ||
cy.clickSubmitButton("Save and Continue"); | ||
return this; | ||
} | ||
|
||
clickSamePhoneNumberCheckbox() { | ||
cy.get('[data-cy="same-phone-number-checkbox"]').click(); | ||
return this; | ||
} | ||
|
||
assertPatientRegistrationSuccess() { | ||
cy.verifyNotification("Patient Registered Successfully"); | ||
return this; | ||
} | ||
} | ||
|
||
export const patientCreation = new PatientCreation(); |
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,8 @@ | ||
class PatientDashboard { | ||
verifyEncounterPatientInfo(contents: string[]) { | ||
cy.verifyContentPresence("#patient-infobadges", contents); | ||
return this; | ||
} | ||
} | ||
|
||
export const patientDashboard = new PatientDashboard(); |
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
class PatientVerify { | ||
verifyPatientName(expectedName: string) { | ||
cy.get('[data-cy="verify-patient-name"]').should("contain", expectedName); | ||
return this; | ||
} | ||
|
||
verifyCreateEncounterButton() { | ||
cy.get('[data-cy="create-encounter-button"]').should( | ||
"contain", | ||
"Create Encounter", | ||
); | ||
return this; | ||
} | ||
|
||
clickCreateEncounter() { | ||
cy.verifyAndClickElement( | ||
'[data-cy="create-encounter-button"]', | ||
"Create Encounter", | ||
); | ||
return this; | ||
} | ||
|
||
// Map display text to data-cy values for better maintainability | ||
private encounterTypeMap = { | ||
Observation: "obsenc", | ||
Inpatient: "imp", | ||
Ambulatory: "amb", | ||
Emergency: "emer", | ||
Virtual: "vr", | ||
"Home Health": "hh", | ||
}; | ||
|
||
selectEncounterType(displayText: string) { | ||
const dataCyValue = this.encounterTypeMap[displayText]; | ||
cy.verifyAndClickElement( | ||
`[data-cy="encounter-type-${dataCyValue}"]`, | ||
displayText, | ||
); | ||
return this; | ||
} | ||
|
||
selectEncounterStatus(status: string) { | ||
cy.clickAndSelectOption('[data-cy="encounter-status"]', status); | ||
return this; | ||
} | ||
|
||
selectEncounterPriority(priority: string) { | ||
cy.clickAndSelectOption('[data-cy="encounter-priority"]', priority); | ||
return this; | ||
} | ||
|
||
clickSubmitEncounter() { | ||
cy.clickSubmitButton("Create Encounter"); | ||
return this; | ||
} | ||
|
||
assertEncounterCreationSuccess() { | ||
cy.verifyNotification("Encounter created successfully"); | ||
return this; | ||
} | ||
} | ||
|
||
export const patientVerify = new PatientVerify(); |
Oops, something went wrong.