Skip to content

Commit

Permalink
Merge branch 'develop' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Oct 31, 2023
2 parents 2544e4b + bcd9730 commit 5b3b4a5
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 74 deletions.
145 changes: 83 additions & 62 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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", "[email protected]");
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",
"[email protected]"
);
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");
Expand Down Expand Up @@ -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("[email protected]");
// cy.contains("button[type='submit']", "Update").click();
// });

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
14 changes: 14 additions & 0 deletions cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/Components/Common/Sidebar/SidebarUserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SidebarUserCard = ({ shrinked }: { shrinked: boolean }) => {
<Link
href="/user/profile"
className="flex-nowrap overflow-hidden break-words font-semibold text-white"
id="profilenamelink"
>
{profileName}
</Link>
Expand Down
27 changes: 25 additions & 2 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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,
});
}}
>
<CareIcon
Expand Down Expand Up @@ -489,6 +497,11 @@ export default function PatientInfoCard(props: {
onClick={() => {
close();
setShowABHAProfile(true);
triggerGoal("Patient Card Button Clicked", {
buttonName: "Show ABHA Profile",
consultationId: consultation?.id,
userId: authUser?.id,
});
}}
>
<CareIcon className="care-l-user-square text-lg text-primary-500" />
Expand All @@ -497,6 +510,11 @@ export default function PatientInfoCard(props: {
<div
className="dropdown-item-primary pointer-events-auto m-2 flex cursor-pointer items-center justify-start gap-2 rounded border-0 p-2 text-sm font-normal transition-all duration-200 ease-in-out"
onClick={() => {
triggerGoal("Patient Card Button Clicked", {
buttonName: "Link Care Context",
consultationId: consultation?.id,
userId: authUser?.id,
});
close();
setShowLinkCareContext(true);
}}
Expand Down Expand Up @@ -532,6 +550,11 @@ export default function PatientInfoCard(props: {
<Switch
checked={medicoLegalCase}
onChange={(checked) => {
triggerGoal("Patient Card Button Clicked", {
buttonName: "Medico Legal Case",
consultationId: consultation?.id,
userId: authUser?.id,
});
setMedicoLegalCase(checked);
switchMedicoLegalCase(checked);
}}
Expand Down
Loading

0 comments on commit 5b3b4a5

Please sign in to comment.