Skip to content

Commit

Permalink
Merge branch 'develop' into issue-10293-UI-Enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinpraveengo authored Jan 31, 2025
2 parents 8f426f6 + 34c7b68 commit d3ff533
Show file tree
Hide file tree
Showing 24 changed files with 483 additions and 237 deletions.
4 changes: 0 additions & 4 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ describe("Facility Management", () => {
const facilityPage = new FacilityCreation();
const facilityType = "Primary Health Centre";

before(() => {
cy.loginByApi("nurse");
});

beforeEach(() => {
cy.viewport(1920, 1080);
cy.loginByApi("nurse");
Expand Down
65 changes: 54 additions & 11 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
patientCreation,
} from "@/pageObject/Patients/PatientCreation";
import { patientDashboard } from "@/pageObject/Patients/PatientDashboard";
import { PatientEncounter } from "@/pageObject/Patients/PatientEncounter";
import { patientVerify } from "@/pageObject/Patients/PatientVerify";
import { FacilityCreation } from "@/pageObject/facility/FacilityCreation";

const facilityCreation = new FacilityCreation();
const patientEncounter = new PatientEncounter();
const ENCOUNTER_TYPE = "Observation";
const ENCOUNTER_STATUS = "In Progress";
const ENCOUNTER_PRIORITY = "ASAP";
Expand All @@ -21,7 +23,6 @@ describe("Patient Management", () => {
const TEST_PHONE = "9495031234";
const PATIENT_DETAILS = {
name: "Nihal",
sex: "Male",
phone: TEST_PHONE,
};

Expand All @@ -46,7 +47,7 @@ describe("Patient Management", () => {
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "non_binary",
gender: "Non_Binary",
bloodGroup: "O+",
age: "25",
address: generateAddress(true),
Expand All @@ -60,7 +61,7 @@ describe("Patient Management", () => {
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "transgender",
gender: "Transgender",
bloodGroup: "AB+",
age: "30",
address: generateAddress(),
Expand All @@ -73,7 +74,7 @@ describe("Patient Management", () => {
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "female",
gender: "Female",
bloodGroup: "Unknown",
age: "25",
sameAsPermanentAddress: false,
Expand All @@ -90,7 +91,7 @@ describe("Patient Management", () => {
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: true,
emergencyPhoneNumber: generatePhoneNumber(),
gender: "male",
gender: "Male",
bloodGroup: "B+",
dateOfBirth: "01-01-1990",
address: generateAddress(),
Expand All @@ -99,10 +100,6 @@ describe("Patient Management", () => {
// ... other test cases ...
];

before(() => {
cy.loginByApi("doctor");
});

beforeEach(() => {
cy.loginByApi("doctor");
cy.visit("/");
Expand Down Expand Up @@ -137,11 +134,57 @@ describe("Patient Management", () => {
});
});

it("search patient with phone number and verifies details", () => {
it("Search patient with phone number and create a new encounter", () => {
facilityCreation.selectFacility("GHC Trikaripur");
patientCreation
.clickSearchPatients()
.searchPatient(TEST_PHONE)
.verifySearchResults(PATIENT_DETAILS);
.verifySearchResults(PATIENT_DETAILS)
.selectPatientFromResults(PATIENT_DETAILS.name)
.enterYearOfBirth("1999")
.clickVerifyButton();

patientVerify
.verifyPatientName(PATIENT_DETAILS.name)
.verifyCreateEncounterButton()
.clickCreateEncounter()
.selectEncounterType(ENCOUNTER_TYPE)
.selectEncounterStatus(ENCOUNTER_STATUS)
.selectEncounterPriority(ENCOUNTER_PRIORITY)
.clickSubmitEncounter()
.assertEncounterCreationSuccess();

patientDashboard.verifyEncounterPatientInfo([
ENCOUNTER_TYPE,
ENCOUNTER_STATUS,
ENCOUNTER_PRIORITY,
]);
});

it("Edit a patient details and verify the changes", () => {
const updatedPatientData: Partial<PatientFormData> = {
gender: "Female",
bloodGroup: "AB+",
address: generateAddress(true),
};

facilityCreation.selectFacility("GHC Trikaripur");
patientEncounter
.navigateToEncounters()
.openFirstEncounterDetails()
.clickPatientDetailsButton()
.clickPatientEditButton();

patientCreation
.selectGender(updatedPatientData.gender)
.selectBloodGroup(updatedPatientData.bloodGroup)
.enterAddress(updatedPatientData.address, true)
.submitPatientUpdateForm()
.verifyUpdateSuccess();

cy.verifyContentPresence("#general-info", [
updatedPatientData.gender,
updatedPatientData.address,
]);
});
});
4 changes: 0 additions & 4 deletions cypress/e2e/patient_spec/patient_encounter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ const facilityCreation = new FacilityCreation();
const patientEncounter = new PatientEncounter();

describe("Patient Encounter Questionnaire", () => {
before(() => {
cy.loginByApi("devnurse");
});

beforeEach(() => {
cy.loginByApi("devnurse");
cy.visit("/");
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ describe("User Creation", () => {
const userCreation = new UserCreation();
const userRole = "Doctor";

before(() => {
cy.loginByApi("admin");
});

beforeEach(() => {
cy.loginByApi("admin");
cy.visit("/");
Expand Down
49 changes: 38 additions & 11 deletions cypress/pageObject/Patients/PatientCreation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface PatientFormData {
name: string;
phoneNumber: string;
gender: "male" | "female" | "transgender" | "non_binary";
gender: "Male" | "Female" | "Transgender" | "Non_Binary";
bloodGroup:
| "Unknown"
| "A+"
Expand Down Expand Up @@ -54,6 +54,8 @@ export class PatientCreation {
samePhoneNumberCheckbox: '[data-cy="same-phone-number-checkbox"]',
stateSelect: '[data-cy="select-state"]',
districtSelect: '[data-cy="select-district"]',
yearOfBirthInput: '[data-cy="year-of-birth-input"]',
verifyButton: '[data-cy="confirm-verification-button"]',
};

// Actions
Expand All @@ -71,33 +73,36 @@ export class PatientCreation {
return this;
}

verifySearchResults(patientDetails: {
name: string;
sex: string;
phone: string;
}) {
verifySearchResults(patientDetails: { name: string; phone: string }) {
// Convert object values to an array of strings
const detailsArray = Object.values(patientDetails);
cy.verifyContentPresence(this.selectors.patientCard, detailsArray);
return this;
}

clickSearchPatients() {
cy.get('[data-sidebar="content"]').contains("Search Patients").click();
return this;
}

enterName(name: string) {
cy.get(this.selectors.nameInput).type(name);
enterName(name: string, clearBeforeTyping: boolean = false) {
cy.typeIntoField(this.selectors.nameInput, name, { clearBeforeTyping });
return this;
}

enterPhoneNumber(phoneNumber: string) {
enterPhoneNumber(phoneNumber: string, clearBeforeTyping: boolean = false) {
cy.typeIntoField(this.selectors.phoneInput, phoneNumber, {
skipVerification: true,
clearBeforeTyping,
});
return this;
}

verifyUpdateSuccess() {
cy.verifyNotification("Patient Updated Successfully");
return this;
}

enterDateOfBirth(dateString: string) {
// Split the date string (expected format: "DD-MM-YYYY")
const [day, month, year] = dateString.split("-");
Expand All @@ -122,8 +127,10 @@ export class PatientCreation {
return this;
}

enterAddress(address: string) {
cy.typeIntoField(this.selectors.addressInput, address);
enterAddress(address: string, clearBeforeTyping: boolean = false) {
cy.typeIntoField(this.selectors.addressInput, address, {
clearBeforeTyping,
});
return this;
}

Expand Down Expand Up @@ -189,6 +196,11 @@ export class PatientCreation {
return this;
}

submitPatientUpdateForm() {
cy.clickSubmitButton("Save");
return this;
}

clickSamePhoneNumberCheckbox() {
cy.get('[data-cy="same-phone-number-checkbox"]').click();
return this;
Expand Down Expand Up @@ -228,6 +240,21 @@ export class PatientCreation {
});
return this;
}

selectPatientFromResults(patientName: string) {
cy.verifyAndClickElement(this.selectors.patientCard, patientName);
return this;
}

enterYearOfBirth(year: string) {
cy.typeIntoField(this.selectors.yearOfBirthInput, year);
return this;
}

clickVerifyButton() {
cy.verifyAndClickElement(this.selectors.verifyButton, "Verify");
return this;
}
}

export const patientCreation = new PatientCreation();
13 changes: 13 additions & 0 deletions cypress/pageObject/Patients/PatientEncounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,17 @@ export class PatientEncounter {
cy.verifyContentPresence('[data-cy="encounter-overview"]', expectedValues);
return this;
}

clickPatientDetailsButton() {
cy.verifyAndClickElement(
'[data-cy="patient-details-button"]',
"Patient Details",
);
return this;
}

clickPatientEditButton() {
cy.verifyAndClickElement('[data-cy="edit-patient-button"]', "Edit");
return this;
}
}
Loading

0 comments on commit d3ff533

Please sign in to comment.