Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Cypress Test | Edit and Discontinue Medicine Workflow | Prescription Module #8068

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading