import selectors from "../utils/selectors" ; import AddUsersPage from "./AddUsers" ; import ChangeUsersRolePage from "./ChangeUsersRole" ; class UserListing { visit ( ) { cy . intercept ( { method : "GET" , url : "/prod/user" , } ) . as ( "listUsersRequest" ) ; cy . get ( selectors . navBar ) . get ( "a" ) . contains ( "Manage users" ) . click ( ) ; cy . wait ( [ "@listUsersRequest" ] ) ; } goToAddUser ( ) { cy . get ( "button" ) . contains ( "Add user(s)" ) . click ( ) ; return new AddUsersPage ( ) ; } verifyUser ( username , userEmail , role ) { cy . findByRole ( "searchbox" ) . type ( username ) ; cy . get ( "form[role='search']" ) . submit ( ) ; cy . contains ( "tr" , userEmail ) . contains ( "tr" , username ) . contains ( "tr" , role ) . contains ( "FORCE_CHANGE_PASSWORD" ) ; cy . findByRole ( "searchbox" ) . clear ( ) ; cy . get ( "form[role='search']" ) . submit ( ) ; } goToChangeRole ( username ) { cy . findByRole ( "searchbox" ) . type ( username ) ; cy . get ( "form[role='search']" ) . submit ( ) ; cy . get ( `input[title="${ username }"]` ) . click ( { force : true , multiple : true , } ) ; cy . get ( "button" ) . contains ( "Actions" ) . click ( ) ; cy . findByRole ( "menuitem" , { name : "Change role" } ) . click ( ) ; return new ChangeUsersRolePage ( ) ; } removeUser ( username ) { cy . findByRole ( "searchbox" ) . type ( username ) ; cy . get ( "form[role='search']" ) . submit ( ) ; cy . get ( `input[title="${ username }"]` ) . click ( { force : true , multiple : true , } ) ; cy . get ( "button" ) . contains ( "Actions" ) . click ( ) ; cy . findByRole ( "menuitem" , { name : "Remove users" } ) . click ( ) ; cy . intercept ( { method : "DELETE" , url : "/prod/user" , } ) . as ( "deleteUsersRequest" ) ; cy . intercept ( { method : "GET" , url : "/prod/user" , } ) . as ( "listUsersRequest" ) ; cy . get ( "button" ) . contains ( "Delete" ) . click ( ) ; cy . wait ( [ "@deleteUsersRequest" , "@listUsersRequest" ] ) ; } } export default UserListing ;