-
Notifications
You must be signed in to change notification settings - Fork 649
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
Cypress: Patient Prescription Management #10740
base: develop
Are you sure you want to change the base?
Changes from 1 commit
abf92d1
d49281f
e90695b
4434e2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,49 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { PatientEncounter } from "@/pageObject/Patients/PatientEncounter"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { FacilityCreation } from "@/pageObject/facility/FacilityCreation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const facilityCreation = new FacilityCreation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const patientEncounter = new PatientEncounter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
describe("Patient Prescription Management", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.loginByApi("devnurse"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cy.visit("/"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it("should add a new medicine for the patient", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
facilityCreation.selectFacility("GHC payyanur"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const medicineName = "Senna 15 mg oral tablet"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dosage = 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const frequency = "BID (1-0-1)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const instructions = "Until symptoms improve"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const route = "Sublabial route"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const site = "Structure of left deltoid muscle"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const method = "Bathe"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const notes = "testing notes"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
patientEncounter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.navigateToEncounters() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.openFirstEncounterDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.clickMedicinesTab() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.clickEditPrescription() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.addMedication( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
medicineName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dosage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
frequency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
instructions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
route, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
site, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
notes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it("should delete prescription", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
facilityCreation.selectFacility("GHC payyanur"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
patientEncounter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.navigateToEncounters() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.openFirstEncounterDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.clickMedicinesTab() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.clickEditPrescription() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.removeMedication(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
once the medicine is removed, verify that the changes in the relevant module is verified |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for medication removal. The deletion test should verify that the medication was actually removed. it("should delete prescription", () => {
facilityCreation.selectFacility("GHC payyanur");
+ const medicineName = "Senna 15 mg oral tablet";
+
+ // First add a medication to ensure we have something to delete
+ patientEncounter
+ .navigateToEncounters()
+ .openFirstEncounterDetails()
+ .clickMedicinesTab()
+ .clickEditPrescription()
+ .addMedication(medicineName, 6, "BID (1-0-1)", "", "", "", "", "");
patientEncounter
.navigateToEncounters()
.openFirstEncounterDetails()
.clickMedicinesTab()
.clickEditPrescription()
- .removeMedication();
+ .removeMedication()
+ .verifyMedicationRemoved(medicineName);
}); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add more test scenarios for comprehensive coverage. The test suite should include additional scenarios:
it("should edit an existing medication", () => {
// Add test for editing medication
});
it("should validate required fields", () => {
// Add test for field validation
});
it("should handle invalid inputs gracefully", () => {
// Add test for error scenarios
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,7 +12,56 @@ export class PatientEncounter { | |||||||||||||||||||||||||||||||
.click(); | ||||||||||||||||||||||||||||||||
return this; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
clickMedicinesTab() { | ||||||||||||||||||||||||||||||||
cy.verifyAndClickElement('[data-cy="tab-medicines"]', "Medicines"); | ||||||||||||||||||||||||||||||||
return this; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
clickEditPrescription() { | ||||||||||||||||||||||||||||||||
cy.verifyAndClickElement('[data-cy="edit-prescription"]', "Edit"); | ||||||||||||||||||||||||||||||||
return this; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
addMedication( | ||||||||||||||||||||||||||||||||
medicineName, | ||||||||||||||||||||||||||||||||
dosage, | ||||||||||||||||||||||||||||||||
frequency, | ||||||||||||||||||||||||||||||||
instructions, | ||||||||||||||||||||||||||||||||
route, | ||||||||||||||||||||||||||||||||
site, | ||||||||||||||||||||||||||||||||
method, | ||||||||||||||||||||||||||||||||
notes, | ||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||
cy.get('[data-cy="question-medication-request"]').click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="listbox"]') | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
check already existing command function to interact with dropdown, replace every usage with command function |
||||||||||||||||||||||||||||||||
.find('[role="option"]') | ||||||||||||||||||||||||||||||||
.contains(medicineName) | ||||||||||||||||||||||||||||||||
.click(); | ||||||||||||||||||||||||||||||||
cy.get('input[inputmode="numeric"]').should("exist").type(dosage); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||
cy.get('[data-cy="frequency"]').click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="option"]').contains(frequency).click(); | ||||||||||||||||||||||||||||||||
cy.contains("Select additional instructions").click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="listbox"]') | ||||||||||||||||||||||||||||||||
.find('[role="option"]') | ||||||||||||||||||||||||||||||||
.contains(instructions) | ||||||||||||||||||||||||||||||||
.click(); | ||||||||||||||||||||||||||||||||
cy.contains("Select route").click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="listbox"]').find('[role="option"]').contains(route).click(); | ||||||||||||||||||||||||||||||||
cy.contains("Select site").click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="listbox"]').find('[role="option"]').contains(site).click(); | ||||||||||||||||||||||||||||||||
cy.contains("Select method").click(); | ||||||||||||||||||||||||||||||||
cy.get('[role="listbox"]').get('[role="option"]').contains(method).click(); | ||||||||||||||||||||||||||||||||
cy.get('[data-cy="notes"]').click(); | ||||||||||||||||||||||||||||||||
cy.get('[data-cy="notes-textarea"]').type(notes); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
this.clickSubmitQuestionnaire(); | ||||||||||||||||||||||||||||||||
this.verifyQuestionnaireSubmission(); | ||||||||||||||||||||||||||||||||
return this; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
removeMedication() { | ||||||||||||||||||||||||||||||||
cy.get('[data-cy="medication-remove"]').first().click(); | ||||||||||||||||||||||||||||||||
cy.verifyAndClickElement('[data-cy="confirm-remove-medication"]', "Remove"); | ||||||||||||||||||||||||||||||||
this.clickSubmitQuestionnaire(); | ||||||||||||||||||||||||||||||||
this.verifyQuestionnaireSubmission(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add verification after medication removal. The removeMedication method should include verification that the medication was actually removed. removeMedication() {
cy.get('[data-cy="medication-remove"]').first().click();
cy.verifyAndClickElement('[data-cy="confirm-remove-medication"]', "Remove");
this.clickSubmitQuestionnaire();
this.verifyQuestionnaireSubmission();
+ // Add verification that medication was removed
+ cy.get('[data-cy="medication-list"]').should('not.contain', this.lastRemovedMedication);
+ return this;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
clickUpdateEncounter() { | ||||||||||||||||||||||||||||||||
cy.verifyAndClickElement( | ||||||||||||||||||||||||||||||||
'[data-cy="update-encounter-option"]', | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.