Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-22 23:20:05 +01:00
parent 5f266bdbce
commit f71c142829
6 changed files with 385 additions and 588 deletions

View file

@ -7,197 +7,113 @@ class AgentUserManageTest < TestCase
firstname = 'Customer Firstname' firstname = 'Customer Firstname'
lastname = 'Customer Lastname' lastname = 'Customer Lastname'
fullname = "#{ firstname } #{ lastname } <#{ customer_user_email }>" fullname = "#{ firstname } #{ lastname } <#{ customer_user_email }>"
tests = [
{
:name => 'create customer',
:action => [
{
:execute => 'close_all_tasks',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket/create"]',
},
{
:execute => 'click',
:css => '.active .newTicket [name="customer_id_completion"]',
},
{
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => '.active .newTicket .recipientList-entry.js-user-new',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.modal input[name="firstname"]',
:value => firstname,
},
{
:execute => 'set',
:css => '.modal input[name="lastname"]',
:value => lastname,
},
{
:execute => 'set',
:css => '.modal input[name="email"]',
:value => customer_user_email,
},
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'wait',
:value => 4,
},
# check is used is selected @browser = browser_instance
{ login(
:execute => 'match', :username => 'agent1@example.com',
:css => '.active input[name="customer_id"]', :password => 'test',
:value => '^\d+$', :url => browser_url,
:no_quote => true, )
:match_result => true, tasks_close_all()
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]',
:value => firstname,
:no_quote => true,
:match_result => true,
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]',
:value => lastname,
:no_quote => true,
:match_result => true,
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]',
:value => customer_user_email,
:no_quote => true,
:match_result => true,
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]',
:value => fullname,
:no_quote => true,
:match_result => true,
},
{
:execute => 'wait',
:value => 4,
},
# call new ticket screen again sleep 1
{
:execute => 'close_all_tasks', # create customer
:discard_changes => 1, click( :css => 'a[href="#new"]' )
}, click( :css => 'a[href="#ticket/create"]' )
{ click( :css => '.active .newTicket [name="customer_id_completion"]' )
:execute => 'click', sendkey( :value => :arrow_down )
:css => 'a[href="#new"]', sleep 1
}, click( :css => '.active .newTicket .recipientList-entry.js-user-new' )
{ sleep 1
:execute => 'click',
:css => 'a[href="#ticket/create"]', set(
}, :css => '.modal input[name="firstname"]',
{ :value => firstname,
:execute => 'wait', )
:value => 2, set(
}, :css => '.modal input[name="lastname"]',
{ :value => lastname,
:execute => 'match', )
:css => '.active input[name="customer_id"]', set(
:value => '^\d+$', :css => '.modal input[name="email"]',
:no_quote => true, :value => customer_user_email,
:match_result => false, )
},
{ click( :css => '.modal button.js-submit' )
:execute => 'match', sleep 4
:css => '.active input[name="customer_id_completion"]',
:value => firstname, # check is used to check selected
:no_quote => true, match(
:match_result => false, :css => '.active input[name="customer_id"]',
}, :value => '^\d+$',
{ :no_quote => true,
:execute => 'set', )
:css => '.active .newTicket input[name="customer_id_completion"]', match(
:value => customer_user_email, :css => '.active input[name="customer_id_completion"]',
}, :value => firstname,
{ )
:execute => 'wait', match(
:value => 3, :css => '.active input[name="customer_id_completion"]',
}, :value => lastname,
{ )
:execute => 'sendkey', match(
:value => [:arrow_down] :css => '.active input[name="customer_id_completion"]',
}, :value => customer_user_email,
{ )
:execute => 'wait', match(
:value => 1, :css => '.active input[name="customer_id_completion"]',
}, :value => fullname,
{ )
:execute => 'click', sleep 4
:css => '.active .newTicket .recipientList-entry.js-user.is-active',
}, # call new ticket screen again
{ tasks_close_all( :discard_changes => 1 )
:execute => 'wait',
:value => 1, click( :css => 'a[href="#new"]' )
}, click( :css => 'a[href="#ticket/create"]' )
{ sleep 2
:execute => 'match',
:css => '.active input[name="customer_id"]', match(
:value => '^\d+$', :css => '.active input[name="customer_id"]',
:no_quote => true, :value => '',
:match_result => true, )
}, match(
{ :css => '.active input[name="customer_id_completion"]',
:execute => 'match', :value => '',
:css => '.active input[name="customer_id_completion"]', )
:value => firstname, set(
:no_quote => true, :css => '.active .newTicket input[name="customer_id_completion"]',
:match_result => true, :value => customer_user_email,
}, )
{ sleep 3
:execute => 'match', sendkey( :value => :arrow_down )
:css => '.active input[name="customer_id_completion"]', sleep 1
:value => lastname, click( :css => '.active .newTicket .recipientList-entry.js-user.is-active' )
:no_quote => true, sleep 1
:match_result => true,
}, # check is used to check selected
{ match(
:execute => 'match', :css => '.active input[name="customer_id"]',
:css => '.active input[name="customer_id_completion"]', :value => '^\d+$',
:value => fullname, :no_quote => true,
:no_quote => true, )
:match_result => true, match(
}, :css => '.active input[name="customer_id_completion"]',
], :value => firstname,
}, )
] match(
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' }) :css => '.active input[name="customer_id_completion"]',
:value => lastname,
)
match(
:css => '.active input[name="customer_id_completion"]',
:value => customer_user_email,
)
match(
:css => '.active input[name="customer_id_completion"]',
:value => fullname,
)
end end
end end

View file

@ -3,88 +3,53 @@ require 'browser_test_helper'
class CustomerTicketCreateTest < TestCase class CustomerTicketCreateTest < TestCase
def test_customer_ticket_create def test_customer_ticket_create
tests = [ @browser = browser_instance
{ login(
:name => 'customer ticket create', :username => 'nicole.braun@zammad.org',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'click', )
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#customer_ticket_new"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'check',
:css => '.newTicket',
:result => true,
},
{
:execute => 'select',
:css => '.newTicket select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.newTicket input[name="title"]',
:value => 'some subject 123äöü',
},
{
:execute => 'set',
:css => '.newTicket [data-name="body"]',
:value => 'some body 123äöü',
},
{
:execute => 'click',
:css => '.newTicket button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket # customer ticket create
{ click( :css => 'a[href="#new"]' )
:execute => 'match', click( :css => 'a[href="#customer_ticket_new"]' )
:css => '.active div.ticket-article', sleep 2
:value => 'some body 123äöü',
:match_result => true,
},
# update ticket select(
{ :css => '.newTicket select[name="group_id"]',
:execute => 'check', :value => 'Users',
:css => '.active [data-name="body"]', )
:result => true,
}, set(
{ :css => '.newTicket input[name="title"]',
:execute => 'set', :value => 'some subject 123äöü',
:css => '.active [data-name="body"]', )
:value => 'some body 1234 äöüß', set(
}, :css => '.newTicket [data-name="body"]',
{ :value => 'some body 123äöü',
:execute => 'click', )
:css => '.active button.js-submit', click( :css => '.newTicket button.submit' )
:type => 'submit', sleep 5
},
{ # check if ticket is shown
:execute => 'watch_for', location_check( :url => '#ticket/zoom/' )
:area => 'body',
:value => 'some body 1234 äöüß', match(
}, :css => '.active div.ticket-article',
], :value => 'some body 123äöü',
}, :no_quote => true,
] )
browser_signle_test_with_login(tests)
# update ticket
set(
:css => '.active [data-name="body"]',
:value => 'some body 1234 äöüß',
)
click( :css => '.active button.js-submit' )
watch_for(
:css => '.active div.ticket-article',
:value => 'some body 1234 äöüß',
)
end end
end end

View file

@ -3,75 +3,46 @@ require 'browser_test_helper'
class PreferencesTest < TestCase class PreferencesTest < TestCase
def test_preferences def test_preferences
tests = [ @browser = browser_instance
{ login(
:name => 'preferences', :username => 'nicole.braun@zammad.org',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'click', )
:css => 'a[href="#current_user"]', click( :css => 'a[href="#current_user"]' )
}, click( :css => 'a[href="#profile"]' )
{ click( :css => 'a[href="#profile/language"]' )
:execute => 'click', select(
:css => 'a[href="#profile"]', :css => '.language_item select[name="locale"]',
}, :value => 'Deutsch',
{ )
:execute => 'click', click( :css => '.content button[type="submit"]' )
:css => 'a[href="#profile/language"]', watch_for(
}, :css => 'body',
{ :value => 'Sprache',
:execute => 'select', )
:css => '.language_item select[name="locale"]', select(
:value => 'Deutsch', :css => '.language_item select[name="locale"]',
}, :value => 'English (United States)',
{ )
:execute => 'click', click( :css => '.content button[type="submit"]' )
:css => '.content button[type="submit"]', watch_for(
}, :css => 'body',
{ :value => 'Language',
:execute => 'watch_for', )
:area => 'body', select(
:value => 'Sprache', :css => '.language_item select[name="locale"]',
}, :value => 'Deutsch',
{ )
:execute => 'select', click( :css => '.content button[type="submit"]' )
:css => '.language_item select[name="locale"]', watch_for(
:value => 'English (United States)', :css => 'body',
}, :value => 'Sprache',
{ )
:execute => 'click', reload()
:css => '.content button[type="submit"]', watch_for(
}, :css => 'body',
{ :value => 'Sprache',
:execute => 'watch_for', )
:area => 'body',
:value => 'Language',
},
{
:execute => 'select',
:css => '.language_item select[name="locale"]',
:value => 'Deutsch',
},
{
:execute => 'click',
:css => '.content button[type="submit"]',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache',
},
{
:execute => 'reload',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache',
},
],
},
]
browser_signle_test_with_login(tests)
end end
end end

View file

@ -33,8 +33,7 @@ class SignupPasswordChangeAndResetTest < TestCase
click( :css => 'button.submit' ) click( :css => 'button.submit' )
sleep 5 sleep 5
result = exists( :css => '.signup' ) exists_not( :css => '.signup' )
assert( !result, ".signup still exists" )
match( match(
:css => '.user-menu .user a', :css => '.user-menu .user a',
@ -152,10 +151,9 @@ class SignupPasswordChangeAndResetTest < TestCase
location( :url => browser_url + '/#password_reset' ) location( :url => browser_url + '/#password_reset' )
sleep 1 sleep 1
match( match_not(
:css => 'body', :css => 'body',
:value => 'password', :value => 'password',
:should_not_match => true,
) )
logout() logout()

View file

@ -3,244 +3,122 @@ require 'browser_test_helper'
class TaskbarTaskTest < TestCase class TaskbarTaskTest < TestCase
def test_persistant_task_a def test_persistant_task_a
tests = [ @browser = browser_instance
{ login(
:name => 'persistant task', :username => 'agent1@example.com',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'wait', )
:value => 2, tasks_close_all()
},
{ # persistant task
:execute => 'close_all_tasks', click( :css => 'a[href="#new"]' )
}, click( :css => 'a[href="#ticket/create"]' )
{ set(
:execute => 'wait', :css => '.active .newTicket input[name="title"]',
:value => 1, :value => 'some test AAA',
}, )
{ sleep 10
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket/create"]',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'check',
:css => '.active .newTicket',
:result => true,
},
{
:execute => 'set',
:css => '.active .newTicket input[name="title"]',
:value => 'some test AAA',
},
{
:execute => 'wait',
:value => 12,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end end
def test_persistant_task_b def test_persistant_task_b
tests = [ @browser = browser_instance
{ login(
:name => 'persistant task', :username => 'agent1@example.com',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'wait', )
:value => 4, sleep 3
},
{ # check if task still exists
:execute => 'click', click( :css => '.task' )
:css => '.task',
}, match(
{ :css => '.active .newTicket input[name="title"]',
:execute => 'wait', :value => 'some test AAA',
:value => 1, )
},
{ tasks_close_all()
:execute => 'match',
:css => 'body', exists_not( :css => '.active .newTicket input[name="title"]' )
:value => 'some test AAA',
:match_result => true,
},
{
:execute => 'close_all_tasks',
},
{
:execute => 'match',
:css => 'body',
:value => 'some test AAA',
:match_result => false,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end end
def test_persistant_task_with_relogin def test_persistant_task_with_relogin
tests = [ @browser = browser_instance
{ login(
:name => 'agent1 - create persistant task', :username => 'agent1@example.com',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'wait', )
:value => 2, tasks_close_all()
},
{ click( :css => 'a[href="#new"]' )
:execute => 'close_all_tasks', click( :css => 'a[href="#ticket/create"]' )
}, set(
{ :css => '.active .newTicket input[name="title"]',
:execute => 'click', :value => 'INBOUND TEST#1',
:css => 'a[href="#new"]', )
}, set(
{ :css => '.active .newTicket [data-name="body"]',
:execute => 'click', :value => 'INBOUND BODY TEST#1',
:css => 'a[href="#ticket/create"]', )
},
{ click( :css => 'a[href="#new"]' )
:execute => 'wait', click( :css => 'a[href="#ticket/create"]' )
:value => 2, set(
}, :css => '.active .newTicket input[name="title"]',
{ :value => 'OUTBOUND TEST#1',
:execute => 'set', )
:css => '.active .newTicket input[name="title"]', set(
:value => 'INBOUND TEST#1', :css => '.active .newTicket [data-name="body"]',
}, :value => 'OUTBOUND BODY TEST#1',
{ )
:execute => 'wait', sleep 10
:value => 4,
}, logout()
{ sleep 4
:execute => 'set',
:css => '.active .newTicket [data-name="body"]', # relogin with master - task are not viewable
:value => 'INBOUND BODY TEST#1', login(
}, :username => 'master@example.com',
{ :password => 'test',
:execute => 'click', :url => browser_url,
:css => 'a[href="#new"]', )
}, sleep 3
{
:execute => 'click', match_not(
:css => 'a[href="#ticket/create"]', :css => 'body',
}, :value => 'INBOUND TEST#1',
{ )
:execute => 'wait', match_not(
:value => 2, :css => 'body',
}, :value => 'OUTBOUND TEST#1',
{ )
:execute => 'set', logout()
:css => '.active .newTicket input[name="title"]', sleep 2
:value => 'OUTBOUND TEST#1',
}, match_not(
{ :css => 'body',
:execute => 'wait', :value => 'INBOUND TEST#1',
:value => 1, )
}, match_not(
{ :css => 'body',
:execute => 'set', :value => 'OUTBOUND TEST#1',
:css => '.active .newTicket [data-name="body"]', )
:value => 'OUTBOUND BODY TEST#1',
}, # relogin with agent - task are viewable
{ login(
:execute => 'wait', :username => 'agent1@example.com',
:value => 12, :password => 'test',
}, :url => browser_url,
{ )
:execute => 'logout', sleep 3
},
{ match(
:execute => 'check', :css => 'body',
:css => '#login', :value => 'INBOUND TEST#1',
:result => true, )
}, match(
{ :css => 'body',
:execute => 'wait', :value => 'OUTBOUND TEST#1',
:value => 10, )
},
],
},
{
:name => 'relogin with master - task are not viewable',
:action => [
{
:execute => 'login',
:username => 'master@example.com',
:password => 'test',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'match',
:css => 'body',
:value => 'INBOUND TEST#1',
:match_result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'OUTBOUND TEST#1',
:match_result => false,
},
{
:execute => 'logout',
},
{
:execute => 'check',
:css => '#login',
:result => true,
},
{
:execute => 'match',
:css => 'body',
:value => 'INBOUND TEST#1',
:match_result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'OUTBOUND TEST#1',
:match_result => false,
},
],
},
{
:name => 'relogin with agent - task are viewable',
:action => [
{
:execute => 'login',
:username => 'agent1@example.com',
:password => 'test',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'match',
:css => 'body',
:value => 'INBOUND TEST#1',
:match_result => true,
},
{
:execute => 'match',
:css => 'body',
:value => 'OUTBOUND TEST#1',
:match_result => true,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end end
end end

View file

@ -153,6 +153,22 @@ class TestCase < Test::Unit::TestCase
instance.get( params[:url] ) instance.get( params[:url] )
end end
=begin
location_check(
:browser => browser1,
:url => 'http://someurl',
)
=end
def location_check(params)
instance = params[:browser] || @browser
if instance.current_url !~ /#{Regexp.quote(params[:url])}/
raise "url #{instance.current_url} is not matching #{params[:url]}"
end
assert( true, "url #{instance.current_url} is matching #{params[:url]}" )
end
=begin =begin
@ -192,10 +208,27 @@ class TestCase < Test::Unit::TestCase
def exists(params) def exists(params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
if instance.find_elements( { :css => params[:css] } )[0] if !instance.find_elements( { :css => params[:css] } )[0]
return true raise "#{params[:css]} dosn't exist, but should"
end end
false true
end
=begin
exists_not(
:browser => browser1,
:css => '.some_class',
)
=end
def exists_not(params)
instance = params[:browser] || @browser
if instance.find_elements( { :css => params[:css] } )[0]
raise "#{params[:css]} exists but should not"
end
true
end end
=begin =begin
@ -228,6 +261,24 @@ class TestCase < Test::Unit::TestCase
sleep 0.1 sleep 0.1
end end
=begin
select(
:browser => browser1,
:css => '.some_class',
:value => 'Some Value',
)
=end
def select(params)
instance = params[:browser] || @browser
element = instance.find_elements( { :css => params[:css] } )[0]
dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, params[:value])
end
=begin =begin
sendkey( sendkey(
@ -319,6 +370,24 @@ class TestCase < Test::Unit::TestCase
return match return match
end end
=begin
match_not(
:browser => browser1,
:css => '#content .text-1',
:value => 'some test for browser and some other for browser',
:attribute => 'some_attribute', # match on attribute
:should_not_match => true,
:no_quote => false, # use regex
)
=end
def match_not(params)
params[:should_not_match] = true
match(params)
end
=begin =begin
cookie( cookie(