@@ -486,6 +486,7 @@ describe('TableCells Components', () => {
486486 org : 'Test Org' ,
487487 scope : 'Test Scope' ,
488488 permissionCount : 1 ,
489+ canManageScope : true ,
489490 } ,
490491 } ;
491492
@@ -497,7 +498,6 @@ describe('TableCells Components', () => {
497498 const user = userEvent . setup ( ) ;
498499 const CustomActionsCell = createActionsCell ( {
499500 onClickDeleteButton : mockOnClickDeleteButton ,
500- hasPermissionToDeleteScope : ( ) => true ,
501501 isUserAuthenticatedPage : false ,
502502 } ) ;
503503 renderWrapper ( < CustomActionsCell row = { baseRow } column = { { id : 'actions' } } /> ) ;
@@ -509,7 +509,7 @@ describe('TableCells Components', () => {
509509 expect ( mockOnClickDeleteButton ) . toHaveBeenCalledWith ( { name : 'Library Admin' , role : 'library_admin' , scope : 'Test Scope' } ) ;
510510 } ) ;
511511
512- it ( 'renders a disabled button for admin roles when isUserAuthenticatedPage is true' , ( ) => {
512+ it ( 'renders a disabled delete icon for admin roles when isUserAuthenticatedPage is true' , ( ) => {
513513 const adminRow = {
514514 original : {
515515 role : 'course_admin' ,
@@ -521,12 +521,32 @@ describe('TableCells Components', () => {
521521 const CustomActionsCell = createActionsCell ( {
522522 onClickDeleteButton : mockOnClickDeleteButton ,
523523 isUserAuthenticatedPage : true ,
524- hasPermissionToDeleteScope : ( ) => true ,
525524 } ) ;
526525 renderWrapper ( < CustomActionsCell row = { adminRow } column = { { id : 'actions' } } /> ) ;
527526
528- const button = screen . getByRole ( 'button' , { name : / d e l e t e r o l e a c t i o n / i } ) ;
529- expect ( button ) . toBeDisabled ( ) ;
527+ const infoIcon = screen . getByRole ( 'img' , { hidden : true } ) ;
528+ expect ( infoIcon ) . toBeInTheDocument ( ) ;
529+ } ) ;
530+
531+ it ( 'renders a tooltip when hovering over delete icon for admin roles when isUserAuthenticatedPage is true' , async ( ) => {
532+ const adminRow = {
533+ original : {
534+ role : 'course_admin' ,
535+ org : 'Test Org' ,
536+ scope : 'Test Scope' ,
537+ permissionCount : 1 ,
538+ } ,
539+ } ;
540+ const user = userEvent . setup ( ) ;
541+ const CustomActionsCell = createActionsCell ( {
542+ onClickDeleteButton : mockOnClickDeleteButton ,
543+ isUserAuthenticatedPage : true ,
544+ } ) ;
545+ renderWrapper ( < CustomActionsCell row = { adminRow } column = { { id : 'actions' } } /> ) ;
546+
547+ const infoIcon = screen . getByRole ( 'img' , { hidden : true } ) ;
548+ await user . hover ( infoIcon ) ;
549+ expect ( screen . getByText ( / Y o u c a n ’ t r e m o v e y o u r o w n a d m i n r o l e / i) ) . toBeInTheDocument ( ) ;
530550 } ) ;
531551
532552 it ( 'renders info icon with tooltip for Django managed roles' , async ( ) => {
@@ -541,7 +561,6 @@ describe('TableCells Components', () => {
541561 const user = userEvent . setup ( ) ;
542562 const CustomActionsCell = createActionsCell ( {
543563 onClickDeleteButton : mockOnClickDeleteButton ,
544- hasPermissionToDeleteScope : ( ) => true ,
545564 isUserAuthenticatedPage : true ,
546565 } ) ;
547566 renderWrapper ( < CustomActionsCell row = { djangoRow } column = { { id : 'actions' } } /> ) ;
@@ -556,9 +575,14 @@ describe('TableCells Components', () => {
556575 const CustomActionsCell = createActionsCell ( {
557576 onClickDeleteButton : mockOnClickDeleteButton ,
558577 isUserAuthenticatedPage : false ,
559- hasPermissionToDeleteScope : ( ) => false ,
560578 } ) ;
561- renderWrapper ( < CustomActionsCell row = { baseRow } column = { { id : 'actions' } } /> ) ;
579+ const customRow = {
580+ original : {
581+ ...baseRow ,
582+ canManageScope : false ,
583+ } ,
584+ } ;
585+ renderWrapper ( < CustomActionsCell row = { customRow } column = { { id : 'actions' } } /> ) ;
562586
563587 const deleteButton = screen . queryByRole ( 'button' , { name : / d e l e t e r o l e a c t i o n / i } ) ;
564588 expect ( deleteButton ) . toBeDisabled ( ) ;
0 commit comments