Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to support local dummy data #10279

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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);

Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ describe("Patient Management", () => {
dateOfBirth: "01-01-1990",
address: generateAddress(),
pincode: "682001",
localBody: "Aluva",
localBody: "Koovappady",
gramaPanchayat: "Asamannoor",
ward: "4",
};

Expand All @@ -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()
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/patient_spec/patient_encounter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ describe("User Creation", () => {
gender: "Male",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
localBody: "Koovappady",
gramaPanchayat: "Asamannoor",
ward: "4",
};

Expand Down
14 changes: 5 additions & 9 deletions cypress/fixtures/users.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
12 changes: 11 additions & 1 deletion cypress/pageObject/Patients/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface PatientFormData {
address: string;
pincode: string;
localBody: string;
gramaPanchayat: string;
ward: string;
}

Expand All @@ -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;
Expand Down Expand Up @@ -105,6 +105,7 @@ export class PatientCreation {
.enterAddress(patient.address)
.enterPincode(patient.pincode)
.selectLocalBody(patient.localBody)
.selectGramaPanchayat(patient.gramaPanchayat)
.selectWard(patient.ward);
}

Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions cypress/pageObject/Patients/PatientEncounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions cypress/pageObject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface UserData {
state?: string;
district?: string;
localBody?: string;
gramaPanchayat?: string;
ward?: string;
gender?: string;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
13 changes: 11 additions & 2 deletions cypress/pageObject/facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/pages/Encounters/EncounterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export function EncounterList({
<Popover>
<PopoverTrigger asChild>
<Button
data-cy="encounter-search-box"
variant="outline"
size="sm"
className={cn(
Expand Down
Loading