diff --git a/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts b/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts index da46a6c093e..963f62a76e0 100644 --- a/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts +++ b/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts @@ -13,6 +13,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { const patientInvestigation = new PatientInvestigation(); const patientPrescription = new PatientPrescription(); const patientCategory = "Moderate"; + const patientModifiedCategory = "Critical"; const additionalSymptoms = "Fever"; const physicalExamination = "physical examination details"; const otherExamination = "Other"; @@ -150,6 +151,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { ]); // verify the edit functionality patientLogupdate.clickUpdateDetail(); + patientLogupdate.verifyPatientCategory(patientCategory); + patientLogupdate.verifyRoundType("Progress Note"); + patientLogupdate.selectPatientCategory(patientModifiedCategory); patientLogupdate.typeSystolic(patientModifiedSystolic); patientLogupdate.typeDiastolic(patientModifiedDiastolic); cy.clickSubmitButton("Continue"); @@ -249,8 +253,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientPage.interceptGetPatient(); patientLogupdate.clickLogupdate(); patientPage.verifyGetPatientResponse(); - patientLogupdate.typePhysicalExamination(physicalExamination); + patientLogupdate.verifyRoundType("Brief Update"); patientLogupdate.selectPatientCategory(patientCategory); + patientLogupdate.typePhysicalExamination(physicalExamination); patientLogupdate.typeOtherDetails(otherExamination); patientLogupdate.selectSymptomsDate("01012024"); patientLogupdate.typeAndMultiSelectSymptoms("fe", ["Fever"]); @@ -282,11 +287,13 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { cy.verifyNotification("Consultation updated successfully"); cy.closeNotification(); patientLogupdate.clickLogupdate(); + patientLogupdate.verifyRoundType("Brief Update"); // Verify the default round type + patientLogupdate.selectRoundType("Brief Update"); + patientLogupdate.selectPatientCategory(patientCategory); patientLogupdate.typePhysicalExamination(physicalExamination); patientLogupdate.typeOtherDetails(otherExamination); patientLogupdate.selectSymptomsDate("01012024"); patientLogupdate.typeAndMultiSelectSymptoms("fe", ["Fever"]); - patientLogupdate.selectPatientCategory(patientCategory); patientLogupdate.typeSystolic(patientSystolic); patientLogupdate.typeDiastolic(patientDiastolic); patientLogupdate.typePulse(patientPulse); @@ -318,10 +325,10 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientRhythm, ]); patientLogupdate.clickUpdateDetail(); - patientLogupdate.clearIntoElementById("#systolic"); - patientLogupdate.typeSystolic(patientModifiedSystolic); - patientLogupdate.clearIntoElementById("#diastolic"); - patientLogupdate.typeDiastolic(patientModifiedDiastolic); + patientLogupdate.verifyPatientCategory(patientCategory); + patientLogupdate.verifyRoundType("Brief Update"); + patientLogupdate.typeSystolic(patientModifiedSystolic, true); + patientLogupdate.typeDiastolic(patientModifiedDiastolic, true); cy.clickSubmitButton("Continue"); cy.verifyNotification("Brief Update updated successfully"); cy.contains("button", "Log Updates").click(); diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index 5601f994c53..a8b1e47bb4d 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -1,3 +1,5 @@ +import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation"; + import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientData, @@ -6,7 +8,11 @@ import { import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; -import { generatePhoneNumber } from "../../pageobject/utils/constants"; +import { + generatePatientName, + generatePhoneNumber, + generateRandomAddress, +} from "../../pageobject/utils/constants"; const yearOfBirth = "2001"; @@ -15,38 +21,21 @@ const calculateAge = () => { return currentYear - parseInt(yearOfBirth); }; -const getRelativeDateString = (deltaDays = 0) => { - const date = new Date(); - if (deltaDays) { - date.setDate(date.getDate() + deltaDays); - } - return date - .toLocaleDateString("en-IN", { - day: "2-digit", - month: "2-digit", - year: "numeric", - }) - .replace(/\//g, ""); -}; - describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); const patientTransfer = new PatientTransfer(); const patientInsurance = new PatientInsurance(); const patientMedicalHistory = new PatientMedicalHistory(); + const patientConsultationPage = new PatientConsultationPage(); const phone_number = generatePhoneNumber(); const age = calculateAge(); const patientFacility = "Dummy Facility 40"; const patientDateOfBirth = "01012001"; - const patientMenstruationStartDate = getRelativeDateString(-10); - const patientDateOfDelivery = getRelativeDateString(-20); - const patientOneName = "Great Napolean 14"; + const patientOneName = generatePatientName(); const patientOneGender = "Male"; const patientOneUpdatedGender = "Female"; - const patientOneAddress = `149/J, 3rd Block, - Aluva - Ernakulam, Kerala - 682001`; + const patientOneAddress = generateRandomAddress(true); const patientOnePincode = "682001"; const patientOneState = "Kerala"; const patientOneDistrict = "Ernakulam"; @@ -115,13 +104,11 @@ describe("Patient Creation with consultation", () => { it("Create a new patient with all field in registration form and no consultation", () => { patientPage.createPatientWithData(newPatientData); - // Verify the patient details patientPage.clickCancelButton(); - patientPage.savePatientUrl(); + // Verify the patient details patientPage.verifyPatientDashboardDetails( patientOneGender, age, - patientOneName, phone_number, phone_number, yearOfBirth, @@ -149,21 +136,15 @@ describe("Patient Creation with consultation", () => { patientPage.verifyPatientNameList(patientOneName); }); - it("Edit the patient details with no consultation and verify", () => { - patientPage.interceptFacilities(); - patientPage.visitUpdatePatientUrl(); - patientPage.verifyStatusCode(); - patientPage.patientformvisibility(); - // change the gender to female and input data to related changed field - cy.wait(3000); + it("Edit the patient details and verify its reflection", () => { + const patientName = "Dummy Patient Two"; + patientPage.visitPatient(patientName); + patientConsultationPage.clickPatientDetails(); + patientPage.clickPatientUpdateDetails(); patientPage.selectPatientGender(patientOneUpdatedGender); patientPage.typePatientDateOfBirth(patientDateOfBirth); - patientPage.clickPatientAntenatalStatusYes(); - patientPage.typeLastMenstruationStartDate(patientMenstruationStartDate); - patientPage.clickPatientPostPartumStatusYes(); - patientPage.typeDateOfDelivery(patientDateOfDelivery); patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); - // Edit the patient consultation , select none medical history and multiple health ID + // select none medical history and add multiple health ID patientMedicalHistory.clickNoneMedicialHistory(); patientInsurance.clickAddInsruanceDetails(); patientInsurance.typePatientInsuranceDetail( @@ -197,20 +178,6 @@ describe("Patient Creation with consultation", () => { ); patientPage.clickUpdatePatient(); patientPage.verifyPatientUpdated(); - patientPage.interceptGetPatient(); - patientPage.visitPatientUrl(); - patientPage.verifyGetPatientResponse(); - // Verify Female Gender change reflection, No Medical History and Insurance Details - patientPage.verifyPatientDashboardDetails( - patientOneUpdatedGender, - age, - patientOneName, - phone_number, - phone_number, - yearOfBirth, - patientOneUpdatedBloodGroup, - patientOccupation, - ); // Verify No medical history patientMedicalHistory.verifyNoSymptosPresent("Diabetes"); // verify insurance details and dedicatd page diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 969023c6dc0..f03fa65ce8b 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -55,7 +55,10 @@ class FacilityPage { phoneNumber: string, clearBeforeTyping: boolean = false, ) { - cy.typeIntoField("#phone_number", phoneNumber, { clearBeforeTyping }); + cy.typeIntoField("#phone_number", phoneNumber, { + clearBeforeTyping, + skipVerification: true, + }); } clickSaveFacilityButton() { diff --git a/cypress/pageobject/Hcx/HcxClaims.ts b/cypress/pageobject/Hcx/HcxClaims.ts index b93862e6d13..883303d1af6 100644 --- a/cypress/pageobject/Hcx/HcxClaims.ts +++ b/cypress/pageobject/Hcx/HcxClaims.ts @@ -3,7 +3,7 @@ export class HcxClaims { cy.get("#select-insurance-policy", { timeout: 10000 }) .should("be.visible") .and("not.be.disabled"); - cy.clickAndSelectOption("#select-insurance-policy", policy); + cy.clickAndSelectOption("#select-insurance-policy", policy, true); } verifyPolicyEligibility() { diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 8ef4554277f..1306432bd03 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -65,7 +65,7 @@ export class PatientConsultationPage { } clickPatientDetails() { - cy.verifyAndClickElement("#consultationpage-header", "Patient Details"); + cy.verifyAndClickElement("#patient-details", "Patient Details"); } typePatientIllnessHistory(history: string) { diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index bdc65c7d431..a74e088eeb8 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -3,7 +3,6 @@ import FacilityPage from "pageobject/Facility/FacilityCreation"; import PatientMedicalHistory from "./PatientMedicalHistory"; -let patient_url = ""; const facilityPage = new FacilityPage(); const patientMedicalHistory = new PatientMedicalHistory(); @@ -96,7 +95,7 @@ export class PatientPage { } typePatientAge(age: string) { - cy.clickAndSelectOption("#patientAge", "Age"); + cy.clickAndSelectOption("#patientAge", "Age", true); cy.clickSubmitButton("Confirm"); cy.get("#age").clear().type(age); } @@ -175,22 +174,6 @@ export class PatientPage { cy.url().should("include", "/patient"); } - savePatientUrl() { - cy.url().then((url) => { - patient_url = url; - }); - } - - visitPatientUrl() { - this.interceptGetPatient(); - cy.awaitUrl(patient_url); - this.verifyGetPatientResponse(); - } - - visitConsultationPage() { - cy.visit(patient_url + "/consultation"); - } - clickUpdatePatient() { cy.intercept("PUT", "**/api/v1/patient/**").as("updatePatient"); cy.get("button").get("[data-testid=submit-button]").click(); @@ -220,7 +203,6 @@ export class PatientPage { verifyPatientDashboardDetails( gender: string, age: number, - patientName: string, phoneNumber: string, emergencyPhoneNumber: string, yearOfBirth: string, @@ -237,7 +219,6 @@ export class PatientPage { .then(($dashboard) => { expect($dashboard).to.contain(gender); expect($dashboard).to.contain(age); - expect($dashboard).to.contain(patientName); expect($dashboard).to.contain(phoneNumber); expect($dashboard).to.contain(emergencyPhoneNumber); expect($dashboard).to.contain(yearOfBirth); @@ -276,10 +257,6 @@ export class PatientPage { }); } - visitUpdatePatientUrl() { - cy.visit(patient_url + "/update"); - } - clickPatientUpdateDetails() { cy.verifyAndClickElement("#update-patient-details", "Edit Profile"); } diff --git a/cypress/pageobject/Patient/PatientLogupdate.ts b/cypress/pageobject/Patient/PatientLogupdate.ts index bbe7c157e15..bcaf6695d96 100644 --- a/cypress/pageobject/Patient/PatientLogupdate.ts +++ b/cypress/pageobject/Patient/PatientLogupdate.ts @@ -20,6 +20,12 @@ class PatientLogupdate { cy.clickAndSelectOption("#rounds_type", roundType); } + verifyRoundType(roundType: string) { + cy.get("#rounds_type", { timeout: 10000 }) + .should("be.visible") + .should("contain.text", roundType); + } + selectBed(bed: string) { cy.typeAndSelectOption("input[name='bed']", bed); cy.intercept("POST", "**/api/v1/consultationbed/").as( @@ -35,13 +41,23 @@ class PatientLogupdate { cy.clickAndSelectOption("#patientCategory", category); } - typePhysicalExamination(examination: string) { - cy.get("#physical_examination_info").click().type(examination); - cy.get("#physical_examination_info").should("contain", examination); + verifyPatientCategory(category: string) { + cy.get("#patientCategory", { timeout: 10000 }) + .should("be.visible") + .should("contain.text", category); + } + + typePhysicalExamination( + examination: string, + clearBeforeTyping: boolean = false, + ) { + cy.typeIntoField("#physical_examination_info", examination, { + clearBeforeTyping, + }); } - typeOtherDetails(details: string) { - cy.get("#other_details").click().type(details); + typeOtherDetails(details: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#other_details", details, { clearBeforeTyping }); } typeAndMultiSelectSymptoms(input: string, symptoms: string[]) { @@ -54,36 +70,36 @@ class PatientLogupdate { cy.get("#add-symptom").click(); } - typeSystolic(systolic: string) { - cy.get("#systolic").click().type(systolic); + typeSystolic(systolic: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#systolic", systolic, { clearBeforeTyping }); } - typeDiastolic(diastolic: string) { - cy.get("#diastolic").click().type(diastolic); + typeDiastolic(diastolic: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#diastolic", diastolic, { clearBeforeTyping }); } - typePulse(pulse: string) { - cy.get("#pulse").click().type(pulse); + typePulse(pulse: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#pulse", pulse, { clearBeforeTyping }); } - typeTemperature(temperature: string) { - cy.get("#temperature").click().type(temperature); + typeTemperature(temperature: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#temperature", temperature, { clearBeforeTyping }); } - typeRespiratory(respiratory: string) { - cy.get("#resp").click().type(respiratory); + typeRespiratory(respiratory: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#resp", respiratory, { clearBeforeTyping }); } - typeSpo2(spo: string) { - cy.get("#ventilator_spo2").click().type(spo); + typeSpo2(spo: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#ventilator_spo2", spo, { clearBeforeTyping }); } selectRhythm(rhythm: string) { cy.clickAndSelectOption("#rhythm", rhythm); } - typeRhythm(rhythm: string) { - cy.get("#rhythm_detail").click().type(rhythm); + typeRhythm(rhythm: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#rhythm_detail", rhythm, { clearBeforeTyping }); } interceptDailyRounds() { @@ -128,10 +144,6 @@ class PatientLogupdate { this.verifyDailyRounds(); } - clearIntoElementById(elementId) { - cy.get(elementId).click().clear(); - } - clickVitals() { cy.get("#consultation_tab_nav").scrollIntoView(); cy.verifyAndClickElement("#consultation_tab_nav", "Vitals"); @@ -141,8 +153,8 @@ class PatientLogupdate { cy.get("#bilateral_air_entry-option-false").click(); } - typeEtco2(etco2: string) { - cy.get("#etco2-range-input").type(etco2); + typeEtco2(etco2: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#etco2-range-input", etco2, { clearBeforeTyping }); } selectOxygenSupport() { @@ -153,36 +165,48 @@ class PatientLogupdate { cy.get("#ventilator_oxygen_modality-option-NON_REBREATHING_MASK").click(); } - typeOxygenFlowRate(flowRate: string) { - cy.get("#oxygen_flow_rate-range-input").type(flowRate); + typeOxygenFlowRate(flowRate: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#oxygen_flow_rate-range-input", flowRate, { + clearBeforeTyping, + }); } - typeVentilatorSpo2(spo2: string) { - cy.get("#ventilator_spo2-range-input").type(spo2); + typeVentilatorSpo2(spo2: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#ventilator_spo2-range-input", spo2, { + clearBeforeTyping, + }); } selectCriticalCareSection(sectionName: string) { cy.contains("button", sectionName).click(); } - typeBloodSugar(bloodSugar: string) { - cy.get("#blood_sugar_level-range-input").type(bloodSugar); + typeBloodSugar(bloodSugar: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#blood_sugar_level-range-input", bloodSugar, { + clearBeforeTyping, + }); } - typeInsulinDosage(insulinDosage: string) { - cy.get("#insulin_intake_dose-range-input").type(insulinDosage); + typeInsulinDosage(insulinDosage: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#insulin_intake_dose-range-input", insulinDosage, { + clearBeforeTyping, + }); } clickGoBackConsultation() { cy.get("#back-to-consultation").click(); } - typeFluidBalance(fluid: string) { - cy.get("#dialysis_fluid_balance-range-input").type(fluid); + typeFluidBalance(fluid: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#dialysis_fluid_balance-range-input", fluid, { + clearBeforeTyping, + }); } - typeNetBalance(netBalance: string) { - cy.get("#dialysis_net_balance-range-input").type(netBalance); + typeNetBalance(netBalance: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#dialysis_net_balance-range-input", netBalance, { + clearBeforeTyping, + }); } } export default PatientLogupdate; diff --git a/cypress/pageobject/utils/advanceFilterHelpers.ts b/cypress/pageobject/utils/advanceFilterHelpers.ts index 613f4af2f23..14e3ab41bda 100644 --- a/cypress/pageobject/utils/advanceFilterHelpers.ts +++ b/cypress/pageobject/utils/advanceFilterHelpers.ts @@ -4,22 +4,22 @@ export const advanceFilters = { }, selectState(state: string) { - cy.wait(200); + cy.wait(1000); cy.clickAndSelectOption("#state", state); }, selectDistrict(district: string) { - cy.wait(200); + cy.wait(1000); cy.clickAndSelectOption("#district", district); }, selectLocalBody(localBody: string) { - cy.wait(200); + cy.wait(1000); cy.clickAndSelectOption("#local_body", localBody); }, selectWard(ward: string) { - cy.wait(200); + cy.wait(1000); cy.clickAndSelectOption("#ward", ward); }, diff --git a/cypress/pageobject/utils/constants.ts b/cypress/pageobject/utils/constants.ts index 90baf3b6d4b..e14e3720231 100644 --- a/cypress/pageobject/utils/constants.ts +++ b/cypress/pageobject/utils/constants.ts @@ -1,7 +1,17 @@ -function generatePhoneNumber(): string { +function unbiasedRandom(max: number): number { const array = new Uint32Array(1); - window.crypto.getRandomValues(array); - const randomNum = (array[0] % 900000000) + 100000000; + let randomValue; + + do { + window.crypto.getRandomValues(array); + randomValue = array[0]; + } while (randomValue > Math.floor(0xffffffff / max) * max); + + return randomValue % max; +} + +function generatePhoneNumber(): string { + const randomNum = unbiasedRandom(900000000) + 100000000; // Ensure 9-digit range return "9" + randomNum.toString(); } @@ -31,9 +41,9 @@ function generateFacilityName(): string { "Ernakulam", ]; const identifiers = [ - () => Math.floor(Math.random() * 100), // Numeric IDs - () => `Zone-${Math.floor(Math.random() * 10)}`, // Zone IDs - () => `Block-${String.fromCharCode(65 + Math.floor(Math.random() * 26))}`, // Alphabetic Blocks + () => unbiasedRandom(100), // Numeric IDs + () => `Zone-${unbiasedRandom(10)}`, // Zone IDs + () => `Block-${String.fromCharCode(65 + unbiasedRandom(26))}`, // Alphabetic Blocks ]; const suffixes = [ "Meta", @@ -46,21 +56,18 @@ function generateFacilityName(): string { "Hospital", ]; - const randomPrefix = prefixes[Math.floor(Math.random() * prefixes.length)]; - const randomLocation = - locations[Math.floor(Math.random() * locations.length)]; - const randomIdentifier = - identifiers[Math.floor(Math.random() * identifiers.length)](); - const randomSuffix = suffixes[Math.floor(Math.random() * suffixes.length)]; + const randomPrefix = prefixes[unbiasedRandom(prefixes.length)]; + const randomLocation = locations[unbiasedRandom(locations.length)]; + const randomIdentifier = identifiers[unbiasedRandom(identifiers.length)](); + const randomSuffix = suffixes[unbiasedRandom(suffixes.length)]; - // Randomize the format of the name const formats = [ `${randomPrefix} ${randomLocation}-${randomIdentifier} ${randomSuffix}`, `${randomLocation} ${randomPrefix} ${randomSuffix}`, `${randomPrefix} ${randomLocation} ${randomSuffix}`, ]; - return formats[Math.floor(Math.random() * formats.length)]; + return formats[unbiasedRandom(formats.length)]; } function generateRandomAddress(multiline: boolean = false): string { @@ -89,17 +96,14 @@ function generateRandomAddress(multiline: boolean = false): string { ]; const districts = ["Kochi", "Ernakulam"]; const states = ["Kerala"]; - const pincode = Math.floor(682000 + Math.random() * 1000).toString(); // Generate random pincodes in the 682XXX range. + const pincode = (682000 + unbiasedRandom(1000)).toString(); - const randomLocality = - localities[Math.floor(Math.random() * localities.length)]; + const randomLocality = localities[unbiasedRandom(localities.length)]; const randomNeighborhood = - neighborhoods[Math.floor(Math.random() * neighborhoods.length)]; - const randomDistrict = - districts[Math.floor(Math.random() * districts.length)]; - const randomState = states[Math.floor(Math.random() * states.length)]; + neighborhoods[unbiasedRandom(neighborhoods.length)]; + const randomDistrict = districts[unbiasedRandom(districts.length)]; + const randomState = states[unbiasedRandom(states.length)]; - // Create address components const addressParts = [ randomNeighborhood, randomLocality, @@ -108,15 +112,65 @@ function generateRandomAddress(multiline: boolean = false): string { `Pincode: ${pincode}`, ]; - // Return address as single line or multiline - // If 'multiline' is false, return address as a single line - // If 'multiline' is true, return address with each component on a new line return multiline ? addressParts.join("\n") : addressParts.join(", "); } +function generatePatientName(): string { + const firstNames = [ + "John", + "Jane", + "Michael", + "Sarah", + "David", + "Emma", + "James", + "Olivia", + "Robert", + "Sophia", + "William", + "Isabella", + "Benjamin", + "Mia", + "Daniel", + "Charlotte", + "Lucas", + "Amelia", + "Ethan", + "Harper", + ]; + const lastNames = [ + "Smith", + "Johnson", + "Williams", + "Brown", + "Jones", + "Miller", + "Davis", + "Garcia", + "Rodriguez", + "Wilson", + "Martinez", + "Hernandez", + "Lopez", + "Gonzalez", + "Perez", + "Taylor", + "Anderson", + "Thomas", + "Jackson", + "White", + ]; + + const randomFirstName = firstNames[unbiasedRandom(firstNames.length)]; + const randomLastName = lastNames[unbiasedRandom(lastNames.length)]; + + return `${randomFirstName} ${randomLastName}`; +} + export { generatePhoneNumber, generateEmergencyPhoneNumber, generateFacilityName, generateRandomAddress, + generatePatientName, }; diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index f5bbcf42290..54bc3be2666 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -133,12 +133,12 @@ Cypress.Commands.add("clickCancelButton", (buttonText = "Cancel") => { Cypress.Commands.add( "typeAndSelectOption", - (element: string, referance: string) => { + (element: string, reference: string) => { cy.get(element) .click() - .type(referance) + .type(reference) .then(() => { - cy.get("[role='option']").contains(referance).click(); + cy.get("[role='option']").contains(reference).click(); }); }, ); @@ -175,11 +175,17 @@ Cypress.Commands.add( Cypress.Commands.add( "clickAndSelectOption", - (element: string, reference: string) => { + (element: string, reference: string, skipVerification: boolean = false) => { cy.get(element) .click() .then(() => { cy.get("[role='option']").contains(reference).click(); + }) + .then(() => { + // Skip verification if skipVerification is true + if (!skipVerification) { + cy.get(element).should("contain", reference); + } }); }, ); @@ -247,15 +253,20 @@ Cypress.Commands.add( ( selector: string, value: string, - options: { clearBeforeTyping?: boolean } = {}, + options: { clearBeforeTyping?: boolean; skipVerification?: boolean } = {}, ) => { - const { clearBeforeTyping = false } = options; + const { clearBeforeTyping = false, skipVerification = false } = options; const inputField = cy.get(selector); if (clearBeforeTyping) { - inputField.clear(); // Clear the input field + inputField.clear(); // Clear the input field if specified } - inputField.click().type(value); // Click and type the new value + inputField.scrollIntoView().should("be.visible").click().type(value); + + // Conditionally skip verification based on the skipVerification flag + if (!skipVerification) { + inputField.should("have.value", value); // Verify the value if skipVerification is false + } }, ); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index fa01326698c..59620bf8a6d 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -34,6 +34,7 @@ declare global { clickAndSelectOption( element: string, reference: string, + skipVerification?: boolean, ): Chainable; verifyAndClickElement( element: string, @@ -49,7 +50,7 @@ declare global { typeIntoField( selector: string, value: string, - options?: { clearBeforeTyping?: boolean }, + options?: { clearBeforeTyping?: boolean; skipVerification?: boolean }, ): Chainable; } }