2022-02-09 11:46:58 +00:00
import ListingPage from "../support/pages/admin_console/ListingPage" ;
import UserRegistration , {
GroupPickerDialog ,
} from "../support/pages/admin_console/manage/realm_settings/UserRegistration" ;
import Masthead from "../support/pages/admin_console/Masthead" ;
import SidebarPage from "../support/pages/admin_console/SidebarPage" ;
import LoginPage from "../support/pages/LoginPage" ;
2022-02-24 10:31:46 +00:00
import adminClient from "../support/util/AdminClient" ;
2022-03-09 16:42:51 +00:00
import { keycloakBefore } from "../support/util/keycloak_hooks" ;
2022-02-16 16:34:54 +00:00
import ModalUtils from "../support/util/ModalUtils" ;
2022-02-09 11:46:58 +00:00
describe ( "Realm settings - User registration tab" , ( ) = > {
const loginPage = new LoginPage ( ) ;
const sidebarPage = new SidebarPage ( ) ;
2022-02-16 16:34:54 +00:00
const modalUtils = new ModalUtils ( ) ;
2022-02-09 11:46:58 +00:00
const masthead = new Masthead ( ) ;
const listingPage = new ListingPage ( ) ;
const groupPicker = new GroupPickerDialog ( ) ;
const userRegistration = new UserRegistration ( ) ;
const groupName = "The default group" ;
before ( ( ) = > {
adminClient . createGroup ( groupName ) ;
keycloakBefore ( ) ;
loginPage . logIn ( ) ;
} ) ;
beforeEach ( ( ) = > {
sidebarPage . goToRealmSettings ( ) ;
userRegistration . goToTab ( ) ;
} ) ;
after ( ( ) = > adminClient . deleteGroups ( ) ) ;
2022-02-16 16:34:54 +00:00
it ( "Add admin role" , ( ) = > {
2022-02-09 11:46:58 +00:00
const role = "admin" ;
2022-02-16 16:34:54 +00:00
userRegistration . addRole ( ) ;
sidebarPage . waitForPageLoad ( ) ;
2022-02-09 11:46:58 +00:00
userRegistration . selectRow ( role ) . assign ( ) ;
masthead . checkNotificationMessage ( "Associated roles have been added" ) ;
listingPage . searchItem ( role , false ) . itemExist ( role ) ;
} ) ;
2022-02-16 16:34:54 +00:00
it ( "Remove admin role" , ( ) = > {
const role = "admin" ;
listingPage . markItemRow ( role ) . removeMarkedItems ( ) ;
sidebarPage . waitForPageLoad ( ) ;
modalUtils
. checkModalTitle ( "Remove associated roles?" )
. checkModalMessage (
"This action will remove the associated roles of default-roles-master. Users who have permission to default-roles-master will no longer have access to these roles."
)
. checkConfirmButtonText ( "Remove" )
. confirmModal ( ) ;
masthead . checkNotificationMessage ( "Associated roles have been removed" ) ;
} ) ;
it ( "Add default group" , ( ) = > {
userRegistration . goToDefaultGroupTab ( ) . addDefaultGroup ( ) ;
2022-02-09 11:46:58 +00:00
groupPicker . checkTitle ( "Add default groups" ) . clickRow ( groupName ) . clickAdd ( ) ;
masthead . checkNotificationMessage ( "New group added to the default groups" ) ;
listingPage . itemExist ( groupName ) ;
} ) ;
} ) ;