@@ -439,6 +439,103 @@ describe("<FormUserManage>", () => {
439439 ) . not . toBeInTheDocument ( )
440440 } )
441441 } )
442+
443+ describe ( "enableSupportAdmin" , ( ) => {
444+ it ( "should not show support admin role when feature flag not enabled" , async ( ) => {
445+ const adminUserWithJurisdictionsAndAllDisabled = {
446+ ...adminUser ,
447+ jurisdictions : [
448+ {
449+ id : "jurisdiction1" ,
450+ name : "jurisdictionWithoutSupportAdmin" ,
451+ } ,
452+ {
453+ id : "jurisdiction2" ,
454+ name : "jurisdictionWithoutSupportAdmin2" ,
455+ } ,
456+ ] ,
457+ }
458+ server . use (
459+ rest . get ( "http://localhost/api/adapter/user" , ( _req , res , ctx ) => {
460+ return res ( ctx . json ( adminUserWithJurisdictionsAndAllDisabled ) )
461+ } ) ,
462+ rest . post ( "http://localhost/api/adapter/user/invite" , ( _req , res , ctx ) => {
463+ return res ( ctx . json ( { success : true } ) )
464+ } )
465+ )
466+ const onCancel = jest . fn ( )
467+ const onDrawerClose = jest . fn ( )
468+ document . cookie = "access-token-available=True"
469+
470+ render (
471+ < FormUserManage
472+ isOpen = { true }
473+ title = { t ( "users.addUser" ) }
474+ mode = { "add" }
475+ listings = { [ ] }
476+ onCancel = { onCancel }
477+ onDrawerClose = { onDrawerClose }
478+ />
479+ )
480+
481+ await waitFor ( ( ) => screen . getByText ( "Administrator" ) )
482+ expect ( screen . getByText ( "Add user" ) ) . toBeInTheDocument ( )
483+ expect ( screen . getByText ( "User details" ) ) . toBeInTheDocument ( )
484+ // "Role" select should not have Support Admin
485+ expect ( screen . getByRole ( "combobox" , { name : "Role" } ) ) . toBeInTheDocument ( )
486+ expect ( screen . getByRole ( "option" , { name : "Administrator" } ) ) . toBeInTheDocument ( )
487+ expect ( screen . getByRole ( "option" , { name : "Partner" } ) ) . toBeInTheDocument ( )
488+ expect ( screen . queryByRole ( "option" , { name : "Admin (support)" } ) ) . not . toBeInTheDocument ( )
489+ } )
490+
491+ it ( "should show support admin role when feature flag enabled" , async ( ) => {
492+ const adminUserWithJurisdictionsAndOneEnabled = {
493+ ...adminUser ,
494+ jurisdictions : [
495+ {
496+ id : "jurisdiction1" ,
497+ name : "jurisdictionWithSupportAdmin" ,
498+ } ,
499+ {
500+ id : "jurisdiction2" ,
501+ name : "jurisdictionWithSupportAdmin2" ,
502+ featureFlags : [ { name : FeatureFlagEnum . enableSupportAdmin , active : true } ] ,
503+ } ,
504+ ] ,
505+ }
506+ server . use (
507+ rest . get ( "http://localhost/api/adapter/user" , ( _req , res , ctx ) => {
508+ return res ( ctx . json ( adminUserWithJurisdictionsAndOneEnabled ) )
509+ } ) ,
510+ rest . post ( "http://localhost/api/adapter/user/invite" , ( _req , res , ctx ) => {
511+ return res ( ctx . json ( { success : true } ) )
512+ } )
513+ )
514+ const onCancel = jest . fn ( )
515+ const onDrawerClose = jest . fn ( )
516+ document . cookie = "access-token-available=True"
517+
518+ render (
519+ < FormUserManage
520+ isOpen = { true }
521+ title = { t ( "users.addUser" ) }
522+ mode = { "add" }
523+ listings = { [ ] }
524+ onCancel = { onCancel }
525+ onDrawerClose = { onDrawerClose }
526+ />
527+ )
528+
529+ await waitFor ( ( ) => screen . getByText ( "Administrator" ) )
530+ expect ( screen . getByText ( "Add user" ) ) . toBeInTheDocument ( )
531+ expect ( screen . getByText ( "User details" ) ) . toBeInTheDocument ( )
532+ // "Role" select should not Support Admin
533+ expect ( screen . getByRole ( "combobox" , { name : "Role" } ) ) . toBeInTheDocument ( )
534+ expect ( screen . queryByRole ( "option" , { name : "Admin (support)" } ) ) . toBeInTheDocument ( )
535+ expect ( screen . getByRole ( "option" , { name : "Administrator" } ) ) . toBeInTheDocument ( )
536+ expect ( screen . getByRole ( "option" , { name : "Partner" } ) ) . toBeInTheDocument ( )
537+ } )
538+ } )
442539 } )
443540
444541 describe ( "Edit User" , ( ) => {
0 commit comments