Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/DonXavierdev/care_fe int…
Browse files Browse the repository at this point in the history
…o issues/7417/File-upload-enhancement
  • Loading branch information
DonXavierdev committed Jan 31, 2025
2 parents eddcfc7 + febfcae commit 776ba36
Show file tree
Hide file tree
Showing 64 changed files with 1,727 additions and 429 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ describe("Facility Management", () => {
const facilityType = "Primary Health Centre";

beforeEach(() => {
// Set larger viewport to ensure all elements are visible
cy.viewport(1920, 1080);
cy.visit("/login");
cy.loginByApi("nurse");
cy.visit("/");
});

it("Create a new facility using the admin role and verify validation errors", () => {
Expand Down
160 changes: 138 additions & 22 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import {
generatePhoneNumber,
} from "utils/commonUtils";

import { patientCreation } from "@/pageObject/Patients/PatientCreation";
import {
PatientFormData,
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 @@ -18,57 +23,168 @@ describe("Patient Management", () => {
const TEST_PHONE = "9495031234";
const PATIENT_DETAILS = {
name: "Nihal",
sex: "Male",
phone: TEST_PHONE,
};

const testPatientData = {
name: generateName(),
phoneNumber: generatePhoneNumber(),
gender: "male",
bloodGroup: "B+",
dateOfBirth: "01-01-1990",
address: generateAddress(),
const basePatientData: Partial<PatientFormData> = {
pincode: "682001",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
ward: "4",
sameAsPermanentAddress: true,
hasEmergencyContact: false,
};

const patientTestCases: Array<{
description: string;
data: PatientFormData;
}> = [
{
description: "non-binary patient | O+ blood group | multi-line address",
data: {
...basePatientData,
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "Non_Binary",
bloodGroup: "O+",
age: "25",
address: generateAddress(true),
} as PatientFormData,
},
{
description:
"transgender patient | AB+ blood group | with emergency contact",
data: {
...basePatientData,
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "Transgender",
bloodGroup: "AB+",
age: "30",
address: generateAddress(),
} as PatientFormData,
},
{
description: "female patient | different addresses | same phone number",
data: {
...basePatientData,
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: false,
gender: "Female",
bloodGroup: "Unknown",
age: "25",
sameAsPermanentAddress: false,
address: generateAddress(),
permanentAddress: generateAddress(),
} as PatientFormData,
},
{
description:
"standard male patient | same address | different emergency contact",
data: {
...basePatientData,
name: generateName(),
phoneNumber: generatePhoneNumber(),
hasEmergencyContact: true,
emergencyPhoneNumber: generatePhoneNumber(),
gender: "Male",
bloodGroup: "B+",
dateOfBirth: "01-01-1990",
address: generateAddress(),
} as PatientFormData,
},
// ... other test cases ...
];

beforeEach(() => {
cy.visit("/login");
cy.loginByApi("doctor");
cy.visit("/");
});

it("create a new patient and verify details", () => {
cy.loginByApi("doctor");
patientTestCases.forEach(({ description, data }) => {
it(`creates a new ${description} and verifies registration`, () => {
facilityCreation.selectFacility("GHC Trikaripur");
patientCreation
.clickSearchPatients()
.clickCreateNewPatient()
.fillPatientDetails(data)
.submitPatientForm()
.assertPatientRegistrationSuccess();

// Verify encounter creation
patientVerify
.verifyPatientName(data.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 create a new encounter", () => {
facilityCreation.selectFacility("GHC Trikaripur");
patientCreation
.clickSearchPatients()
.clickCreateNewPatient()
.fillPatientDetails(testPatientData)
.submitPatientForm()
.assertPatientRegistrationSuccess();
.searchPatient(TEST_PHONE)
.verifySearchResults(PATIENT_DETAILS)
.selectPatientFromResults(PATIENT_DETAILS.name)
.enterYearOfBirth("1999")
.clickVerifyButton();

patientVerify
.verifyPatientName(testPatientData.name)
.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("search patient with phone number and verifies details", () => {
cy.loginByApi("staff");
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
.clickSearchPatients()
.searchPatient(TEST_PHONE)
.verifySearchResults(PATIENT_DETAILS);
.selectGender(updatedPatientData.gender)
.selectBloodGroup(updatedPatientData.bloodGroup)
.enterAddress(updatedPatientData.address, true)
.submitPatientUpdateForm()
.verifyUpdateSuccess();

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

describe("Patient Encounter Questionnaire", () => {
beforeEach(() => {
// Login and set up any necessary test state
cy.visit("/login");
cy.loginByApi("devnurse");
cy.visit("/");
});

it("Create a new ABG questionnaire and verify the values", () => {
const abgValues = {
pco2: "120",
po2: "80",
};
cy.loginByApi("devnurse");
facilityCreation.selectFacility("GHC Trikaripur");

// Chain the methods instead of multiple separate calls
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe("User Creation", () => {
const userRole = "Doctor";

beforeEach(() => {
cy.visit("/login");
cy.loginByApi("admin");
cy.visit("/");
});

it("should create a new user successfully", () => {
Expand Down
Loading

0 comments on commit 776ba36

Please sign in to comment.