diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index 7c7111af006..d95832965bb 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -1,6 +1,6 @@ -import { FacilityCreation } from "@/cypress/pageObject/facility/FacilityCreation"; -import { generatePhoneNumber } from "@/cypress/utils/commonUtils"; -import { generateFacilityData } from "@/cypress/utils/facilityData"; +import { FacilityCreation } from "pageObject/facility/FacilityCreation"; +import { generatePhoneNumber } from "utils/commonUtils"; +import { generateFacilityData } from "utils/facilityData"; const LOCATION_HIERARCHY = { localBody: "Aluva", @@ -12,6 +12,8 @@ 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"); }); diff --git a/cypress/e2e/patient_spec/patient_creation.cy.ts b/cypress/e2e/patient_spec/patient_creation.cy.ts index 8bb6a30b46c..06cb1a606b2 100644 --- a/cypress/e2e/patient_spec/patient_creation.cy.ts +++ b/cypress/e2e/patient_spec/patient_creation.cy.ts @@ -2,12 +2,11 @@ import { patientCreation } from "pageObject/Patients/PatientCreation"; import { patientDashboard } from "pageObject/Patients/PatientDashboard"; import { patientVerify } from "pageObject/Patients/PatientVerify"; import { FacilityCreation } from "pageObject/facility/FacilityCreation"; - import { generateAddress, generateName, generatePhoneNumber, -} from "@/cypress/utils/commonUtils"; +} from "utils/commonUtils"; const facilityCreation = new FacilityCreation(); const ENCOUNTER_TYPE = "Observation"; diff --git a/cypress/pageObject/Patients/PatientCreation.ts b/cypress/pageObject/Patients/PatientCreation.ts index 388321ca8c0..b9bb144f411 100644 --- a/cypress/pageObject/Patients/PatientCreation.ts +++ b/cypress/pageObject/Patients/PatientCreation.ts @@ -109,7 +109,7 @@ export class PatientCreation { } selectLocalBody(localBody: string) { - cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody); + cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody, false); return this; } diff --git a/cypress/pageObject/Users/UserCreation.ts b/cypress/pageObject/Users/UserCreation.ts index b4658aab531..47bfb40bd3c 100644 --- a/cypress/pageObject/Users/UserCreation.ts +++ b/cypress/pageObject/Users/UserCreation.ts @@ -99,7 +99,7 @@ export class UserCreation { } selectLocalBody(localBody: string) { - cy.clickAndSelectOption('[data-cy="select-local_body"]', localBody); + cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody, false); return this; } diff --git a/cypress/pageObject/facility/FacilityCreation.ts b/cypress/pageObject/facility/FacilityCreation.ts index 3c00df258b9..8e630f7e56e 100644 --- a/cypress/pageObject/facility/FacilityCreation.ts +++ b/cypress/pageObject/facility/FacilityCreation.ts @@ -127,7 +127,13 @@ export class FacilityCreation { } fillLocationHierarchy(location: { localBody: string; ward: string }) { - cy.typeAndSelectOption('[data-cy="select-local_body"]', location.localBody); + // Don't verify selection for local body (false parameter) + cy.typeAndSelectOption( + '[data-cy="select-local_body"]', + location.localBody, + false, + ); + // Verify selection for ward (default behavior) cy.typeAndSelectOption('[data-cy="select-ward"]', location.ward); return this; } diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index de70a42fdfc..597454eb00c 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -108,19 +108,30 @@ Cypress.Commands.add("clickCancelButton", (buttonText = "Cancel") => { Cypress.Commands.add( "typeAndSelectOption", - (selector: string, value: string) => { + (selector: string, value: string, verify: boolean = true) => { // Click to open the dropdown - cy.get(selector).click(); - - // Type in the command input - cy.get("[cmdk-input]").should("be.visible").clear().type(value); - - // Select the filtered option from command menu - cy.get("[cmdk-list]") - .find("[cmdk-item]") - .contains(value) - .should("be.visible") - .click(); + cy.get(selector) + .click() + .then(() => { + // Type in the command input + cy.get("[cmdk-input]") + .should("be.visible") + .type(value) + .then(() => { + // Select the filtered option from command menu + cy.get("[cmdk-list]") + .find("[cmdk-item]") + .contains(value) + .should("be.visible") + .click() + .then(() => { + // Verify the selected value is present in the selector (if verify is true) + if (verify) { + cy.get(selector).should("contain", value); + } + }); + }); + }); }, ); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 6a2df4ca4eb..4a8bd309951 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -16,7 +16,8 @@ declare global { clickCancelButton(buttonText?: string): Chainable; typeAndSelectOption( element: string, - referance: string, + reference: string, + skipVerification?: boolean, ): Chainable; clickAndMultiSelectOption( selector: string,