From f622b499b84d13e93d033e7d7510dbb5cc22d4b4 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:06:51 +0530 Subject: [PATCH 1/2] doctor connect test --- .../patient_spec/PatientDoctorConnect.cy.ts | 56 +++++++++++++++++++ .../Patient/PatientDoctorConnect.ts | 32 +++++++++++ .../Facility/ConsultationDetails/index.tsx | 1 + .../Facility/DoctorVideoSlideover.tsx | 6 +- 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 cypress/e2e/patient_spec/PatientDoctorConnect.cy.ts create mode 100644 cypress/pageobject/Patient/PatientDoctorConnect.ts diff --git a/cypress/e2e/patient_spec/PatientDoctorConnect.cy.ts b/cypress/e2e/patient_spec/PatientDoctorConnect.cy.ts new file mode 100644 index 00000000000..64d47db2cf1 --- /dev/null +++ b/cypress/e2e/patient_spec/PatientDoctorConnect.cy.ts @@ -0,0 +1,56 @@ +import { DoctorConnect } from "pageobject/Patient/PatientDoctorConnect"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; + +describe("Patient Doctor Connect in consultation page", () => { + const loginPage = new LoginPage(); + const patientPage = new PatientPage(); + const doctorconnect = new DoctorConnect(); + const patientName = "Dummy Patient 11"; + const doctorUser = "Dev Doctor"; + const doctorUserNumber = "+919876543219"; + const nurseUser = "Dev Staff"; + const teleIcuUser = "Dev Doctor Two"; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Patient Doctor connect phone redirection and sort by filter", () => { + // click on the slideover and verify icon redirection + patientPage.visitPatient(patientName); + doctorconnect.clickDoctorConnectButton(); + // verify all the users are visible under the all section + cy.verifyContentPresence("#doctor-connect-home-doctor", [doctorUser]); + cy.verifyContentPresence("#doctor-connect-home-nurse", [nurseUser]); + cy.verifyContentPresence("#doctor-connect-remote-doctor", [teleIcuUser]); + // verify copy content button functionality + doctorconnect.CopyFunctionTrigger(); + doctorconnect.clickCopyPhoneNumber( + "#doctor-connect-home-doctor", + doctorUser, + ); + doctorconnect.verifyCopiedContent(doctorUserNumber); + // verify the whatsapp and phone number icon presence + doctorconnect.verifyIconVisible("#whatsapp-icon"); + doctorconnect.verifyIconVisible("#phone-icon"); + // sort the each datas based on user type + doctorconnect.clickUsersSortBy("Doctor"); + cy.verifyContentPresence("#doctor-connect-home-doctor", [doctorUser]); + doctorconnect.clickUsersSortBy("Nurse"); + cy.verifyContentPresence("#doctor-connect-home-nurse", [nurseUser]); + doctorconnect.clickUsersSortBy("TeleICU Doctor"); + cy.verifyContentPresence("#doctor-connect-remote-doctor", [teleIcuUser]); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/pageobject/Patient/PatientDoctorConnect.ts b/cypress/pageobject/Patient/PatientDoctorConnect.ts new file mode 100644 index 00000000000..b8c33bb4b24 --- /dev/null +++ b/cypress/pageobject/Patient/PatientDoctorConnect.ts @@ -0,0 +1,32 @@ +export class DoctorConnect { + clickDoctorConnectButton() { + cy.get("#doctor-connect-button").scrollIntoView(); + cy.get("#doctor-connect-button").click(); + } + + CopyFunctionTrigger() { + cy.window().then((win) => { + cy.stub(win.navigator.clipboard, "writeText").as("clipboardStub"); + }); + } + + verifyCopiedContent(text: string) { + cy.get("@clipboardStub").should("be.calledWith", text); + } + + verifyIconVisible(selector: string) { + cy.get(selector).should("be.visible"); + } + + clickCopyPhoneNumber(element: string, text: string) { + cy.get(element) + .contains(text) // Find the element containing "dev doctor" + .parent() // Move up to the parent element (if necessary) + .find("#copy-phoneicon") // Find the #copy-phoneicon within that context + .click(); + } + + clickUsersSortBy(text: string) { + cy.get("#doctor-connect-filter-tabs").contains(text).click(); + } +} diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 53e137d12eb..6970898a158 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -256,6 +256,7 @@ export const ConsultationDetails = (props: any) => { {!consultationData.discharge_date && ( <>