fix profile redirection issue for displayname (#21624)

(cherry picked from commit d529c9fe9d990504abf74ded53356450cbedeec2)
This commit is contained in:
Shrushti Polekar 2025-06-06 19:59:47 +05:30 committed by OpenMetadata Release Bot
parent ec3eda8ae0
commit b60898daff
5 changed files with 37 additions and 16 deletions

View File

@ -310,11 +310,11 @@ const ActivityFeedCardNew = ({
) : (
<div className="d-flex gap-2">
<div>
<UserPopOverCard userName={getEntityName(currentUser)}>
<UserPopOverCard userName={currentUser?.name ?? ''}>
<div className="d-flex items-center">
<ProfilePicture
key={feed.id}
name={getEntityName(currentUser)}
name={currentUser?.name ?? ''}
width="32"
/>
</div>

View File

@ -958,20 +958,16 @@ export const TaskTabNew = ({
{taskThread?.task?.assignees?.length === 1 ? (
<div className="d-flex items-center gap-2">
<UserPopOverCard
userName={
taskThread?.task?.assignees[0].displayName ?? ''
}>
userName={taskThread?.task?.assignees[0].name ?? ''}>
<div className="d-flex items-center">
<ProfilePicture
name={
taskThread?.task?.assignees[0].displayName ?? ''
}
name={taskThread?.task?.assignees[0].name ?? ''}
width="24"
/>
</div>
</UserPopOverCard>
<Typography.Text className="text-grey-body">
{taskThread?.task?.assignees[0].displayName}
{getEntityName(taskThread?.task?.assignees[0])}
</Typography.Text>
</div>
) : (
@ -1132,11 +1128,11 @@ export const TaskTabNew = ({
taskThread?.task?.status === ThreadTaskStatus.Open && (
<div className="d-flex gap-2">
<div className="profile-picture">
<UserPopOverCard userName={getEntityName(currentUser)}>
<UserPopOverCard userName={currentUser?.name ?? ''}>
<div className="d-flex items-center">
<ProfilePicture
key={taskThread.id}
name={getEntityName(currentUser)}
name={currentUser?.name ?? ''}
width="32"
/>
</div>

View File

@ -145,17 +145,16 @@ const TaskTabIncidentManagerHeaderNew = ({ thread }: { thread: Thread }) => {
<Col className="flex items-center gap-2" span={16}>
{thread?.task?.assignees?.length === 1 ? (
<div className="d-flex items-center gap-2">
<UserPopOverCard
userName={thread?.task?.assignees[0].displayName ?? ''}>
<UserPopOverCard userName={thread?.task?.assignees[0].name ?? ''}>
<div className="d-flex items-center">
<ProfilePicture
name={thread?.task?.assignees[0].displayName ?? ''}
name={thread?.task?.assignees[0].name ?? ''}
width="24"
/>
</div>
</UserPopOverCard>
<Typography.Text className="text-grey-body">
{thread?.task?.assignees[0].displayName}
{getEntityName(thread?.task?.assignees[0])}
</Typography.Text>
</div>
) : (

View File

@ -239,7 +239,7 @@ const ProfileSectionUserDetailsCard = ({
</Popover>
<div className="m-t-sm">
<UserPopOverCard userName={getEntityName(userData)}>
<UserPopOverCard userName={userData?.name}>
<div className="d-flex items-center">
<ProfilePicture
data-testid="replied-user"

View File

@ -85,6 +85,11 @@ jest.mock('../ProfilePicture/ProfilePicture', () => {
return jest.fn().mockImplementation(() => <div>ProfilePicture</div>);
});
const mockPush = jest.fn();
(useHistory as jest.Mock).mockImplementation(() => ({
push: mockPush,
}));
describe('Test UserPopOverCard components', () => {
describe('UserTeams Component', () => {
it('should render teams when teams are available', () => {
@ -195,6 +200,27 @@ describe('Test UserPopOverCard components', () => {
expect(screen.getByText('testUser')).toBeInTheDocument();
});
it('should navigate using name instead of display name when clicking display name in tooltip', () => {
(useUserProfile as jest.Mock).mockImplementation(() => [
null,
null,
mockUserData,
]);
render(
<PopoverTitle
profilePicture={<div>ProfilePicture</div>}
type={OwnerType.USER}
userName="testUser"
/>
);
const displayNameButton = screen.getByText('Test User');
displayNameButton.click();
expect(mockPush).toHaveBeenCalledWith('/users/testUser');
});
it('should handle click on user name', () => {
const mockPush = jest.fn();
(useHistory as jest.Mock).mockImplementationOnce(() => ({