fix(ui): User popover card team redirection issue (#22531)

* fix user popover card team redirection issue

* added test
This commit is contained in:
Shrushti Polekar 2025-08-01 19:50:04 +05:30 committed by GitHub
parent 070c04b570
commit c3b51526dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 59 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import { formatDateTime } from '../../../../utils/date-time/DateTimeUtils';
import { getEntityName } from '../../../../utils/EntityUtils';
import { useActivityFeedProvider } from '../../../ActivityFeed/ActivityFeedProvider/ActivityFeedProvider';
import { OwnerType } from '../../../../enums/user.enum';
import { OwnerLabel } from '../../../common/OwnerLabel/OwnerLabel.component';
import UserPopOverCard from '../../../common/PopOverCard/UserPopOverCard';
import ProfilePicture from '../../../common/ProfilePicture/ProfilePicture';
@ -146,7 +147,9 @@ 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].name ?? ''}>
<UserPopOverCard
type={thread?.task?.assignees[0]?.type as OwnerType}
userName={thread?.task?.assignees[0].name ?? ''}>
<div className="d-flex items-center">
<ProfilePicture
name={thread?.task?.assignees[0].name ?? ''}

View File

@ -249,6 +249,56 @@ describe('Test UserPopOverCard components', () => {
expect(screen.getByText('testUser')).toBeInTheDocument();
expect(screen.queryByText('Test User')).not.toBeInTheDocument();
});
it('should navigate to team details path when type is TEAM', () => {
const mockNavigate = jest.fn();
(useNavigate as jest.Mock).mockImplementationOnce(() => mockNavigate);
(useUserProfile as jest.Mock).mockImplementation(() => [
null,
null,
{ name: 'testTeam', displayName: 'Test Team' },
]);
render(
<PopoverTitle
profilePicture={<div>ProfilePicture</div>}
type={OwnerType.TEAM}
userName="testTeam"
/>
);
const teamNameButton = screen.getByText('Test Team');
teamNameButton.click();
expect(mockNavigate).toHaveBeenCalledWith(
'/settings/members/teams/testTeam'
);
expect(mockNavigate).not.toHaveBeenCalledWith('/users/testTeam');
});
it('should navigate to user profile path when type is USER', () => {
const mockNavigate = jest.fn();
(useNavigate as jest.Mock).mockImplementationOnce(() => mockNavigate);
(useUserProfile as jest.Mock).mockImplementation(() => [
null,
null,
{ name: 'testUser', displayName: 'Test User' },
]);
render(
<PopoverTitle
profilePicture={<div>ProfilePicture</div>}
type={OwnerType.USER}
userName="testUser"
/>
);
const userNameButton = screen.getByText('Test User');
userNameButton.click();
expect(mockNavigate).toHaveBeenCalledWith('/users/testUser');
});
});
describe('UserPopOverCard Component', () => {

View File

@ -210,7 +210,11 @@ export const PopoverTitle = React.memo(
type="link"
onClick={(e) => {
e.stopPropagation();
onTitleClickHandler(getUserPath(name));
onTitleClickHandler(
type === OwnerType.TEAM
? getTeamAndUserDetailsPath(name)
: getUserPath(name)
);
}}>
<span className="font-medium m-r-xs" data-testid="user-name">
{displayName}