Skip to content

Commit

Permalink
fix cypress fails
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed Feb 18, 2024
1 parent 441481c commit c01435a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 28 deletions.
62 changes: 39 additions & 23 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -213,21 +226,24 @@ describe("Patient Creation with consultation", () => {
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
patientOneFirstInsurerId,
patientOneFirstInsurerName
patientOneFirstInsurerName,
enable_hcx
);
patientInsurance.clickPatientInsuranceViewDetail();
cy.wait(3000);
patientInsurance.verifyPatientPolicyDetails(
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
patientOneFirstInsurerId,
patientOneFirstInsurerName
patientOneFirstInsurerName,
enable_hcx
);
patientInsurance.verifyPatientPolicyDetails(
patientOneSecondSubscriberId,
patientOneSecondPolicyId,
patientOneSecondInsurerId,
patientOneSecondInsurerName
patientOneSecondInsurerName,
enable_hcx
);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
23 changes: 20 additions & 3 deletions cypress/pageobject/Patient/PatientInsurance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HCX/InsuranceDetailsBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const InsuranceDetailEditCard = ({
{enable_hcx ? (
<InsurerAutocomplete
required
name="insurer_"
name="insurer"
label="Insurer"
placeholder="Eg. GICOFINDIA"
value={seletedInsurer}
Expand Down

0 comments on commit c01435a

Please sign in to comment.