Skip to content

Commit

Permalink
New Cypress Test | Normal Log Update for Admission and Non- Admission…
Browse files Browse the repository at this point in the history
… Patients | Patient Consultation Module (#7400)

* log update

* log update

* updated the additional symptoms

* Normal log update modification part done

* pre-final part

* pre-final part

* final change

* flaky test

* syntax error

* added wait

* added scrollinto view

* added wait

* fixing scroll

* revert canvas verification
  • Loading branch information
nihal467 committed Mar 19, 2024
1 parent df8c57b commit 2d7abfb
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 24 deletions.
1 change: 0 additions & 1 deletion cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ describe("Patient Consultation in multiple combination", () => {
it("Edit created consultation to existing patient", () => {
patientPage.visitPatient("Dummy Patient 13");
patientConsultationPage.clickEditConsultationButton();
cy.wait(5000);
patientConsultationPage.typePatientIllnessHistory("editted");
patientConsultationPage.selectPatientDiagnosis(
diagnosis5,
Expand Down
156 changes: 156 additions & 0 deletions cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientLogupdate from "../../pageobject/Patient/PatientLogupdate";

describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
const loginPage = new LoginPage();
const patientConsultationPage = new PatientConsultationPage();
const patientPage = new PatientPage();
const patientLogupdate = new PatientLogupdate();
const domicilaryPatient = "Dummy Patient 11";
const patientCategory = "Abnormal";
const additionalSymptoms = "ASYMPTOMATIC";
const physicalExamination = "physical examination details";
const otherExamination = "Other";
const patientSystolic = "119";
const patientDiastolic = "150";
const patientModifiedSystolic = "120";
const patientModifiedDiastolic = "145";
const patientPulse = "152";
const patientTemperature = "96.6";
const patientRespiratory = "140";
const patientSpo2 = "15";
const patientRhythmType = "Regular";
const patientRhythm = "Normal Rhythm";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("Create a new log teleicu update for a domicilary care patient and verify the copy previous value function", () => {
patientPage.visitPatient("Dummy Patient 11");
patientConsultationPage.clickEditConsultationButton();
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
cy.submitButton("Update Consultation");
cy.verifyNotification("Consultation updated successfully");
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.typeAdditionalSymptoms(additionalSymptoms);
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
patientLogupdate.typeTemperature(patientTemperature);
patientLogupdate.typeRespiratory(patientRespiratory);
patientLogupdate.typeSpo2(patientSpo2);
patientLogupdate.selectRhythm(patientRhythmType);
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
// verify the copied previous value
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.clickCopyPreviousValue();
patientLogupdate.selectPatientCategory(patientCategory);
cy.submitButton("Save");
cy.closeNotification();
cy.verifyContentPresence("#physical_examination_info", [
physicalExamination,
]);
cy.verifyContentPresence("#rhythm_detail", [patientRhythm]);
cy.submitButton("Continue");
cy.verifyNotification("Consultation Updates details updated successfully");
});

it("Create a new log normal update for a domicilary care patient and edit it", () => {
patientPage.visitPatient(domicilaryPatient);
patientConsultationPage.clickEditConsultationButton();
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
cy.submitButton("Update Consultation");
cy.verifyNotification("Consultation updated successfully");
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.typeAdditionalSymptoms(additionalSymptoms);
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
patientLogupdate.typeTemperature(patientTemperature);
patientLogupdate.typeRespiratory(patientRespiratory);
patientLogupdate.typeSpo2(patientSpo2);
patientLogupdate.selectRhythm(patientRhythmType);
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
// edit the card and verify the data.
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
cy.verifyContentPresence("#consultation-preview", [
patientCategory,
patientDiastolic,
patientSystolic,
physicalExamination,
otherExamination,
patientPulse,
patientTemperature,
patientRespiratory,
patientSpo2,
patientRhythm,
]);
patientLogupdate.clickUpdateDetail();
patientLogupdate.clickClearButtonInElement("#systolic");
patientLogupdate.typeSystolic(patientModifiedSystolic);
patientLogupdate.clickClearButtonInElement("#diastolic");
patientLogupdate.typeDiastolic(patientModifiedDiastolic);
cy.submitButton("Continue");
cy.verifyNotification("Consultation Updates details updated successfully");
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
cy.verifyContentPresence("#consultation-preview", [
patientModifiedDiastolic,
patientModifiedSystolic,
]);
});

it("Create a new log normal update for a admission patient and verify its reflection in cards", () => {
patientPage.visitPatient("Dummy Patient 13");
patientLogupdate.clickLogupdate();
cy.verifyNotification("Please assign a bed to the patient");
patientLogupdate.selectBed("Dummy Bed 6");
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.typeAdditionalSymptoms(additionalSymptoms);
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
patientLogupdate.typeTemperature(patientTemperature);
patientLogupdate.typeRespiratory(patientRespiratory);
patientLogupdate.typeSpo2(patientSpo2);
patientLogupdate.selectRhythm(patientRhythmType);
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
// Verify the card content
cy.get("#basic-information").scrollIntoView();
cy.verifyContentPresence("#basic-information", [additionalSymptoms]);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
1 change: 1 addition & 0 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class PatientConsultationPage {
"#consultation-buttons",
"Edit Consultation Details"
);
cy.wait(3000);
}

visitShiftRequestPage() {
Expand Down
88 changes: 88 additions & 0 deletions cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
class PatientLogupdate {
clickLogupdate() {
cy.get("#log-update").scrollIntoView();
cy.verifyAndClickElement("#log-update", "Log Update");
cy.wait(2000);
}

selectBed(bed: string) {
cy.searchAndSelectOption("input[name='bed']", bed);
cy.submitButton("Move to bed");
cy.wait(2000);
}

selectPatientCategory(category: string) {
cy.clickAndSelectOption("#patient_category", category);
}

typePhysicalExamination(examination: string) {
cy.get("#physical_examination_info").click().type(examination);
cy.get("#physical_examination_info").should("contain", examination);
}

typeOtherDetails(details: string) {
cy.get("#other_details").click().type(details);
}

typeAdditionalSymptoms(symptoms: string) {
cy.clickAndSelectOption("#additional_symptoms", symptoms);
}

typeSystolic(systolic: string) {
cy.searchAndSelectOption("#systolic", systolic);
}

typeDiastolic(diastolic: string) {
cy.searchAndSelectOption("#diastolic", diastolic);
}

typePulse(pulse: string) {
cy.searchAndSelectOption("#pulse", pulse);
}

typeTemperature(temperature: string) {
cy.searchAndSelectOption("#temperature", temperature);
}

typeRespiratory(respiratory: string) {
cy.searchAndSelectOption("#resp", respiratory);
}

typeSpo2(spo: string) {
cy.searchAndSelectOption("#ventilator_spo2", spo);
}

selectRhythm(rhythm: string) {
cy.clickAndSelectOption("#rhythm", rhythm);
}

typeRhythm(rhythm: string) {
cy.get("#rhythm_detail").click().type(rhythm);
}

clickLogupdateCard(element, patientCategory) {
cy.get(element).scrollIntoView();
cy.verifyContentPresence(element, [patientCategory]);
cy.get(element).first().contains("View Details").click();
cy.wait(3000);
}

clickUpdateDetail() {
cy.verifyAndClickElement("#consultation-preview", "Update Details");
cy.wait(3000);
}

clickClearButtonInElement(elementId) {
cy.get(elementId).find("#clear-button").click();
}

clickVitals() {
cy.get("#consultation_tab_nav").scrollIntoView();
cy.verifyAndClickElement("#consultation_tab_nav", "Vitals");
}

clickCopyPreviousValue() {
cy.get("#clone_last").click();
}
}
export default PatientLogupdate;
8 changes: 8 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,11 @@ Cypress.Commands.add("closeNotification", () => {
cy.wrap($div).click();
});
});

Cypress.Commands.add("verifyContentPresence", (selector, texts) => {
cy.get(selector).then(($el) => {
texts.forEach((text) => {
cy.wrap($el).should("contain", text);
});
});
});
4 changes: 4 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ declare global {
): Chainable<Element>;
preventPrint(): Chainable<Window>;
closeNotification(): Chainable<Element>;
verifyContentPresence(
selector: string,
texts: string[]
): Chainable<Element>;
}
}
}
22 changes: 6 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"@typescript-eslint/parser": "^5.61.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"autoprefixer": "^10.4.14",
"cypress": "^13.5.0",
"cypress": "^13.7.0",
"cypress-localstorage-commands": "^2.2.3",
"cypress-split": "^1.20.1",
"eslint": "^8.44.0",
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TimelineContext = createContext("");

export default function Timeline({ className, children, name }: TimelineProps) {
return (
<div className={className}>
<div className={className} id="list">
<ol role="list" className="space-y-6">
<TimelineContext.Provider value={name}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
</section>
)}
<div className="flex flex-col xl:flex-row">
<div className="w-full xl:w-2/3">
<div className="w-full xl:w-2/3" id="basic-information">
<PageTitle
title="Basic Information"
hideBack={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const DefaultLogUpdateCard = ({ round, ...props }: Props) => {
const { t } = useTranslation();

return (
<div className="flex w-full flex-col gap-4 rounded-lg border border-gray-400 p-4 @container">
<div
className="flex w-full flex-col gap-4 rounded-lg border border-gray-400 p-4 @container"
id="dailyround-entry"
>
<LogUpdateCardAttribute
attributeKey={"Round Type" as any}
attributeValue={t(round.rounds_type)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const PrimaryParametersPlot = ({

return (
<div>
<div className="grid gap-4 md:grid-cols-2">
<div className="grid gap-4 md:grid-cols-2" id="vital-section">
<div className="m-2 overflow-x-auto rounded-lg border bg-white px-4 pt-4 shadow md:w-full">
<StackedLinePlot title="BP" xData={dates} yData={BPData} />
</div>
Expand Down

0 comments on commit 2d7abfb

Please sign in to comment.