Skip to content

Commit

Permalink
User Profile Replacement/Removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Dec 11, 2024
1 parent e89530d commit d6c8a25
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 1,110 deletions.
14 changes: 0 additions & 14 deletions cypress/e2e/users_spec/UsersManage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,6 @@ describe("Manage User", () => {
cy.wait(500);
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
cy.wait(500);
manageUserPage.navigateToProfile();
cy.verifyContentPresence("#username-profile-details", [
usernameforworkinghour,
]);
manageUserPage.assertSkillInAlreadyLinkedSkills(linkedskill);
// unlink the skill
manageUserPage.navigateToManageUser();
userPage.typeInSearchInput(usernameforworkinghour);
userPage.checkUsernameText(usernameforworkinghour);
manageUserPage.clickMoreDetailsButton(usernameforworkinghour);
manageUserPage.verifyMoreDetailsPage();
manageUserPage.clickLinkedSkillTab();
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
manageUserPage.clickUnlinkSkill();
manageUserPage.verifyUnlinkSkillModal();
manageUserPage.clickConfirmUnlinkSkill();
Expand Down Expand Up @@ -305,7 +292,6 @@ describe("Manage User", () => {
manageUserPage.clickSubmit();
// verify the data is reflected in the page
manageUserPage.verifyWorkingHours(workinghour);
manageUserPage.verifyProfileWorkingHours(workinghour);
});

it("linking and unlinking facility for multiple users, and confirm reflection in user cards and doctor connect", () => {
Expand Down
92 changes: 58 additions & 34 deletions cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import LoginPage from "../../pageobject/Login/LoginPage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import UserProfilePage from "../../pageobject/Users/UserProfilePage";

import dayjs = require("dayjs");

describe("Manage User Profile", () => {
const loginPage = new LoginPage();
const userProfilePage = new UserProfilePage();
Expand Down Expand Up @@ -32,48 +34,70 @@ describe("Manage User Profile", () => {
cy.awaitUrl("/user/profile");
});

it("Set Dob, Gender, Email, Phone and Working Hours for a user and verify its reflection in user profile", () => {
userProfilePage.clickEditProfileButton();
it("Set Dob and Gender for a user and verify its reflection in user profile", () => {
manageUserPage.verifyMoreDetailsPage();
manageUserPage.clickBasicInfoEditButton();
manageUserPage.clearUserBasicInfo();
manageUserPage.editUserBasicInfo("Devo", "Doctoro", date_of_birth, gender);
userProfilePage.clickSubmit();
manageUserPage.verifyEditUserDetails("Devo", "Doctoro", "1/1/1999", "Male");
});

userProfilePage.typeDateOfBirth(date_of_birth);
userProfilePage.selectGender(gender);
userProfilePage.typeEmail(email);
userProfilePage.typePhoneNumber(phone);
userProfilePage.typeWhatsappNumber(phone);
userProfilePage.typeWorkingHours(workinghours);
userProfilePage.typeQualification(qualification);
userProfilePage.typeDoctorYoE(doctorYoE);
userProfilePage.typeMedicalCouncilRegistration(medicalCouncilRegistration);
userProfilePage.clickUpdateButton();
cy.verifyNotification("Details updated successfully");
userProfilePage.assertDateOfBirth("01/01/1999");
userProfilePage.assertGender(gender);
userProfilePage.assertEmail(email);
userProfilePage.assertPhoneNumber(phone);
userProfilePage.assertAltPhoneNumber(phone);
userProfilePage.assertWorkingHours(workinghours);
it("Set Email and Phone for a user and verify its reflection in user profile", () => {
manageUserPage.verifyMoreDetailsPage();
manageUserPage.clickContactInfoEditButton();
manageUserPage.clearUserContactInfo();
manageUserPage.editUserContactInfo(email, phone);
manageUserPage.clickSubmit();
manageUserPage.verifyEditUserContactInfo(email, phone);
});

it("Adding video connect link for a user and verify its reflection in user profile and doctor connect", () => {
// verify the user doesn't have any video connect link
userProfilePage.assertVideoConnectLink("-");
// Link a new video connect link and ensure it is under video connect link
userProfilePage.clickEditProfileButton();
userProfilePage.typeVideoConnectLink("https://www.example.com");
userProfilePage.clickUpdateButton();
userProfilePage.assertVideoConnectLink("https://www.example.com");
// Edit the video connect link and ensure it is updated
userProfilePage.clickEditProfileButton();
userProfilePage.typeVideoConnectLink("https://www.test.com");
userProfilePage.clickUpdateButton();
userProfilePage.assertVideoConnectLink("https://www.test.com");
// Go to particular facility doctor connect and verify the video connect link is present
it("Set Qualification, YoE, Medical Council Registration, Weekly Working Hours and Video Connect Link for a user and verify its reflection in user profile", () => {
manageUserPage.verifyMoreDetailsPage();
manageUserPage.clickProfessionalInfoEditButton();
manageUserPage.clearProfessionalInfo();
manageUserPage.clearDoctorOrNurseProfessionalInfo(true);
manageUserPage.editUserProfessionalInfo(
qualification,
doctorYoE,
medicalCouncilRegistration,
);
manageUserPage.editHoursAndVideoConnectLink(
workinghours,
"https://www.example.com",
);
manageUserPage.clickSubmit();
const experienceCommencedOn = dayjs().subtract(parseInt(doctorYoE), "year");
const formattedDate = dayjs(experienceCommencedOn).format("YYYY-MM-DD");
manageUserPage.verifyEditUserProfessionalInfo(
qualification,
formattedDate,
medicalCouncilRegistration,
);
manageUserPage.verifyHoursAndVideoConnectLink(
workinghours,
"https://www.example.com",
);
manageUserPage.clickProfessionalInfoEditButton();
manageUserPage.clearProfessionalInfo();
manageUserPage.editHoursAndVideoConnectLink(
workinghours,
"https://www.test.com",
);
manageUserPage.clickSubmit();
manageUserPage.verifyHoursAndVideoConnectLink(
workinghours,
"https://www.test.com",
);
facilityHome.navigateToFacilityHomepage();
facilityHome.typeFacilitySearch(facilitySearch);
facilityHome.assertFacilityInCard(facilitySearch);
manageUserPage.clickFacilityPatients();
manageUserPage.clickDoctorConnectButton();
manageUserPage.assertVideoConnectLink("Dev Doctor", "https://www.test.com");
manageUserPage.assertVideoConnectLink(
"Devo Doctoro",
"https://www.test.com",
);
});

afterEach(() => {
Expand Down
37 changes: 28 additions & 9 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ export class ManageUserPage {
}
}

editHoursAndVideoConnectLink(
weeklyWorkingHours: string,
videoConnectLink: string,
) {
cy.get("input[name='weekly_working_hours']").scrollIntoView();
cy.get("input[name='weekly_working_hours']")
.click()
.type(weeklyWorkingHours);
cy.get("input[name='video_connect_link']").click().type(videoConnectLink);
}

verifyEditUserProfessionalInfo(
qualification: string,
yearsOfExperience?: string,
Expand All @@ -170,6 +181,21 @@ export class ManageUserPage {
}
}

verifyHoursAndVideoConnectLink(
weeklyWorkingHours: string,
videoConnectLink: string,
) {
cy.get("#view-average_weekly_working_hours").scrollIntoView();
cy.get("#view-average_weekly_working_hours").should(
"contain.text",
weeklyWorkingHours,
);
cy.get("#view-video_conference_link").should(
"contain.text",
videoConnectLink,
);
}

verifyPasswordEditButtonNotExist() {
cy.get("#change-edit-password-button").should("not.exist");
}
Expand All @@ -193,15 +219,8 @@ export class ManageUserPage {
}

verifyWorkingHours(expectedHours: string) {
cy.get("input[name='weekly_working_hours']").scrollIntoView();
cy.get("input[name='weekly_working_hours']").should("be.visible");
cy.get("input[name='weekly_working_hours']").should(
"have.value",
expectedHours,
);
}

verifyProfileWorkingHours(expectedHours: string) {
cy.get("#view-average_weekly_working_hours").scrollIntoView();
cy.get("#view-average_weekly_working_hours").should("be.visible");
cy.get("#view-average_weekly_working_hours").should(
"contain.text",
expectedHours,
Expand Down
3 changes: 3 additions & 0 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default class UserProfilePage {
cy.clickSubmitButton("Update");
}

clickSubmit() {
cy.get("#submit").click();
}
typeDateOfBirth(dob: string) {
cy.clickAndTypeDate("#date_of_birth", dob);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Routers/routes/UserRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ManageUsers from "@/components/Users/ManageUsers";
import UserAdd from "@/components/Users/UserAdd";
import UserHome from "@/components/Users/UserHome";
import UserProfile from "@/components/Users/UserProfile";

import { AppRoutes } from "@/Routers/AppRouter";

Expand All @@ -14,7 +13,7 @@ const UserRoutes: AppRoutes = {
"/users/:username/:tab": ({ username, tab }) => (
<UserHome username={username} tab={tab} />
),
"/user/profile": () => <UserProfile />,
"/user/:tab": ({ tab }) => <UserHome tab={tab} />,
};

export default UserRoutes;
10 changes: 8 additions & 2 deletions src/components/Users/UserHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default function UserHome(props: UserHomeProps) {
if (!username) {
username = authUser.username;
}
const loggedInUser = username === authUser.username;
const urlPrefix = loggedInUser ? "/user" : `/users/${username}`;

const { loading, refetch: refetchUserDetails } = useQuery(
routes.getUserDetails,
Expand Down Expand Up @@ -96,7 +98,11 @@ export default function UserHome(props: UserHomeProps) {
<>
<Page
title={formatName(userData) || userData.username || t("manage_user")}
crumbsReplacements={{ [username]: { name: username } }}
crumbsReplacements={
loggedInUser
? { [username]: { name: "Profile" } }
: { [username]: { name: username } }
}
focusOnLoad={true}
backUrl="/users"
hideTitleOnPage
Expand All @@ -123,7 +129,7 @@ export default function UserHome(props: UserHomeProps) {
? "border-b-2 border-primary-500 text-primary-600 hover:border-secondary-300"
: "text-secondary-700 hover:text-secondary-700",
)}
href={`/users/${username}/${p.toLocaleLowerCase()}`}
href={`${urlPrefix}/${p.toLocaleLowerCase()}`}
>
<div className="px-3 py-1.5" id={p.toLowerCase()}>
{t(`USERMANAGEMENT_TAB__${p}`)}
Expand Down
Loading

0 comments on commit d6c8a25

Please sign in to comment.