mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-11-03 20:19:31 +00:00 
			
		
		
		
	
							parent
							
								
									f5cbcd0ef0
								
							
						
					
					
						commit
						0639bdc083
					
				@ -11,7 +11,7 @@
 | 
			
		||||
 *  limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { findByTestId, render } from '@testing-library/react';
 | 
			
		||||
import { findByTestId, fireEvent, render } from '@testing-library/react';
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import { MemoryRouter } from 'react-router-dom';
 | 
			
		||||
import UserCard from './UserCard';
 | 
			
		||||
@ -101,4 +101,25 @@ describe('Test userCard component', () => {
 | 
			
		||||
    expect(svgIcon).toBeInTheDocument();
 | 
			
		||||
    expect(datasetLink).toBeInTheDocument();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('If isOwner is passed it should allow delete action', async () => {
 | 
			
		||||
    const { container } = render(
 | 
			
		||||
      <UserCard
 | 
			
		||||
        isActionVisible
 | 
			
		||||
        isOwner
 | 
			
		||||
        item={mockItem}
 | 
			
		||||
        onRemove={mockRemove}
 | 
			
		||||
      />,
 | 
			
		||||
      {
 | 
			
		||||
        wrapper: MemoryRouter,
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const remove = await findByTestId(container, 'remove');
 | 
			
		||||
 | 
			
		||||
    fireEvent.click(remove);
 | 
			
		||||
 | 
			
		||||
    expect(remove).toBeInTheDocument();
 | 
			
		||||
    expect(mockRemove).toBeCalled();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -42,6 +42,7 @@ interface Props {
 | 
			
		||||
  isIconVisible?: boolean;
 | 
			
		||||
  isDataset?: boolean;
 | 
			
		||||
  isCheckBoxes?: boolean;
 | 
			
		||||
  isOwner?: boolean;
 | 
			
		||||
  onSelect?: (value: string) => void;
 | 
			
		||||
  onRemove?: (value: string) => void;
 | 
			
		||||
}
 | 
			
		||||
@ -52,6 +53,7 @@ const UserCard = ({
 | 
			
		||||
  isIconVisible = false,
 | 
			
		||||
  isDataset = false,
 | 
			
		||||
  isCheckBoxes = false,
 | 
			
		||||
  isOwner = false,
 | 
			
		||||
  onSelect,
 | 
			
		||||
  onRemove,
 | 
			
		||||
}: Props) => {
 | 
			
		||||
@ -202,6 +204,7 @@ const UserCard = ({
 | 
			
		||||
          ) : (
 | 
			
		||||
            <NonAdminAction
 | 
			
		||||
              html={<>You do not have permission to update the team.</>}
 | 
			
		||||
              isOwner={isOwner}
 | 
			
		||||
              permission={Operation.UpdateTeam}
 | 
			
		||||
              position="bottom">
 | 
			
		||||
              <span
 | 
			
		||||
@ -209,6 +212,7 @@ const UserCard = ({
 | 
			
		||||
                  'tw-opacity-40':
 | 
			
		||||
                    !isAdminUser &&
 | 
			
		||||
                    !isAuthDisabled &&
 | 
			
		||||
                    !isOwner &&
 | 
			
		||||
                    !userPermissions[Operation.UpdateTeam],
 | 
			
		||||
                })}
 | 
			
		||||
                data-testid="remove"
 | 
			
		||||
 | 
			
		||||
@ -439,6 +439,7 @@ const TeamsPage = () => {
 | 
			
		||||
          <p>There are no users added yet.</p>
 | 
			
		||||
          {isAdminUser ||
 | 
			
		||||
          isAuthDisabled ||
 | 
			
		||||
          isOwner() ||
 | 
			
		||||
          userPermissions[Operation.UpdateTeam] ? (
 | 
			
		||||
            <>
 | 
			
		||||
              <p>Would like to start adding some?</p>
 | 
			
		||||
@ -476,6 +477,7 @@ const TeamsPage = () => {
 | 
			
		||||
              <UserCard
 | 
			
		||||
                isActionVisible
 | 
			
		||||
                isIconVisible
 | 
			
		||||
                isOwner={isOwner()}
 | 
			
		||||
                item={User}
 | 
			
		||||
                key={index}
 | 
			
		||||
                onRemove={deleteUserHandler}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user