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