mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-25 14:38:29 +00:00
fix(ui): User popover card team redirection issue (#22531)
* fix user popover card team redirection issue * added test
This commit is contained in:
parent
070c04b570
commit
c3b51526dd
@ -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 ?? ''}
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user