diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index ae416d8d990..5a1e5d874de 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -4,6 +4,10 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { UserPage } from "../../pageobject/Users/UserSearch"; import { UserCreationPage } from "../../pageobject/Users/UserCreation"; +import { + emergency_phone_number, + phone_number, +} from "../../pageobject/constants"; describe("User Creation", () => { const userPage = new UserPage(); @@ -43,6 +47,15 @@ describe("User Creation", () => { "Please select the local body", ]; + const EXPECTED_PROFILE_ERROR_MESSAGES = [ + "Field is required", + "Field is required", + "This field is required", + "Please enter valid phone number", + "This field is required", + "This field is required", + ]; + before(() => { loginPage.loginAsDisctrictAdmin(); cy.saveLocalStorage(); @@ -53,13 +66,82 @@ describe("User Creation", () => { cy.awaitUrl("/users"); }); + it("Update the existing user profile and verify its reflection", () => { + userCreationPage.clickElementById("profilenamelink"); + userCreationPage.verifyElementContainsText( + "username-profile-details", + "devdistrictadmin" + ); + userCreationPage.clickElementById("edit-cancel-profile-button"); + userCreationPage.typeIntoElementByIdPostClear( + "firstName", + "District Editted" + ); + userCreationPage.typeIntoElementByIdPostClear("lastName", "Cypress"); + userCreationPage.typeIntoElementByIdPostClear("age", "22"); + userCreationPage.selectDropdownOption("gender", "Male"); + userCreationPage.typeIntoElementByIdPostClear( + "phoneNumber", + "+91" + phone_number + ); + userCreationPage.typeIntoElementByIdPostClear( + "altPhoneNumber", + "+91" + emergency_phone_number + ); + userCreationPage.typeIntoElementByIdPostClear("email", "test@test.com"); + userCreationPage.typeIntoElementByIdPostClear("weekly_working_hours", "14"); + userCreationPage.clickElementById("submit"); + userCreationPage.verifyElementContainsText( + "contactno-profile-details", + "+91" + phone_number + ); + userCreationPage.verifyElementContainsText( + "whatsapp-profile-details", + "+91" + emergency_phone_number + ); + userCreationPage.verifyElementContainsText( + "firstname-profile-details", + "District Editted" + ); + userCreationPage.verifyElementContainsText( + "lastname-profile-details", + "Cypress" + ); + userCreationPage.verifyElementContainsText("age-profile-details", "22"); + userCreationPage.verifyElementContainsText( + "emailid-profile-details", + "test@test.com" + ); + userCreationPage.verifyElementContainsText( + "gender-profile-details", + "Male" + ); + userCreationPage.verifyElementContainsText( + "averageworkinghour-profile-details", + "14" + ); + }); + + it("Update the existing user profile Form Mandatory File Error", () => { + userCreationPage.clickElementById("profilenamelink"); + userCreationPage.clickElementById("edit-cancel-profile-button"); + userCreationPage.clearIntoElementById("firstName"); + userCreationPage.clearIntoElementById("lastName"); + userCreationPage.clearIntoElementById("age"); + userCreationPage.clearIntoElementById("phoneNumber"); + userCreationPage.clearIntoElementById("altPhoneNumber"); + userCreationPage.clearIntoElementById("weekly_working_hours"); + userCreationPage.clickElementById("submit"); + userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); + }); + it("create new user and verify reflection", () => { userCreationPage.clickElementById("addUserButton"); userCreationPage.selectFacility("Dummy Shifting Center"); userCreationPage.typeIntoElementById("username", username); userCreationPage.typeIntoElementById("password", "Test@123"); userCreationPage.selectHomeFacility("Dummy Shifting Center"); - userCreationPage.typeIntoElementById("phone_number", "9999999999"); + userCreationPage.typeIntoElementById("phone_number", phone_number); userCreationPage.setInputDate("date_of_birth", "date-input", "25081999"); userCreationPage.selectDropdownOption("user_type", "Doctor"); userCreationPage.typeIntoElementById("c_password", "Test@123"); @@ -130,67 +212,6 @@ describe("User Creation", () => { // .contains("Facility - User Already has permission to this facility"); // }); - // describe("Edit User Profile & Error Validation", () => { - // before(() => { - // cy.loginByApi(username, "#@Cypress_test123"); - // cy.saveLocalStorage(); - // }); - - // beforeEach(() => { - // cy.restoreLocalStorage(); - // cy.awaitUrl("/user/profile"); - // cy.contains("button", "Edit User Profile").click(); - // }); - - // it("First name Field Updation " + username, () => { - // cy.get("input[name=firstName]").clear(); - // cy.contains("button[type='submit']", "Update").click(); - // cy.get("span.error-text").should("contain", "Field is required"); - // cy.get("input[name=firstName]").type("firstName updated"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - - // it("Last name Field Updation " + username, () => { - // cy.get("input[name=lastName]").clear(); - // cy.contains("button[type='submit']", "Update").click(); - // cy.get("span.error-text").should("contain", "Field is required"); - // cy.get("input[name=lastName]").type("lastName updated"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - - // it("Age Field Updation " + username, () => { - // cy.get("input[name=age]").clear(); - // cy.contains("button[type='submit']", "Update").click(); - // cy.get("span.error-text").should("contain", "This field is required"); - // cy.get("input[name=age]").type("11"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - - // it("Phone number Field Updation " + username, () => { - // cy.get("input[name=phoneNumber]").clear(); - // cy.contains("button[type='submit']", "Update").click(); - // cy.get("span.error-text").should( - // "contain", - // "Please enter valid phone number" - // ); - // cy.get("input[name=phoneNumber]").type("+919999999999"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - - // it("Whatsapp number Field Updation " + username, () => { - // cy.get("input[name=altPhoneNumber]").clear(); - // cy.get("input[name=altPhoneNumber]").type("+919999999999"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - - // it("Email Field Updation " + username, () => { - // cy.get("input[name=email]").clear(); - // cy.contains("button[type='submit']", "Update").click(); - // cy.get("span.error-text").should("contain", "This field is required"); - // cy.get("input[name=email]").type("test@test.com"); - // cy.contains("button[type='submit']", "Update").click(); - // }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 6bef3584ec8..32127ffcb90 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -10,6 +10,20 @@ export class UserCreationPage { .type(value); } + typeIntoElementByIdPostClear(elementId: string, value: string) { + cy.get("#" + elementId) + .click() + .clear() + .click() + .type(value); + } + + clearIntoElementById(elementId: string) { + cy.get("#" + elementId) + .click() + .clear(); + } + typeIntoInputByName(inputName: string, value: string) { cy.get("input[name='" + inputName + "']") .click() diff --git a/src/Components/Common/Sidebar/SidebarUserCard.tsx b/src/Components/Common/Sidebar/SidebarUserCard.tsx index 6f243d430d0..59970e8a73c 100644 --- a/src/Components/Common/Sidebar/SidebarUserCard.tsx +++ b/src/Components/Common/Sidebar/SidebarUserCard.tsx @@ -37,6 +37,7 @@ const SidebarUserCard = ({ shrinked }: { shrinked: boolean }) => { {profileName} diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 1392b7af6eb..fd6213d8e08 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -8,7 +8,7 @@ import { TELEMEDICINE_ACTIONS, } from "../../Common/constants"; import { ConsultationModel, PatientCategory } from "../Facility/models"; -import { Switch } from "@headlessui/react"; +import { Switch, Menu } from "@headlessui/react"; import { Link } from "raviger"; import { useState } from "react"; @@ -26,8 +26,9 @@ import Beds from "../Facility/Consultations/Beds"; import { PatientModel } from "./models"; import request from "../../Utils/request/request.js"; import routes from "../../Redux/api.js"; -import { Menu } from "@headlessui/react"; import DropdownMenu from "../Common/components/Menu.js"; +import { triggerGoal } from "../../Integrations/Plausible.js"; +import useAuthUser from "../../Common/hooks/useAuthUser.js"; export default function PatientInfoCard(props: { patient: PatientModel; @@ -36,6 +37,8 @@ export default function PatientInfoCard(props: { consultationId: string; showAbhaProfile?: boolean; }) { + const authUser = useAuthUser(); + const [open, setOpen] = useState(false); const [showLinkABHANumber, setShowLinkABHANumber] = useState(false); const [showABHAProfile, setShowABHAProfile] = useState( @@ -459,6 +462,11 @@ export default function PatientInfoCard(props: { }); setOpen(true); } + triggerGoal("Patient Card Button Clicked", { + buttonName: action[1], + consultationId: consultation?.id, + userId: authUser?.id, + }); }} > { close(); setShowABHAProfile(true); + triggerGoal("Patient Card Button Clicked", { + buttonName: "Show ABHA Profile", + consultationId: consultation?.id, + userId: authUser?.id, + }); }} > @@ -497,6 +510,11 @@ export default function PatientInfoCard(props: {
{ + triggerGoal("Patient Card Button Clicked", { + buttonName: "Link Care Context", + consultationId: consultation?.id, + userId: authUser?.id, + }); close(); setShowLinkCareContext(true); }} @@ -532,6 +550,11 @@ export default function PatientInfoCard(props: { { + triggerGoal("Patient Card Button Clicked", { + buttonName: "Medico Legal Case", + consultationId: consultation?.id, + userId: authUser?.id, + }); setMedicoLegalCase(checked); switchMedicoLegalCase(checked); }} diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 5c5ad46b9fa..0653ea452a2 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -417,7 +417,11 @@ export default function UserProfile() { Local Body, District and State are Non Editable Settings.

- setShowEdit(!showEdit)} type="button"> + setShowEdit(!showEdit)} + type="button" + id="edit-cancel-profile-button" + > {showEdit ? "Cancel" : "Edit User Profile"} handleSignOut(true)}> @@ -431,7 +435,10 @@ export default function UserProfile() { {!showEdit && (
-
+
Username
@@ -439,7 +446,10 @@ export default function UserProfile() { {details.username || "-"}
-
+
Contact No
@@ -448,7 +458,10 @@ export default function UserProfile() {
-
+
Whatsapp No
@@ -456,7 +469,10 @@ export default function UserProfile() { {details.alt_phone_number || "-"}
-
+
Email address
@@ -464,7 +480,10 @@ export default function UserProfile() { {details.email || "-"}
-
+
First Name
@@ -472,7 +491,10 @@ export default function UserProfile() { {details.first_name || "-"}
-
+
Last Name
@@ -480,7 +502,7 @@ export default function UserProfile() { {details.last_name || "-"}
-
+
Age
@@ -497,7 +519,10 @@ export default function UserProfile() { {details.user_type || "-"}
-
+
Gender
@@ -547,7 +572,10 @@ export default function UserProfile() {
-
+
Average weekly working hours