diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTabIncidentManagerHeader/TasktabIncidentManagerHeaderNew.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTabIncidentManagerHeader/TasktabIncidentManagerHeaderNew.tsx index e8c2d1ad2d0..b100909991b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTabIncidentManagerHeader/TasktabIncidentManagerHeaderNew.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTabIncidentManagerHeader/TasktabIncidentManagerHeaderNew.tsx @@ -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 }) => { {thread?.task?.assignees?.length === 1 ? (
- +
{ 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( + ProfilePicture
} + 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( + ProfilePicture
} + type={OwnerType.USER} + userName="testUser" + /> + ); + + const userNameButton = screen.getByText('Test User'); + userNameButton.click(); + + expect(mockNavigate).toHaveBeenCalledWith('/users/testUser'); + }); }); describe('UserPopOverCard Component', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/UserPopOverCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/UserPopOverCard.tsx index c104c095d1f..27d9389c287 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/UserPopOverCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/UserPopOverCard.tsx @@ -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) + ); }}> {displayName}