Skip to content

Commit

Permalink
Merge branch 'develop' into questionaire_duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaJ2305 authored Jan 30, 2025
2 parents 4b4a555 + 5edb84e commit 7c7f51d
Show file tree
Hide file tree
Showing 44 changed files with 289 additions and 391 deletions.
7 changes: 5 additions & 2 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ describe("Facility Management", () => {
const facilityPage = new FacilityCreation();
const facilityType = "Primary Health Centre";

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

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
139 changes: 106 additions & 33 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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 { patientVerify } from "@/pageObject/Patients/PatientVerify";
import { FacilityCreation } from "@/pageObject/facility/FacilityCreation";
Expand All @@ -22,49 +25,119 @@ describe("Patient Management", () => {
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,
};

beforeEach(() => {
cy.visit("/login");
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 ...
];

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

it("create a new patient and verify details", () => {
beforeEach(() => {
cy.loginByApi("doctor");
facilityCreation.selectFacility("GHC Trikaripur");
patientCreation
.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,
]);
cy.visit("/");
});

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 verifies details", () => {
cy.loginByApi("staff");
facilityCreation.selectFacility("GHC Trikaripur");
patientCreation
.clickSearchPatients()
Expand Down
9 changes: 6 additions & 3 deletions cypress/e2e/patient_spec/patient_encounter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ const facilityCreation = new FacilityCreation();
const patientEncounter = new PatientEncounter();

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

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
6 changes: 5 additions & 1 deletion cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ describe("User Creation", () => {
const userCreation = new UserCreation();
const userRole = "Doctor";

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

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

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

0 comments on commit 7c7f51d

Please sign in to comment.