From fe82a57ee16602705e7d00886250e4a5d80ef4af Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 12 Nov 2024 05:47:19 +0530 Subject: [PATCH] New Cypress Test for HCX Workflow in the platform (#9007) Co-authored-by: Khavin Shankar --- .github/workflows/cypress.yaml | 2 + cypress/e2e/hcx_spec/HcxClaims.cy.ts | 97 +++++++++++++++++++ .../e2e/patient_spec/PatientHomepage.cy.ts | 1 - .../patient_spec/PatientRegistration.cy.ts | 49 ++-------- cypress/pageobject/Hcx/HcxClaims.ts | 9 ++ .../pageobject/Patient/PatientConsultation.ts | 19 ++++ cypress/pageobject/Patient/PatientCreation.ts | 4 + .../pageobject/Patient/PatientInsurance.ts | 37 +------ src/components/Facility/ConsultationCard.tsx | 2 +- src/components/HCX/PolicyEligibilityCheck.tsx | 2 + src/components/Patient/PatientHome.tsx | 1 + 11 files changed, 150 insertions(+), 73 deletions(-) create mode 100644 cypress/e2e/hcx_spec/HcxClaims.cy.ts create mode 100644 cypress/pageobject/Hcx/HcxClaims.ts diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 1104d7f480d..ecd06f922c0 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -18,6 +18,8 @@ jobs: containers: [1, 2, 3, 4] env: REACT_CARE_API_URL: http://localhost:9000 + REACT_ENABLED_APPS: "ohcnetwork/care_hcx_fe@main" + REACT_ENABLE_HCX: true steps: - name: Checkout 📥 uses: actions/checkout@v3 diff --git a/cypress/e2e/hcx_spec/HcxClaims.cy.ts b/cypress/e2e/hcx_spec/HcxClaims.cy.ts new file mode 100644 index 00000000000..2c4a6b45df9 --- /dev/null +++ b/cypress/e2e/hcx_spec/HcxClaims.cy.ts @@ -0,0 +1,97 @@ +import { HcxClaims } from "pageobject/Hcx/HcxClaims"; +import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation"; +import PatientInsurance from "pageobject/Patient/PatientInsurance"; + +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; + +describe("HCX Claims configuration and approval workflow", () => { + const loginPage = new LoginPage(); + const patientPage = new PatientPage(); + const patientConsultationPage = new PatientConsultationPage(); + const patientInsurance = new PatientInsurance(); + const hcxClaims = new HcxClaims(); + const hcxPatientName = "Dummy Patient 14"; + const firstInsuranceIdentifier = "insurance-details-0"; + const patientMemberId = "001"; + const patientPolicyId = "100"; + const patientInsurerName = "Demo Payor"; + + before(() => { + loginPage.loginAsDistrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Verify the HCX Workflow for a patient with mocked eligibility", () => { + // Modify the insurance for a facility + patientPage.visitPatient(hcxPatientName); + patientConsultationPage.clickPatientDetails(); + patientPage.clickPatientUpdateDetails(); + patientInsurance.clickAddInsruanceDetails(); + patientInsurance.typePatientInsuranceDetail( + firstInsuranceIdentifier, + "subscriber_id", + patientMemberId, + ); + patientInsurance.typePatientInsuranceDetail( + firstInsuranceIdentifier, + "policy_id", + patientPolicyId, + ); + patientInsurance.selectPatientInsurerName( + firstInsuranceIdentifier, + patientInsurerName, + ); + cy.submitButton("Save Details"); + cy.verifyNotification("Patient updated successfully"); + cy.closeNotification(); + // Navigate to Consultation View and capture dynamic consultation ID + let consultationId: string; + patientConsultationPage.clickViewConsultationButton(); + cy.url().then((url) => { + const urlRegex = + /facility\/([^/]+)\/patient\/([^/]+)\/consultation\/([^/]+)/; + const match = url.match(urlRegex); + if (match) { + consultationId = match[3]; + } + }); + // Intercept and mock the eligibility check response using captured consultationId + cy.intercept("POST", "/api/hcx/check_eligibility", (req) => { + req.reply({ + statusCode: 200, + body: { + api_call_id: "bfa228f0-cdfa-4426-bebe-26e996079dbb", + correlation_id: "86ae030c-1b33-4e52-a6f1-7a74a48111eb", + timestamp: Date.now(), + consultation: consultationId, + policy: patientPolicyId, + outcome: "Complete", + limit: 1, + }, + }); + }).as("checkEligibility"); + // Raise a HCX Pre-auth + patientConsultationPage.clickManagePatientButton(); + patientConsultationPage.clickClaimsButton(); + hcxClaims.selectEligiblePolicy(patientInsurerName); + hcxClaims.verifyPolicyEligibility(); + cy.verifyNotification("Checking Policy Eligibility"); + cy.closeNotification(); + // Confirm that the eligibility check displays as successful + cy.wait("@checkEligibility").then((interception) => { + const response = interception.response.body; + expect(response.outcome).to.equal("Complete"); + }); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index 53fb8732712..d2dbb2a3619 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -127,7 +127,6 @@ describe("Patient Homepage present functionalities", () => { patientHome.selectPatientMedicoFilter(patientMedicoStatus); patientHome.clickPatientFilterApply(); cy.get("a[data-cy='patient']").should("contain.text", "Dummy Patient"); - patientHome.verifyTotalPatientCount("1"); // Verify the presence of badges patientHome.verifyGenderBadgeContent(patientGender); patientHome.verifyCategoryBadgeContent(patientCategory); diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index cb84fa06674..91810ffd273 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -7,7 +7,6 @@ import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; import { generatePhoneNumber } from "../../pageobject/utils/constants"; const yearOfBirth = "2001"; -const isHCXEnabled = Cypress.env("ENABLE_HCX"); const calculateAge = () => { const currentYear = new Date().getFullYear(); @@ -58,13 +57,11 @@ describe("Patient Creation with consultation", () => { const patientOneFirstInsuranceId = "insurance-details-0"; const patientOneFirstSubscriberId = "member id 01"; const patientOneFirstPolicyId = "policy name 01"; - const patientOneFirstInsurerId = "insurer id 01"; - const patientOneFirstInsurerName = "insurer name 01"; + const patientOneFirstInsurerName = "Demo Payor"; const patientOneSecondInsuranceId = "insurance-details-1"; const patientOneSecondSubscriberId = "member id 02"; const patientOneSecondPolicyId = "policy name 02"; - const patientOneSecondInsurerId = "insurer id 02"; - const patientOneSecondInsurerName = "insurer name 02"; + const patientOneSecondInsurerName = "Care Payor"; const patientTransferPhoneNumber = "9849511866"; const patientTransferFacility = "Dummy Shifting Center"; const patientTransferName = "Dummy Patient 10"; @@ -178,21 +175,10 @@ describe("Patient Creation with consultation", () => { "policy_id", patientOneFirstPolicyId, ); - if (isHCXEnabled) { - patientInsurance.selectInsurer("test"); - } else { - patientInsurance.typePatientInsuranceDetail( - patientOneFirstInsuranceId, - "insurer_id", - patientOneFirstInsurerId, - ); - patientInsurance.typePatientInsuranceDetail( - patientOneFirstInsuranceId, - "insurer_name", - patientOneFirstInsurerName, - ); - } - + patientInsurance.selectPatientInsurerName( + patientOneFirstInsuranceId, + patientOneFirstInsurerName, + ); patientInsurance.clickAddInsruanceDetails(); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, @@ -204,21 +190,10 @@ describe("Patient Creation with consultation", () => { "policy_id", patientOneSecondPolicyId, ); - if (isHCXEnabled) { - patientInsurance.selectInsurer("Care"); - } else { - patientInsurance.typePatientInsuranceDetail( - patientOneSecondInsuranceId, - "insurer_id", - patientOneSecondInsurerId, - ); - patientInsurance.typePatientInsuranceDetail( - patientOneSecondInsuranceId, - "insurer_name", - patientOneSecondInsurerName, - ); - } - + patientInsurance.selectPatientInsurerName( + patientOneSecondInsuranceId, + patientOneSecondInsurerName, + ); patientPage.clickUpdatePatient(); cy.wait(3000); patientPage.verifyPatientUpdated(); @@ -247,16 +222,12 @@ describe("Patient Creation with consultation", () => { patientInsurance.verifyPatientPolicyDetails( patientOneFirstSubscriberId, patientOneFirstPolicyId, - patientOneFirstInsurerId, patientOneFirstInsurerName, - isHCXEnabled, ); patientInsurance.verifyPatientPolicyDetails( patientOneSecondSubscriberId, patientOneSecondPolicyId, - patientOneSecondInsurerId, patientOneSecondInsurerName, - isHCXEnabled, ); }); diff --git a/cypress/pageobject/Hcx/HcxClaims.ts b/cypress/pageobject/Hcx/HcxClaims.ts new file mode 100644 index 00000000000..9a915a05196 --- /dev/null +++ b/cypress/pageobject/Hcx/HcxClaims.ts @@ -0,0 +1,9 @@ +export class HcxClaims { + selectEligiblePolicy(policy: string) { + cy.clickAndSelectOption("#select-insurance-policy", policy); + } + + verifyPolicyEligibility() { + cy.verifyAndClickElement("#check-eligibility", "Check Eligibility"); + } +} diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index e0b51b9265e..6f4f994b395 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -13,6 +13,7 @@ export class PatientConsultationPage { selectSymptomsDate(date: string) { cy.clickAndTypeDate("#symptoms_onset_date", date); } + clickAddSymptom() { cy.get("#add-symptom").click(); } @@ -111,4 +112,22 @@ export class PatientConsultationPage { ); cy.wait(3000); } + + clickViewConsultationButton() { + cy.verifyAndClickElement( + "#view_consultation_updates", + "View Consultation / Consultation Updates", + ); + } + + clickManagePatientButton() { + cy.verifyAndClickElement("#show-more", "Manage Patient"); + } + + clickClaimsButton() { + cy.get("#log-update").scrollIntoView(); + cy.intercept(/\/api\/hcx\/policy\/\?.*/).as("policyStatus"); + cy.get("#consultation-buttons").contains("Claims").click(); + cy.wait("@policyStatus").its("response.statusCode").should("eq", 200); + } } diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 41b3c02977d..8f46dec5560 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -220,6 +220,10 @@ export class PatientPage { cy.visit(patient_url + "/update"); } + clickPatientUpdateDetails() { + cy.verifyAndClickElement("#update-patient-details", "Update Details"); + } + interceptFacilities() { cy.intercept("GET", "**/facility/*/patient/**").as("getFacilities"); } diff --git a/cypress/pageobject/Patient/PatientInsurance.ts b/cypress/pageobject/Patient/PatientInsurance.ts index 1b91d27b629..79d6e3b7510 100644 --- a/cypress/pageobject/Patient/PatientInsurance.ts +++ b/cypress/pageobject/Patient/PatientInsurance.ts @@ -9,32 +9,10 @@ class PatientInsurance { }); } - selectInsurer(insurer: string) { - cy.intercept("GET", "**/api/v1/hcx/payors/**", { - statusCode: 200, - body: [ - { - name: "test payor 2", - code: "testpayor2.swasthmock@swasth-hcx-staging", - }, - { - name: "Care Payor", - code: "khavinshankar.gmail@swasth-hcx-staging", - }, - { - name: "Alliance", - code: "hcxdemo.yopmail@swasth-hcx-staging", - }, - ], - }).as("getInsurer"); - cy.get("[name='insurer']") - .last() - .click() - .type(insurer) - .then(() => { - cy.wait("@getInsurer"); - cy.get("[role='option']").contains(insurer).click(); - }); + selectPatientInsurerName(containerId: string, value: string) { + cy.get(`#${containerId}`).within(() => { + cy.typeAndSelectOption("#insurer", value); + }); } clickPatientInsuranceViewDetail() { @@ -49,18 +27,13 @@ class PatientInsurance { verifyPatientPolicyDetails( subscriberId: string, policyId: string, - insurerId: string, insurerName: string, - isHcxEnabled: string, ) { cy.get("[data-testid=patient-details]").then(($dashboard) => { cy.url().should("include", "/facility/"); expect($dashboard).to.contain(subscriberId); expect($dashboard).to.contain(policyId); - if (!isHcxEnabled) { - expect($dashboard).to.contain(insurerId); - expect($dashboard).to.contain(insurerName); - } + expect($dashboard).to.contain(insurerName); }); } } diff --git a/src/components/Facility/ConsultationCard.tsx b/src/components/Facility/ConsultationCard.tsx index 11fce3fbe28..213f306d730 100644 --- a/src/components/Facility/ConsultationCard.tsx +++ b/src/components/Facility/ConsultationCard.tsx @@ -169,7 +169,7 @@ export const ConsultationCard = (props: ConsultationProps) => {
navigate( diff --git a/src/components/HCX/PolicyEligibilityCheck.tsx b/src/components/HCX/PolicyEligibilityCheck.tsx index 48c63f3ca74..4515819fc26 100644 --- a/src/components/HCX/PolicyEligibilityCheck.tsx +++ b/src/components/HCX/PolicyEligibilityCheck.tsx @@ -71,6 +71,7 @@ export default function HCXPolicyEligibilityCheck({
{ )}