From 2d7abfb6032e5517a682da739f354634b42e4811 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:20:52 +0530 Subject: [PATCH] New Cypress Test | Normal Log Update for Admission and Non- Admission 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 --- .../patient_spec/patient_consultation.cy.ts | 1 - .../e2e/patient_spec/patient_logupdate.cy.ts | 156 ++++++++++++++++++ .../pageobject/Patient/PatientConsultation.ts | 1 + .../pageobject/Patient/PatientLogupdate.ts | 88 ++++++++++ cypress/support/commands.ts | 8 + cypress/support/index.ts | 4 + package-lock.json | 22 +-- package.json | 2 +- src/CAREUI/display/Timeline.tsx | 2 +- .../ConsultationUpdatesTab.tsx | 2 +- .../DailyRounds/DefaultLogUpdateCard.tsx | 5 +- .../Consultations/PrimaryParametersPlot.tsx | 2 +- .../Patient/DailyRoundListDetails.tsx | 5 +- src/Components/Patient/PatientInfoCard.tsx | 5 +- 14 files changed, 279 insertions(+), 24 deletions(-) create mode 100644 cypress/e2e/patient_spec/patient_logupdate.cy.ts create mode 100644 cypress/pageobject/Patient/PatientLogupdate.ts diff --git a/cypress/e2e/patient_spec/patient_consultation.cy.ts b/cypress/e2e/patient_spec/patient_consultation.cy.ts index 99565a24cc..36c3ebdcb4 100644 --- a/cypress/e2e/patient_spec/patient_consultation.cy.ts +++ b/cypress/e2e/patient_spec/patient_consultation.cy.ts @@ -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, diff --git a/cypress/e2e/patient_spec/patient_logupdate.cy.ts b/cypress/e2e/patient_spec/patient_logupdate.cy.ts new file mode 100644 index 0000000000..57f3198067 --- /dev/null +++ b/cypress/e2e/patient_spec/patient_logupdate.cy.ts @@ -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(); + }); +}); diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index d88c79dafd..db72765444 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -120,6 +120,7 @@ export class PatientConsultationPage { "#consultation-buttons", "Edit Consultation Details" ); + cy.wait(3000); } visitShiftRequestPage() { diff --git a/cypress/pageobject/Patient/PatientLogupdate.ts b/cypress/pageobject/Patient/PatientLogupdate.ts new file mode 100644 index 0000000000..8b15e4dd4f --- /dev/null +++ b/cypress/pageobject/Patient/PatientLogupdate.ts @@ -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; diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 5170635647..f4b7becdca 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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); + }); + }); +}); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 46e695b650..fbaaa4f18e 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -34,6 +34,10 @@ declare global { ): Chainable; preventPrint(): Chainable; closeNotification(): Chainable; + verifyContentPresence( + selector: string, + texts: string[] + ): Chainable; } } } diff --git a/package-lock.json b/package-lock.json index 497be83b96..95740c9629 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,7 +87,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", @@ -8849,21 +8849,20 @@ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/cypress": { - "version": "13.5.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.5.0.tgz", - "integrity": "sha512-oh6U7h9w8wwHfzNDJQ6wVcAeXu31DlIYlNOBvfd6U4CcB8oe4akawQmH+QJVOMZlM42eBoCne015+svVqdwdRQ==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.0.tgz", + "integrity": "sha512-UimjRSJJYdTlvkChcdcfywKJ6tUYuwYuk/n1uMMglrvi+ZthNhoRYcxnWgTqUtkl17fXrPAsD5XT2rcQYN1xKA==", "dev": true, "hasInstallScript": true, "dependencies": { "@cypress/request": "^3.0.0", "@cypress/xvfb": "^1.2.4", - "@types/node": "^18.17.5", "@types/sinonjs__fake-timers": "8.1.1", "@types/sizzle": "^2.3.2", "arch": "^2.2.0", "blob-util": "^2.0.2", "bluebird": "^3.7.2", - "buffer": "^5.6.0", + "buffer": "^5.7.1", "cachedir": "^2.3.0", "chalk": "^4.1.0", "check-more-types": "^2.24.0", @@ -8881,7 +8880,7 @@ "figures": "^3.2.0", "fs-extra": "^9.1.0", "getos": "^3.2.1", - "is-ci": "^3.0.0", + "is-ci": "^3.0.1", "is-installed-globally": "~0.4.0", "lazy-ass": "^1.6.0", "listr2": "^3.8.3", @@ -8937,15 +8936,6 @@ "cypress-split-preview": "bin/preview.js" } }, - "node_modules/cypress/node_modules/@types/node": { - "version": "18.18.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.9.tgz", - "integrity": "sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/cypress/node_modules/fs-extra": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", diff --git a/package.json b/package.json index 7c5ab56133..244b6c125b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/CAREUI/display/Timeline.tsx b/src/CAREUI/display/Timeline.tsx index 49ace78bd8..f8e7991d3b 100644 --- a/src/CAREUI/display/Timeline.tsx +++ b/src/CAREUI/display/Timeline.tsx @@ -23,7 +23,7 @@ const TimelineContext = createContext(""); export default function Timeline({ className, children, name }: TimelineProps) { return ( -
+
    {children} diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index fdbf484632..e8a64b5310 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -130,7 +130,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { )}
    -
    +
    { const { t } = useTranslation(); return ( -
    +
    -
    +
    diff --git a/src/Components/Patient/DailyRoundListDetails.tsx b/src/Components/Patient/DailyRoundListDetails.tsx index 02ad9aa47f..0896cb5310 100644 --- a/src/Components/Patient/DailyRoundListDetails.tsx +++ b/src/Components/Patient/DailyRoundListDetails.tsx @@ -58,7 +58,10 @@ export const DailyRoundListDetails = (props: any) => { title={`Consultation Update #${id}`} backUrl={`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/daily-rounds`} > -
    +
    diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 1d9be149be..e91ce64562 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -492,7 +492,10 @@ export default function PatientInfoCard(props: { {patient.is_active && consultation?.id && !consultation?.discharge_date && ( -
    +