Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-22 17:07:38 +01:00
parent 43ff43f5cf
commit aaf7e69322

View file

@ -4,381 +4,254 @@ require 'browser_test_helper'
class SignupPasswordChangeAndResetTest < TestCase class SignupPasswordChangeAndResetTest < TestCase
def test_signup def test_signup
signup_user_email = 'signup-test-' + rand(999999).to_s + '@example.com' signup_user_email = 'signup-test-' + rand(999999).to_s + '@example.com'
tests = [ @browser = browser_instance
{ location( :url => browser_url )
:name => 'start', click( :css => 'a[href="#signup"]' )
:instance => browser_instance, exists( :css => '.signup' )
:url => browser_url,
:action => [
{
:execute => 'click',
:css => 'a[href="#signup"]',
},
{
:execute => 'check',
:css => '.signup',
:result => true,
},
],
},
{
:name => 'signup',
:action => [
{
:execute => 'set',
:css => 'input[name="firstname"]',
:value => 'Signup Firstname',
},
{
:execute => 'set',
:css => 'input[name="lastname"]',
:value => 'Signup Lastname',
},
{
:execute => 'set',
:css => 'input[name="email"]',
:value => signup_user_email,
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'some-pass',
},
{
:execute => 'set',
:css => 'input[name="password_confirm"]',
:value => 'some-pass',
},
{
:execute => 'click',
:css => 'button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.signup',
:result => false,
},
{
:execute => 'match',
:css => '.user-menu .user a',
:attribute => 'title',
:value => signup_user_email,
:match_result => true,
},
],
},
{
:name => 'set password',
:action => [
{
:execute => 'click',
:css => '.navbar-items-personal .user a',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => 'a[href="#profile"]',
},
{
:execute => 'click',
:css => 'a[href="#profile/password"]',
},
{
:execute => 'set',
:css => 'input[name="password_old"]',
:value => 'nonexisiting',
},
{
:execute => 'set',
:css => 'input[name="password_new"]',
:value => 'some',
},
{
:execute => 'set',
:css => 'input[name="password_new_confirm"]',
:value => 'some',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'current password is wrong',
},
{
:execute => 'set',
:css => 'input[name="password_old"]',
:value => 'some-pass',
},
{
:execute => 'set',
:css => 'input[name="password_new_confirm"]',
:value => 'some2',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'passwords do not match',
},
{
:execute => 'set',
:css => 'input[name="password_new"]',
:value => 'some',
},
{
:execute => 'set',
:css => 'input[name="password_new_confirm"]',
:value => 'some',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'it must be at least',
},
{
:execute => 'set',
:css => 'input[name="password_new"]',
:value => 'some-pass-new',
},
{
:execute => 'set',
:css => 'input[name="password_new_confirm"]',
:value => 'some-pass-new',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'must contain at least 1 digit',
},
{
:execute => 'set',
:css => 'input[name="password_new"]',
:value => 'some-pass-new2',
},
{
:execute => 'set',
:css => 'input[name="password_new_confirm"]',
:value => 'some-pass-new2',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Password changed successfully',
},
{
:execute => 'logout',
},
{
:execute => 'login',
:username => signup_user_email,
:password => 'some-pass-new2',
},
{
:execute => 'logout',
},
],
},
{
:name => 'reset password (not possible)',
:action => [
# got to wrong url
{
:execute => 'navigate',
:to => browser_url + '/#password_reset_verify/not_existing_token',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Token is invalid',
},
# with valid session
{
:execute => 'navigate',
:to => browser_url + '/#',
},
{
:execute => 'login',
:username => signup_user_email,
:password => 'some-pass-new2',
},
{
:execute => 'navigate',
:to => browser_url + '/#password_reset',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => 'body',
:value => 'password',
:match_result => false,
},
{
:execute => 'logout',
},
],
},
{
:name => 'reset password (correct way)',
:action => [
{
:execute => 'click',
:css => 'a[href="#password_reset"]',
},
{
:execute => 'set',
:css => 'input[name="username"]',
:value => 'nonexisiting',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'address invalid',
},
{
:execute => 'set',
:css => 'input[name="username"]',
:value => signup_user_email,
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'sent password reset instructions',
},
# redirect to "#password_reset_verify/#{token}" url by app, because of "developer_mode" # signup
{ set(
:execute => 'watch_for', :css => 'input[name="firstname"]',
:area => 'body', :value => 'Signup Firstname',
:value => 'Choose your new password', )
}, set(
:css => 'input[name="lastname"]',
:value => 'Signup Lastname',
)
set(
:css => 'input[name="email"]',
:value => signup_user_email,
)
set(
:css => 'input[name="password"]',
:value => 'some-pass',
)
set(
:css => 'input[name="password_confirm"]',
:value => 'some-pass',
)
click( :css => 'button.submit' )
sleep 5
result = exists( :css => '.signup' )
assert( !result, ".signup still exists" )
match(
:css => '.user-menu .user a',
:value => signup_user_email,
:attribute => 'title',
)
# change password
click( :css => '.navbar-items-personal .user a' )
sleep 1
click( :css => 'a[href="#profile"]' )
click( :css => 'a[href="#profile/password"]' )
set(
:css => 'input[name="password_old"]',
:value => 'nonexisiting',
)
set(
:css => 'input[name="password_new"]',
:value => 'some',
)
set(
:css => 'input[name="password_new_confirm"]',
:value => 'some',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'current password is wrong',
)
set(
:css => 'input[name="password_old"]',
:value => 'some-pass',
)
set(
:css => 'input[name="password_new_confirm"]',
:value => 'some2',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'passwords do not match',
)
set(
:css => 'input[name="password_new"]',
:value => 'some',
)
set(
:css => 'input[name="password_new_confirm"]',
:value => 'some',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'it must be at least',
)
set(
:css => 'input[name="password_new"]',
:value => 'some-pass-new',
)
set(
:css => 'input[name="password_new_confirm"]',
:value => 'some-pass-new',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'must contain at least 1 digit',
)
set(
:css => 'input[name="password_new"]',
:value => 'some-pass-new2',
)
set(
:css => 'input[name="password_new_confirm"]',
:value => 'some-pass-new2',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'Password changed successfully',
)
logout()
sleep 4
login(
:username => signup_user_email,
:password => 'some-pass-new2',
)
logout()
# reset password (not possible)
location( :url => browser_url + '/#password_reset_verify/not_existing_token' )
watch_for(
:css => 'body',
:value => 'Token is invalid',
)
# reset password (with valid session - should not be possible)
login(
:username => signup_user_email,
:password => 'some-pass-new2',
:url => browser_url,
)
location( :url => browser_url + '/#password_reset' )
sleep 1
match(
:css => 'body',
:value => 'password',
:should_not_match => true,
)
logout()
# reset password (correct way)
click( :css => 'a[href="#password_reset"]' )
set(
:css => 'input[name="username"]',
:value => 'nonexisiting',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'address invalid',
)
set(
:css => 'input[name="username"]',
:value => signup_user_email,
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'sent password reset instructions',
)
# redirect to "#password_reset_verify/#{token}" url by app, because of "developer_mode"
watch_for(
:css => 'body',
:value => 'Choose your new password',
)
# set new password
set(
:css => 'input[name="password"]',
:value => 'some',
)
set(
:css => 'input[name="password_confirm"]',
:value => 'some2',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'passwords do not match',
)
set(
:css => 'input[name="password"]',
:value => 'some',
)
set(
:css => 'input[name="password_confirm"]',
:value => 'some',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'it must be at least',
)
set(
:css => 'input[name="password"]',
:value => 'some-pass-new',
)
set(
:css => 'input[name="password_confirm"]',
:value => 'some-pass-new',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'must contain at least 1 digit',
)
set(
:css => 'input[name="password"]',
:value => 'some-pass-new2',
)
set(
:css => 'input[name="password_confirm"]',
:value => 'some-pass-new2',
)
click( :css => '.content .btn--primary' )
watch_for(
:css => 'body',
:value => 'Your password has been changed',
)
# check if user is logged in
sleep 5
match(
:css => '.user-menu .user a',
:value => signup_user_email,
:attribute => 'title',
)
# set new password
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'some',
},
{
:execute => 'set',
:css => 'input[name="password_confirm"]',
:value => 'some2',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'passwords do not match',
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'some',
},
{
:execute => 'set',
:css => 'input[name="password_confirm"]',
:value => 'some',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'it must be at least',
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'some-pass-new',
},
{
:execute => 'set',
:css => 'input[name="password_confirm"]',
:value => 'some-pass-new',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'must contain at least 1 digit',
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'some-pass-new2',
},
{
:execute => 'set',
:css => 'input[name="password_confirm"]',
:value => 'some-pass-new2',
},
{
:execute => 'click',
:css => '.content .btn--primary',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Your password has been changed',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:css => '.user-menu .user a',
:attribute => 'title',
:value => signup_user_email,
:match_result => true,
},
],
},
]
browser_single_test(tests)
end end
end end