From c01435a2de19fe36cf70cb229b654879f634c2fe Mon Sep 17 00:00:00 2001 From: khavinshankar Date: Sun, 18 Feb 2024 12:43:10 +0530 Subject: [PATCH] fix cypress fails --- .../patient_spec/patient_registration.cy.ts | 62 ++++++++++++------- .../pageobject/Patient/PatientConsultation.ts | 2 +- .../pageobject/Patient/PatientInsurance.ts | 23 ++++++- .../HCX/InsuranceDetailsBuilder.tsx | 2 +- 4 files changed, 61 insertions(+), 28 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 1dce2c7c6f7..6b6b59ed5fb 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -10,6 +10,7 @@ import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; import PatientExternal from "../../pageobject/Patient/PatientExternal"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; +import { enable_hcx } from "../../../public/config.json"; const yearOfBirth = "2001"; @@ -156,16 +157,22 @@ describe("Patient Creation with consultation", () => { "policy_id", patientOneFirstPolicyId ); - patientInsurance.typePatientInsuranceDetail( - patientOneFirstInsuranceId, - "insurer_id", - patientOneFirstInsurerId - ); - patientInsurance.typePatientInsuranceDetail( - patientOneFirstInsuranceId, - "insurer_name", - patientOneFirstInsurerName - ); + + if (enable_hcx) { + patientInsurance.selectInsurer(); + } else { + patientInsurance.typePatientInsuranceDetail( + patientOneFirstInsuranceId, + "insurer_id", + patientOneFirstInsurerId + ); + patientInsurance.typePatientInsuranceDetail( + patientOneFirstInsuranceId, + "insurer_name", + patientOneFirstInsurerName + ); + } + patientInsurance.clickAddInsruanceDetails(); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, @@ -177,16 +184,22 @@ describe("Patient Creation with consultation", () => { "policy_id", patientOneSecondPolicyId ); - patientInsurance.typePatientInsuranceDetail( - patientOneSecondInsuranceId, - "insurer_id", - patientOneSecondInsurerId - ); - patientInsurance.typePatientInsuranceDetail( - patientOneSecondInsuranceId, - "insurer_name", - patientOneSecondInsurerName - ); + + if (enable_hcx) { + patientInsurance.selectInsurer(); + } else { + patientInsurance.typePatientInsuranceDetail( + patientOneSecondInsuranceId, + "insurer_id", + patientOneSecondInsurerId + ); + patientInsurance.typePatientInsuranceDetail( + patientOneSecondInsuranceId, + "insurer_name", + patientOneSecondInsurerName + ); + } + patientPage.clickUpdatePatient(); cy.wait(3000); patientPage.verifyPatientUpdated(); @@ -213,7 +226,8 @@ describe("Patient Creation with consultation", () => { patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, - patientOneFirstInsurerName + patientOneFirstInsurerName, + enable_hcx ); patientInsurance.clickPatientInsuranceViewDetail(); cy.wait(3000); @@ -221,13 +235,15 @@ describe("Patient Creation with consultation", () => { patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, - patientOneFirstInsurerName + patientOneFirstInsurerName, + enable_hcx ); patientInsurance.verifyPatientPolicyDetails( patientOneSecondSubscriberId, patientOneSecondPolicyId, patientOneSecondInsurerId, - patientOneSecondInsurerName + patientOneSecondInsurerName, + enable_hcx ); }); diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index bc2e8f330a3..3b74acca570 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -244,7 +244,7 @@ export class PatientConsultationPage { cy.intercept("POST", "**/api/v1/consultation/*/discharge_patient/").as( "dischargePatient" ); - cy.get("#submit").contains("Confirm Discharge").click(); + cy.get("#submit > span").contains("Confirm Discharge").click(); cy.wait("@dischargePatient").its("response.statusCode").should("eq", 200); } diff --git a/cypress/pageobject/Patient/PatientInsurance.ts b/cypress/pageobject/Patient/PatientInsurance.ts index be4c25c5535..9b562b11ac3 100644 --- a/cypress/pageobject/Patient/PatientInsurance.ts +++ b/cypress/pageobject/Patient/PatientInsurance.ts @@ -9,6 +9,15 @@ class PatientInsurance { }); } + selectInsurer(insurer = "") { + cy.get("#insurer") + .click() + .type(insurer) + .then(() => { + cy.get("[role='option']").first().click(); + }); + } + clickPatientInsuranceViewDetail() { cy.get("#insurance-view-details").scrollIntoView(); cy.get("#insurance-view-details").click(); @@ -18,13 +27,21 @@ class PatientInsurance { cy.get("[data-testid=add-insurance-button]").click(); } - verifyPatientPolicyDetails(subscriberId, policyId, insurerId, insurerName) { + verifyPatientPolicyDetails( + subscriberId, + policyId, + insurerId, + insurerName, + hcx_enabled + ) { cy.get("[data-testid=patient-details]").then(($dashboard) => { cy.url().should("include", "/facility/"); expect($dashboard).to.contain(subscriberId); expect($dashboard).to.contain(policyId); - expect($dashboard).to.contain(insurerId); - expect($dashboard).to.contain(insurerName); + if (hcx_enabled) { + expect($dashboard).to.contain(insurerId); + expect($dashboard).to.contain(insurerName); + } }); } } diff --git a/src/Components/HCX/InsuranceDetailsBuilder.tsx b/src/Components/HCX/InsuranceDetailsBuilder.tsx index 36713e317a2..fd5d253d76b 100644 --- a/src/Components/HCX/InsuranceDetailsBuilder.tsx +++ b/src/Components/HCX/InsuranceDetailsBuilder.tsx @@ -136,7 +136,7 @@ const InsuranceDetailEditCard = ({ {enable_hcx ? (