import UserListingPage from "../pages/UserListing" ; import LoginPage from "../pages/Login" ; import * as Chance from "chance" ; const random = new Chance ( ) ; describe ( "Admin user" , ( ) => { beforeEach ( ( ) => { const loginPage = new LoginPage ( ) ; loginPage . visit ( ) ; loginPage . loginAsAdmin ( ) ; } ) ; it ( "can create a new user, change its role, and remove it" , ( ) => { const userListingPage = new UserListingPage ( ) ; userListingPage . visit ( ) ; const addUsersPage = userListingPage . goToAddUser ( ) ; const username = random . word ( ) ; const userEmail = username . concat ( "@example.com" ) ; addUsersPage . fillEmailAddress ( userEmail ) ; addUsersPage . selectAdminRole ( ) ; addUsersPage . submit ( ) ; userListingPage . verifyUser ( username , userEmail , "Admin" ) ; const changeUsersRolePage = userListingPage . goToChangeRole ( username ) ; changeUsersRolePage . verifyEmailAddress ( userEmail ) ; changeUsersRolePage . selectEditorRole ( ) ; changeUsersRolePage . submit ( ) ; userListingPage . verifyUser ( username , userEmail , "Editor" ) ; userListingPage . removeUser ( username ) ; cy . contains ( "Successfully removed 1 user." ) ; } ) ; } ) ;