From 706a36a8bd0ca52f4d6c3e8df861dfb2fe9814bc Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:21:08 +0530 Subject: [PATCH] changes to support local dummy data --- cypress/e2e/facility_spec/facility_creation.cy.ts | 14 +++++--------- cypress/e2e/patient_spec/patient_creation.cy.ts | 9 +++++---- cypress/e2e/patient_spec/patient_encounter.cy.ts | 6 ++++-- cypress/e2e/users_spec/user_creation.cy.ts | 3 ++- cypress/fixtures/users.json | 14 +++++--------- cypress/pageObject/Patients/PatientCreation.ts | 12 +++++++++++- cypress/pageObject/Patients/PatientEncounter.ts | 7 +++++++ cypress/pageObject/Users/UserCreation.ts | 12 ++++++++++++ cypress/pageObject/facility/FacilityCreation.ts | 13 +++++++++++-- src/pages/Encounters/EncounterList.tsx | 1 + 10 files changed, 63 insertions(+), 28 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index d2d0351c414..1302a877fd3 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -3,19 +3,19 @@ import { generatePhoneNumber } from "@/utils/commonUtils"; import { generateFacilityData } from "@/utils/facilityData"; const LOCATION_HIERARCHY = { - localBody: "Aluva", + localBody: "Koovappady", + gramaPanchayat: "Asamannoor", ward: "4", }; describe("Facility Management", () => { const facilityPage = new FacilityCreation(); const facilityType = "Primary Health Centre"; + const pincode = "682001"; beforeEach(() => { - // Set larger viewport to ensure all elements are visible - cy.viewport(1920, 1080); cy.visit("/login"); - cy.loginByApi("nurse"); + cy.loginByApi("admin"); }); it("Create a new facility using the admin role and verify validation errors", () => { @@ -37,11 +37,7 @@ describe("Facility Management", () => { facilityPage.selectFeatures(testFacility.features); - facilityPage.fillContactDetails( - phoneNumber, - testFacility.pincode, - testFacility.address, - ); + facilityPage.fillContactDetails(phoneNumber, pincode, testFacility.address); facilityPage.fillLocationHierarchy(LOCATION_HIERARCHY); diff --git a/cypress/e2e/patient_spec/patient_creation.cy.ts b/cypress/e2e/patient_spec/patient_creation.cy.ts index cbeb15a241d..64ea6d224f7 100644 --- a/cypress/e2e/patient_spec/patient_creation.cy.ts +++ b/cypress/e2e/patient_spec/patient_creation.cy.ts @@ -30,7 +30,8 @@ describe("Patient Management", () => { dateOfBirth: "01-01-1990", address: generateAddress(), pincode: "682001", - localBody: "Aluva", + localBody: "Koovappady", + gramaPanchayat: "Asamannoor", ward: "4", }; @@ -40,7 +41,7 @@ describe("Patient Management", () => { it("create a new patient and verify details", () => { cy.loginByApi("doctor"); - facilityCreation.selectFacility("GHC Trikaripur"); + facilityCreation.selectFacility("CHC Aluva"); patientCreation .clickSearchPatients() .clickCreateNewPatient() @@ -64,8 +65,8 @@ describe("Patient Management", () => { }); it("search patient with phone number and verifies details", () => { - cy.loginByApi("staff"); - facilityCreation.selectFacility("GHC Trikaripur"); + cy.loginByApi("doctor"); + facilityCreation.selectFacility("CHC Aluva"); patientCreation .clickSearchPatients() .searchPatient(TEST_PHONE) diff --git a/cypress/e2e/patient_spec/patient_encounter.cy.ts b/cypress/e2e/patient_spec/patient_encounter.cy.ts index ac13650585d..7300dddecfa 100644 --- a/cypress/e2e/patient_spec/patient_encounter.cy.ts +++ b/cypress/e2e/patient_spec/patient_encounter.cy.ts @@ -15,12 +15,14 @@ describe("Patient Encounter Questionnaire", () => { pco2: "120", po2: "80", }; - cy.loginByApi("devnurse"); - facilityCreation.selectFacility("GHC Trikaripur"); + const patientName = "Sarah Brown"; + cy.loginByApi("nurse"); + facilityCreation.selectFacility("CHC Aluva"); // Chain the methods instead of multiple separate calls patientEncounter .navigateToEncounters() + .searchEncounterName(patientName) .openFirstEncounterDetails() .clickUpdateEncounter() .addQuestionnaire("Arterial Blood Gas") diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index c43eae3d02f..ea05d5314b3 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -34,7 +34,8 @@ describe("User Creation", () => { gender: "Male", state: "Kerala", district: "Ernakulam", - localBody: "Aluva", + localBody: "Koovappady", + gramaPanchayat: "Asamannoor", ward: "4", }; diff --git a/cypress/fixtures/users.json b/cypress/fixtures/users.json index c484f51b6f2..a3b5248bf00 100644 --- a/cypress/fixtures/users.json +++ b/cypress/fixtures/users.json @@ -1,22 +1,18 @@ { "admin": { - "username": "devsuperadmin", + "username": "devadmin", "password": "Test@123" }, "nurse": { - "username": "nihal-nurse", + "username": "devnurse", "password": "Test@123" }, "doctor": { - "username": "arjun-doctor", + "username": "devdoctor", "password": "Test@123" }, - "staff": { - "username": "nihalstaff", - "password": "Test@123" - }, - "devnurse": { - "username": "dev-nurse", + "volunteer": { + "username": "devvolunteer", "password": "Test@123" } } diff --git a/cypress/pageObject/Patients/PatientCreation.ts b/cypress/pageObject/Patients/PatientCreation.ts index b9bb144f411..dd6f45444d7 100644 --- a/cypress/pageObject/Patients/PatientCreation.ts +++ b/cypress/pageObject/Patients/PatientCreation.ts @@ -7,6 +7,7 @@ interface PatientFormData { address: string; pincode: string; localBody: string; + gramaPanchayat: string; ward: string; } @@ -30,7 +31,6 @@ export class PatientCreation { 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; @@ -105,6 +105,7 @@ export class PatientCreation { .enterAddress(patient.address) .enterPincode(patient.pincode) .selectLocalBody(patient.localBody) + .selectGramaPanchayat(patient.gramaPanchayat) .selectWard(patient.ward); } @@ -113,6 +114,15 @@ export class PatientCreation { return this; } + selectGramaPanchayat(gramaPanchayat: string) { + cy.typeAndSelectOption( + '[data-cy="select-grama_panchayat"]', + gramaPanchayat, + false, + ); + return this; + } + selectWard(ward: string) { cy.typeAndSelectOption('[data-cy="select-ward"]', ward); return this; diff --git a/cypress/pageObject/Patients/PatientEncounter.ts b/cypress/pageObject/Patients/PatientEncounter.ts index c73236d2d1b..7e25e94ea2a 100644 --- a/cypress/pageObject/Patients/PatientEncounter.ts +++ b/cypress/pageObject/Patients/PatientEncounter.ts @@ -22,6 +22,13 @@ export class PatientEncounter { return this; } + searchEncounterName(patientName: string) { + cy.get('[data-cy="encounter-search-box"]').click(); + cy.typeIntoField("#encounter-search", patientName); + cy.get('[data-cy="encounter-search-box"]').click(); + return this; + } + // Questionnaire actions addQuestionnaire(questionnaireName: string) { cy.get('[data-cy="add-questionnaire-button"]').click(); diff --git a/cypress/pageObject/Users/UserCreation.ts b/cypress/pageObject/Users/UserCreation.ts index e5cc81e0332..4c478f167fc 100644 --- a/cypress/pageObject/Users/UserCreation.ts +++ b/cypress/pageObject/Users/UserCreation.ts @@ -9,6 +9,7 @@ export interface UserData { state?: string; district?: string; localBody?: string; + gramaPanchayat?: string; ward?: string; gender?: string; } @@ -103,6 +104,15 @@ export class UserCreation { return this; } + selectGramaPanchayat(gramaPanchayat: string) { + cy.typeAndSelectOption( + '[data-cy="select-grama_panchayat"]', + gramaPanchayat, + false, + ); + return this; + } + selectWard(ward: string) { cy.clickAndSelectOption('[data-cy="select-ward"]', ward); return this; @@ -128,6 +138,8 @@ export class UserCreation { if (userData.state) this.selectState(userData.state); if (userData.district) this.selectDistrict(userData.district); if (userData.localBody) this.selectLocalBody(userData.localBody); + if (userData.gramaPanchayat) + this.selectGramaPanchayat(userData.gramaPanchayat); if (userData.ward) this.selectWard(userData.ward); return this; } diff --git a/cypress/pageObject/facility/FacilityCreation.ts b/cypress/pageObject/facility/FacilityCreation.ts index 8f7e0edf319..ade358fd4ee 100644 --- a/cypress/pageObject/facility/FacilityCreation.ts +++ b/cypress/pageObject/facility/FacilityCreation.ts @@ -126,13 +126,22 @@ export class FacilityCreation { .should("not.be.empty"); } - fillLocationHierarchy(location: { localBody: string; ward: string }) { - // Don't verify selection for local body (false parameter) + fillLocationHierarchy(location: { + localBody: string; + gramaPanchayat: string; + ward: string; + }) { cy.typeAndSelectOption( '[data-cy="select-local_body"]', location.localBody, false, ); + + cy.typeAndSelectOption( + '[data-cy="select-grama_panchayat"]', + location.gramaPanchayat, + false, + ); // Verify selection for ward (default behavior) cy.typeAndSelectOption('[data-cy="select-ward"]', location.ward); return this; diff --git a/src/pages/Encounters/EncounterList.tsx b/src/pages/Encounters/EncounterList.tsx index b4abc39fe7a..25c5ae5cb83 100644 --- a/src/pages/Encounters/EncounterList.tsx +++ b/src/pages/Encounters/EncounterList.tsx @@ -222,6 +222,7 @@ export function EncounterList({