@ -1,27 +1,32 @@
import filterTests from "../support/filterTests"
const interact = require ( '../support/interact' )
import filterTests from "../../ support/filterTests"
const interact = require ( '../../ support/interact' )
filterTests ( [ "smoke" , "all" ] , ( ) => {
context ( "Create a User and Assign Roles " , ( ) => {
context ( "User Management " , ( ) => {
before ( ( ) => {
cy . login ( )
cy . deleteApp ( "Cypress Tests" )
cy . createApp ( "Cypress Tests" )
} )
it ( "should create a user" , ( ) => {
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` )
cy . wait ( 1000 )
it ( "should create a user via basic onboarding" , ( ) => {
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` , { timeout : 1000 } )
cy . createUser ( "bbuser@test.com" )
cy . get ( interact . SPECTRUM_TABLE ) . should ( "contain" , "bbuser" )
} )
it ( "should confirm there is No Access for a New User" , ( ) => {
// Click into the user
it ( "should confirm basic permission for a New User" , ( ) => {
// Basic permission = development & administraton disabled
cy . contains ( "bbuser" ) . click ( )
// Get No Access table - Confirm it has apps in it
// Confirm development and admin access are disabled
for ( let i = 4 ; i < 6 ; i ++ ) {
cy . get ( interact . FIELD ) . eq ( i ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_SWITCH_INPUT ) . should ( 'be.disabled' )
} )
}
// Existing apps appear within the No Access table
cy . get ( interact . SPECTRUM_TABLE , { timeout : 500 } ) . eq ( 1 ) . should ( "not.contain" , "No rows found" )
// Get Configure Roles table - Confirm it has no apps
// Configure roles table should not contain apps
cy . get ( interact . SPECTRUM_TABLE ) . eq ( 0 ) . contains ( "No rows found" )
} )
@ -46,12 +51,9 @@ filterTests(["smoke", "all"], () => {
}
} )
// Navigate back to the user
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` )
cy . wait ( 500 )
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` , { timeout : 500 } )
cy . get ( interact . SPECTRUM_SIDENAV ) . contains ( "Users" ) . click ( )
cy . wait ( 500 )
cy . get ( interact . SPECTRUM_TABLE ) . contains ( "bbuser" ) . click ( )
cy . wait ( 1000 )
cy . get ( interact . SPECTRUM_TABLE , { timeout : 500 } ) . contains ( "bbuser" ) . click ( )
for ( let i = 0 ; i < 3 ; i ++ ) {
cy . get ( interact . SPECTRUM_TABLE , { timeout : 3000 } )
. eq ( 1 )
@ -60,31 +62,27 @@ filterTests(["smoke", "all"], () => {
. find ( interact . SPECTRUM_TABLE_CELL )
. eq ( 0 )
. click ( )
cy . wait ( 500 )
cy . get ( interact . SPECTRUM_DIALOG_GRID )
cy . get ( interact . SPECTRUM_DIALOG_GRID , { timeout : 500 } )
. contains ( "Choose an option" )
. click ( )
. then ( ( ) => {
cy . wait ( 1000 )
if ( i == 0 ) {
cy . get ( interact . SPECTRUM_MENU ) . contains ( "Admin" ) . click ( { force : true } )
cy . get ( interact . SPECTRUM_MENU , { timeout : 1000 } ) . contains ( "Admin" ) . click ( { force : true } )
}
else if ( i == 1 ) {
cy . get ( interact . SPECTRUM_MENU ) . contains ( "Power" ) . click ( { force : true } )
cy . get ( interact . SPECTRUM_MENU , { timeout : 1000 } ) . contains ( "Power" ) . click ( { force : true } )
}
else if ( i == 2 ) {
cy . get ( interact . SPECTRUM_MENU ) . contains ( "Basic" ) . click ( { force : true } )
cy . get ( interact . SPECTRUM_MENU , { timeout : 1000 } ) . contains ( "Basic" ) . click ( { force : true } )
}
cy . wait ( 1000 )
cy . get ( interact . SPECTRUM_BUTTON )
cy . get ( interact . SPECTRUM_BUTTON , { timeout : 1000 } )
. contains ( "Update role" )
. click ( { force : true } )
} )
cy . reload ( )
}
// Confirm roles exist within Configure roles table
cy . wait ( 2000 )
cy . get ( interact . SPECTRUM_TABLE )
cy . get ( interact . SPECTRUM_TABLE , { timeout : 2000 } )
. eq ( 0 )
. within ( assginedRoles => {
expect ( assginedRoles ) . to . contain ( "Admin" )
@ -110,21 +108,19 @@ filterTests(["smoke", "all"], () => {
. click ( )
. then ( ( ) => {
cy . get ( interact . SPECTRUM_PICKER ) . eq ( 1 ) . click ( { force : true } )
cy . wait ( 500 )
cy . get ( interact . SPECTRUM_POPOVER ) . contains ( "No Access" ) . click ( )
cy . get ( interact . SPECTRUM_POPOVER , { timeout : 500 } ) . contains ( "No Access" ) . click ( )
} )
cy . get ( interact . SPECTRUM_BUTTON )
. contains ( "Update role" )
. click ( { force : true } )
cy . wait ( 1000 )
}
} )
// Confirm Configure roles table no longer has any apps in it
cy . get ( interact . SPECTRUM_TABLE ) . eq ( 0 ) . contains ( "No rows found" )
cy . get ( interact . SPECTRUM_TABLE , { timeout : 1000 } ) . eq ( 0 ) . contains ( "No rows found" )
} )
}
it ( "should enable Developer access" , ( ) => {
it ( "should enable Developer access and verify application access " , ( ) => {
// Enable Developer access
cy . get ( interact . FIELD )
. eq ( 4 )
@ -156,15 +152,15 @@ filterTests(["smoke", "all"], () => {
} )
} )
it ( "should disable Developer access" , ( ) => {
it ( "should disable Developer access and verify application access " , ( ) => {
// Disable Developer access
cy . get ( ".field" )
cy . get ( interact . FIELD )
. eq ( 4 )
. within ( ( ) => {
cy . get ( ".spectrum-Switch-input" ) . click ( { force : true } )
} )
// Configure roles table should now be empty
cy . get ( ".container" )
cy . get ( interact . CONTAINER )
. contains ( "Configure roles" )
. parent ( )
. within ( ( ) => {
@ -172,45 +168,75 @@ filterTests(["smoke", "all"], () => {
} )
} )
it ( "Should edit user details" , ( ) => {
it ( "Should edit user details within user details page " , ( ) => {
// Add First name
cy . get ( ".field" ) . eq ( 2 ) . within ( ( ) => {
cy . get ( interact . FIELD , { timeout : 500 } ) . eq ( 2 ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . type ( "bb" )
} )
// Add Last name
cy . get ( ".field" ) . eq ( 3 ) . within ( ( ) => {
cy . get ( interact . FIELD ) . eq ( 3 ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . type ( "test" )
} )
// Navigate away and back to the user
cy . contains ( "Apps" ) . click ( )
cy . contains ( "Users" ) . click ( )
cy . contains ( "bbuser" ) . click ( )
// Reload page
cy . reload ( )
// Confirm details have been saved
cy . get ( ".field" ) . eq ( 2 ) . within ( ( ) => {
cy . get ( interact . FIELD , { timeout : 1000 } ) . eq ( 2 ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . should ( 'have.value' , "bb" )
} )
cy . get ( ".field" ) . eq ( 3 ) . within ( ( ) => {
cy . get ( interact . FIELD ) . eq ( 3 ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . should ( 'have.value' , "test" )
} )
} )
it ( "should reset the users password" , ( ) => {
cy . get ( interact . REGENERATE , { timeout : 500 } ) . click ( { force : true } )
// Reset password modal
const newPwd = cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . its ( 'value' )
cy . get ( interact . SPECTRUM_BUTTON ) . contains ( "Reset password" ) . click ( { force : true } )
// Logout, then login with new password
cy . logOut ( )
cy . login ( "bbuser@test.com" , newPwd )
// Reset password screen
for ( let i = 0 ; i < 2 ; i ++ ) {
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . eq ( i ) . type ( "test" )
}
cy . get ( interact . SPECTRUM_BUTTON ) . contains ( "Reset your password" ) . click ( { force : true } )
// Confirm user logged in afer password change
cy . get ( ".user-dropdown .avatar > .icon" ) . click ( { force : true } )
cy . get ( ".spectrum-Popover[data-cy='user-menu']" ) . within ( ( ) => {
cy . get ( "li[data-cy='user-info']" ) . click ( { force : true } )
} )
cy . get ( interact . SPECTRUM_TEXTFIELD_INPUT ) . its ( 'value' ) . should ( 'eq' , 'bbuser@test.com' )
// Logout and login as previous user
cy . logOut ( )
cy . login ( )
} )
it ( "should delete a user" , ( ) => {
// Navigate to test user
cy . contains ( "Users" ) . click ( )
cy . contains ( "bbuser" ) . click ( )
// Click Delete user button
cy . get ( interact . SPECTRUM_BUTTON )
. contains ( "Delete user" )
. click ( { force : true } )
. then ( ( ) => {
// Confirm deletion within modal
cy . wait ( 500 )
cy . get ( interact . SPECTRUM_DIALOG_GRID ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_DIALOG_GRID , { timeout : 500 } ) . within ( ( ) => {
cy . get ( interact . SPECTRUM_BUTTON )
. contains ( "Delete user" )
. click ( { force : true } )
cy . wait ( 4000 )
} )
} )
cy . get ( interact . SPECTRUM_TABLE ) . should ( "not.have.text" , "bbuser" )
cy . get ( interact . SPECTRUM_TABLE , { timeout : 4000 } ) . should ( "not.have.text" , "bbuser" )
} )
} )
} )