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