Skip to content

Commit

Permalink
Adds cypress tests (#7930)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored May 28, 2024
1 parent fb9ba0e commit 6b75578
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 37 deletions.
30 changes: 12 additions & 18 deletions cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.selectConsultationStatus(
"Outpatient/Emergency Room",
);
cy.searchAndSelectOption("#symptoms", "ASYMPTOMATIC");
cy.get("#is_asymptomatic").click();
patientConsultationPage.typePatientIllnessHistory(patientIllnessHistory);
patientConsultationPage.typePatientExaminationHistory(
patientExaminationHistory,
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("Patient Consultation in multiple combination", () => {
"Outpatient/Emergency Room",
);
// Asymptomatic
cy.searchAndSelectOption("#symptoms", "ASYMPTOMATIC");
cy.get("#is_asymptomatic").click();
// CRITICAL category
patientConsultationPage.selectPatientCategory("Critical");
patientConsultationPage.selectPatientSuggestion("Declare Death");
Expand Down Expand Up @@ -234,7 +234,7 @@ describe("Patient Consultation in multiple combination", () => {
);
patientConsultationPage.selectPatientWard("Dummy Location 1");
// Asymptomatic
cy.searchAndSelectOption("#symptoms", "ASYMPTOMATIC");
cy.get("#is_asymptomatic").click();
// Abnormal category
patientConsultationPage.selectPatientCategory("Moderate");
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
Expand Down Expand Up @@ -293,18 +293,14 @@ describe("Patient Consultation in multiple combination", () => {
);
// verify the free text in referring facility name
patientConsultationPage.typeReferringFacility("Life Care Hospital");
// Vomiting and Nausea symptoms
patientConsultationPage.selectSymptomsDate("01012024");
patientConsultationPage.typeAndMultiSelectSymptoms("s", [
"SPUTUM",
"SORE THROAT",
"Sore throat",
"Sputum",
]);
patientConsultationPage.clickAddSymptom();
// Stable category
patientConsultationPage.selectPatientCategory("Mild");
// Date of symptoms
patientConsultationPage.selectSymptomsDate(
"#symptoms_onset_date",
"01012024",
);
// OP Consultation
patientConsultationPage.selectPatientSuggestion("OP Consultation");
// one ICD-11 and no principal
Expand Down Expand Up @@ -341,18 +337,16 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.selectConsultationStatus(
"Outpatient/Emergency Room",
);
// Select the Symptoms - Sore throat and fever symptoms
// Select the Symptoms - Breathlessness and Bleeding symptoms
patientConsultationPage.selectSymptomsDate("01012024");
patientConsultationPage.typeAndMultiSelectSymptoms("b", [
"BREATHLESSNESS",
"BLEEDING",
"Breathlessness",
"Bleeding",
]);
patientConsultationPage.clickAddSymptom();
// Comfort Care category
patientConsultationPage.selectPatientCategory("Comfort Care");
// Date of symptoms
patientConsultationPage.selectSymptomsDate(
"#symptoms_onset_date",
"01012024",
);
// Decision after consultation - Referred to Facility
patientConsultationPage.selectPatientSuggestion(
"Refer to another Hospital",
Expand Down
22 changes: 11 additions & 11 deletions cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
const patientLogupdate = new PatientLogupdate();
const domicilaryPatient = "Dummy Patient 11";
const patientCategory = "Moderate";
const additionalSymptoms = "ASYMPTOMATIC";
const additionalSymptoms = "Fever";
const physicalExamination = "physical examination details";
const otherExamination = "Other";
const patientSystolic = "119";
Expand Down Expand Up @@ -59,9 +59,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification(
"Telemedicine Log Updates details created successfully",
);
cy.verifyNotification("Tele-medicine log update created successfully");
});

it("Create a new log normal update for a domicilary care patient and edit it", () => {
Expand All @@ -86,7 +84,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.verifyNotification("Normal log update created successfully");
cy.closeNotification();
// edit the card and verify the data.
cy.contains("Daily Rounds").click();
Expand All @@ -109,7 +107,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.clickClearButtonInElement("#diastolic");
patientLogupdate.typeDiastolic(patientModifiedDiastolic);
cy.submitButton("Continue");
cy.verifyNotification("Normal Log Updates details updated successfully");
cy.verifyNotification("Normal log update details updated successfully");
cy.contains("Daily Rounds").click();
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
cy.verifyContentPresence("#consultation-preview", [
Expand All @@ -127,7 +125,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.typeAdditionalSymptoms(additionalSymptoms);
patientLogupdate.selectSymptomsDate("01012024");
patientLogupdate.typeAndMultiSelectSymptoms("fe", ["Fever"]);
patientLogupdate.clickAddSymptom();
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
Expand All @@ -140,10 +140,10 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.wait(2000);
cy.verifyNotification("Normal Log Updates details created successfully");
cy.verifyNotification("Normal log update created successfully");
// Verify the card content
cy.get("#basic-information").scrollIntoView();
cy.verifyContentPresence("#basic-information", [additionalSymptoms]);
cy.verifyContentPresence("#encounter-symptoms", [additionalSymptoms]);
});

it("Create a normal log update to verify MEWS Score Functionality", () => {
Expand All @@ -163,7 +163,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRespiratory(patientRespiratory);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.verifyNotification("Normal log update created successfully");
cy.closeNotification();
cy.verifyContentPresence("#consultation-buttons", ["9"]);
// Verify the Incomplete data will give blank info
Expand All @@ -173,7 +173,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
cy.submitButton("Save");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.verifyNotification("Normal log update created successfully");
cy.closeNotification();
cy.verifyContentPresence("#consultation-buttons", ["-"]);
});
Expand Down
12 changes: 6 additions & 6 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export class PatientConsultationPage {
cy.clickAndSelectOption("#route_to_facility", status);
}

selectSymptoms(symptoms) {
cy.clickAndMultiSelectOption("#symptoms", symptoms);
}
typeAndMultiSelectSymptoms(input, symptoms) {
cy.typeAndMultiSelectOption("#symptoms", input, symptoms);
cy.typeAndMultiSelectOption("#additional_symptoms", input, symptoms);
}
selectSymptomsDate(date: string) {
cy.clickAndTypeDate("#symptoms_onset_date", date);
}
selectSymptomsDate(selector: string, date: string) {
cy.clickAndTypeDate(selector, date);
clickAddSymptom() {
cy.get("#add-symptom").click();
}

verifyConsultationPatientName(patientName: string) {
Expand Down
10 changes: 10 additions & 0 deletions cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class PatientLogupdate {
cy.searchAndSelectOption("#additional_symptoms", symptoms);
}

typeAndMultiSelectSymptoms(input, symptoms) {
cy.typeAndMultiSelectOption("#additional_symptoms", input, symptoms);
}
selectSymptomsDate(date: string) {
cy.clickAndTypeDate("#symptoms_onset_date", date);
}
clickAddSymptom() {
cy.get("#add-symptom").click();
}

typeSystolic(systolic: string) {
cy.searchAndSelectOption("#systolic", systolic);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from "../Diagnosis/types";
import { EncounterSymptomsBuilder } from "../Symptoms/SymptomsBuilder";
import { FieldLabel } from "../Form/FormFields/FormField";

const Loading = lazy(() => import("../Common/Loading"));

const initForm: any = {
Expand Down Expand Up @@ -336,7 +337,7 @@ export const DailyRounds = (props: any) => {
if (obj) {
dispatch({ type: "set_form", form: initForm });
Notification.Success({
msg: `${obj.rounds_type === "VENTILATOR" ? "Critical Care" : capitalize(obj.rounds_type)} Log Updates details updated successfully`,
msg: `${obj.rounds_type === "VENTILATOR" ? "Critical Care" : capitalize(obj.rounds_type)} log update details updated successfully`,
});
if (["NORMAL", "TELEMEDICINE"].includes(state.form.rounds_type)) {
navigate(
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Symptoms/SymptomsBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ const AddSymptom = (props: {
<DateFormField
className="w-full md:w-36"
name="onset_date"
id="symptoms_onset_date"
placeholder="Date of onset"
disableFuture
value={onsetDate}
Expand Down Expand Up @@ -319,6 +320,7 @@ const AddSymptom = (props: {
)}
</div>
<ButtonV2
id="add-symptom"
type="button"
className="w-full py-3 md:w-auto"
disabled={
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Symptoms/SymptomsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const EncounterSymptomsCard = () => {
const records = groupAndSortSymptoms(data.results);

return (
<div>
<div id="encounter-symptoms">
<h3 className="mb-2 text-lg font-semibold leading-relaxed text-gray-900">
Symptoms
</h3>
Expand Down

0 comments on commit 6b75578

Please sign in to comment.