Skip to content

Commit

Permalink
added test for edit and discontinue medicines
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Jun 20, 2024
1 parent 5a77383 commit b7243b4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ describe("Patient Medicine Administration", () => {
cy.awaitUrl("/patients");
});

it("Add a new medicine | Verify the Edit and Discontinue Medicine workflow |", () => {
patientPage.visitPatient("Dummy Patient 9");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
// Add a normal Medicine to the patient
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// Edit the existing medicine & Verify they are properly moved to discontinue position
patientPrescription.clickReturnToDashboard();
patientPrescription.visitMedicineTab();
cy.verifyAndClickElement("#0", medicineNameOne);
cy.verifyContentPresence("#submit", ["Discontinue"]); // To verify the pop-up is open
cy.submitButton("Edit");
patientPrescription.enterDosage(medicineTargetDosage);
cy.submitButton("Submit");
cy.verifyNotification("Prescription edited successfully");
cy.closeNotification();
// Discontinue a medicine & Verify the notification
cy.verifyAndClickElement("#0", medicineNameOne);
cy.submitButton("Discontinue");
patientPrescription.enterDiscontinueReason("Medicine is been discontinued");
cy.submitButton("Discontinue");
cy.verifyNotification("Prescription discontinued");
cy.closeNotification();
// verify the discontinue medicine view
cy.verifyContentPresence("#discontinued-medicine", [
"discontinued prescription(s)",
]);
});

it("Add a PRN Prescription medicine | Group Administrate it |", () => {
patientPage.visitPatient("Dummy Patient 6");
patientPrescription.visitMedicineTab();
Expand Down
7 changes: 7 additions & 0 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ export class PatientPrescription {
}

enterDosage(doseAmount: string) {
cy.get("#base_dosage").clear({ force: true });
cy.get("#base_dosage").click({ force: true });
cy.get("#base_dosage").type(doseAmount, { force: true });
}

enterIndicator(indicator: string) {
cy.get("#indicator").type(indicator);
}

enterDiscontinueReason(reason: string) {
cy.wait(2000);
cy.get("#discontinuedReason").type(reason);
}

enterAdministerDosage(dosage: string) {
cy.get("#dosage").type(dosage);
}
Expand Down
1 change: 1 addition & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Cypress.Commands.add("clearAllFilters", () => {
});

Cypress.Commands.add("submitButton", (buttonText = "Submit") => {
cy.get("button[type='submit']").contains(buttonText).scrollIntoView();
cy.get("button[type='submit']").contains(buttonText).click();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => {
</ScrollOverlay>
{!!discontinuedCount && (
<ButtonV2
id="discontinued-medicine"
variant="secondary"
className="group sticky left-0 w-full rounded-b-lg rounded-t-none bg-gray-100"
disabled={loading || discontinuedPrescriptions.loading}
Expand Down

0 comments on commit b7243b4

Please sign in to comment.