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 = [
{ @browser = browser_instance
:name => 'create customer', login(
:action => [ :username => 'agent1@example.com',
{ :password => 'test',
:execute => 'close_all_tasks', :url => browser_url,
}, )
{ tasks_close_all()
:execute => 'wait',
:value => 1, sleep 1
},
{ # create customer
:execute => 'click', click( :css => 'a[href="#new"]' )
:css => 'a[href="#new"]', click( :css => 'a[href="#ticket/create"]' )
}, click( :css => '.active .newTicket [name="customer_id_completion"]' )
{ sendkey( :value => :arrow_down )
:execute => 'click', sleep 1
:css => 'a[href="#ticket/create"]', click( :css => '.active .newTicket .recipientList-entry.js-user-new' )
}, sleep 1
{
:execute => 'click', set(
: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"]', :css => '.modal input[name="firstname"]',
:value => firstname, :value => firstname,
}, )
{ set(
:execute => 'set',
:css => '.modal input[name="lastname"]', :css => '.modal input[name="lastname"]',
:value => lastname, :value => lastname,
}, )
{ set(
:execute => 'set',
:css => '.modal input[name="email"]', :css => '.modal input[name="email"]',
:value => customer_user_email, :value => customer_user_email,
}, )
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'wait',
:value => 4,
},
# check is used is selected click( :css => '.modal button.js-submit' )
{ sleep 4
:execute => 'match',
# check is used to check selected
match(
:css => '.active input[name="customer_id"]', :css => '.active input[name="customer_id"]',
:value => '^\d+$', :value => '^\d+$',
:no_quote => true, :no_quote => true,
:match_result => true, )
}, match(
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => firstname, :value => firstname,
:no_quote => true, )
:match_result => true, match(
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => lastname, :value => lastname,
:no_quote => true, )
:match_result => true, match(
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => customer_user_email, :value => customer_user_email,
:no_quote => true, )
:match_result => true, match(
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => fullname, :value => fullname,
:no_quote => true, )
:match_result => true, sleep 4
},
{
:execute => 'wait',
:value => 4,
},
# call new ticket screen again # call new ticket screen again
{ tasks_close_all( :discard_changes => 1 )
:execute => 'close_all_tasks',
:discard_changes => 1, click( :css => 'a[href="#new"]' )
}, click( :css => 'a[href="#ticket/create"]' )
{ sleep 2
:execute => 'click',
:css => 'a[href="#new"]', match(
},
{
:execute => 'click',
:css => 'a[href="#ticket/create"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'match',
:css => '.active input[name="customer_id"]', :css => '.active input[name="customer_id"]',
:value => '^\d+$', :value => '',
:no_quote => true, )
:match_result => false, match(
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => firstname, :value => '',
:no_quote => true, )
:match_result => false, set(
},
{
:execute => 'set',
:css => '.active .newTicket input[name="customer_id_completion"]', :css => '.active .newTicket input[name="customer_id_completion"]',
:value => customer_user_email, :value => customer_user_email,
}, )
{ sleep 3
:execute => 'wait', sendkey( :value => :arrow_down )
:value => 3, sleep 1
}, click( :css => '.active .newTicket .recipientList-entry.js-user.is-active' )
{ sleep 1
:execute => 'sendkey',
:value => [:arrow_down] # check is used to check selected
}, match(
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => '.active .newTicket .recipientList-entry.js-user.is-active',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => '.active input[name="customer_id"]', :css => '.active input[name="customer_id"]',
:value => '^\d+$', :value => '^\d+$',
:no_quote => true, :no_quote => true,
:match_result => true, )
}, match(
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => firstname, :value => firstname,
:no_quote => true, )
:match_result => true, match(
},
{
:execute => 'match',
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => lastname, :value => lastname,
:no_quote => true, )
:match_result => true, match(
}, :css => '.active input[name="customer_id_completion"]',
{ :value => customer_user_email,
:execute => 'match', )
match(
:css => '.active input[name="customer_id_completion"]', :css => '.active input[name="customer_id_completion"]',
:value => fullname, :value => fullname,
:no_quote => true, )
:match_result => true,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
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"]',
}, # customer ticket create
{ click( :css => 'a[href="#new"]' )
:execute => 'click', click( :css => 'a[href="#customer_ticket_new"]' )
:css => 'a[href="#customer_ticket_new"]', sleep 2
},
{ select(
:execute => 'wait',
:value => 2,
},
{
:execute => 'check',
:css => '.newTicket',
:result => true,
},
{
:execute => 'select',
:css => '.newTicket select[name="group_id"]', :css => '.newTicket select[name="group_id"]',
:value => 'Users', :value => 'Users',
}, )
{
:execute => 'set', set(
:css => '.newTicket input[name="title"]', :css => '.newTicket input[name="title"]',
:value => 'some subject 123äöü', :value => 'some subject 123äöü',
}, )
{ set(
:execute => 'set',
:css => '.newTicket [data-name="body"]', :css => '.newTicket [data-name="body"]',
:value => 'some body 123äöü', :value => 'some body 123äöü',
}, )
{ click( :css => '.newTicket button.submit' )
:execute => 'click', sleep 5
:css => '.newTicket button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket # check if ticket is shown
{ location_check( :url => '#ticket/zoom/' )
:execute => 'match',
match(
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => 'some body 123äöü', :value => 'some body 123äöü',
:match_result => true, :no_quote => true,
}, )
# update ticket # update ticket
{ set(
:execute => 'check',
:css => '.active [data-name="body"]',
:result => true,
},
{
:execute => 'set',
:css => '.active [data-name="body"]', :css => '.active [data-name="body"]',
:value => 'some body 1234 äöüß', :value => 'some body 1234 äöüß',
}, )
{ click( :css => '.active button.js-submit' )
:execute => 'click',
:css => '.active button.js-submit', watch_for(
:type => 'submit', :css => '.active div.ticket-article',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'some body 1234 äöüß', :value => 'some body 1234 äöüß',
}, )
],
},
]
browser_signle_test_with_login(tests)
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"]',
},
{
:execute => 'click',
:css => 'a[href="#profile/language"]',
},
{
:execute => 'select',
:css => '.language_item select[name="locale"]', :css => '.language_item select[name="locale"]',
:value => 'Deutsch', :value => 'Deutsch',
}, )
{ click( :css => '.content button[type="submit"]' )
:execute => 'click', watch_for(
:css => '.content button[type="submit"]', :css => 'body',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache', :value => 'Sprache',
}, )
{ select(
:execute => 'select',
:css => '.language_item select[name="locale"]', :css => '.language_item select[name="locale"]',
:value => 'English (United States)', :value => 'English (United States)',
}, )
{ click( :css => '.content button[type="submit"]' )
:execute => 'click', watch_for(
:css => '.content button[type="submit"]', :css => 'body',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Language', :value => 'Language',
}, )
{ select(
:execute => 'select',
:css => '.language_item select[name="locale"]', :css => '.language_item select[name="locale"]',
:value => 'Deutsch', :value => 'Deutsch',
}, )
{ click( :css => '.content button[type="submit"]' )
:execute => 'click', watch_for(
:css => '.content button[type="submit"]', :css => 'body',
},
{
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache', :value => 'Sprache',
}, )
{ reload()
:execute => 'reload', watch_for(
}, :css => 'body',
{
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache', :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',
:action => [
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'close_all_tasks',
},
{
:execute => 'wait',
:value => 1,
},
{
: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
def test_persistant_task_b
tests = [
{
:name => 'persistant task',
:action => [
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'click',
:css => '.task',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => 'body',
: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
def test_persistant_task_with_relogin
tests = [
{
:name => 'agent1 - create persistant task',
:action => [
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'close_all_tasks',
},
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket/create"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => '.active .newTicket input[name="title"]',
:value => 'INBOUND TEST#1',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'set',
:css => '.active .newTicket [data-name="body"]',
:value => 'INBOUND BODY TEST#1',
},
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket/create"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => '.active .newTicket input[name="title"]',
:value => 'OUTBOUND TEST#1',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.active .newTicket [data-name="body"]',
:value => 'OUTBOUND BODY TEST#1',
},
{
:execute => 'wait',
:value => 12,
},
{
:execute => 'logout',
},
{
:execute => 'check',
:css => '#login',
:result => true,
},
{
:execute => 'wait',
: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', :username => 'agent1@example.com',
:password => 'test', :password => 'test',
}, :url => browser_url,
{ )
:execute => 'wait', tasks_close_all()
:value => 3,
}, # persistant task
{ click( :css => 'a[href="#new"]' )
:execute => 'match', click( :css => 'a[href="#ticket/create"]' )
set(
:css => '.active .newTicket input[name="title"]',
:value => 'some test AAA',
)
sleep 10
end
def test_persistant_task_b
@browser = browser_instance
login(
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
sleep 3
# check if task still exists
click( :css => '.task' )
match(
:css => '.active .newTicket input[name="title"]',
:value => 'some test AAA',
)
tasks_close_all()
exists_not( :css => '.active .newTicket input[name="title"]' )
end
def test_persistant_task_with_relogin
@browser = browser_instance
login(
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all()
click( :css => 'a[href="#new"]' )
click( :css => 'a[href="#ticket/create"]' )
set(
:css => '.active .newTicket input[name="title"]',
:value => 'INBOUND TEST#1',
)
set(
:css => '.active .newTicket [data-name="body"]',
:value => 'INBOUND BODY TEST#1',
)
click( :css => 'a[href="#new"]' )
click( :css => 'a[href="#ticket/create"]' )
set(
:css => '.active .newTicket input[name="title"]',
:value => 'OUTBOUND TEST#1',
)
set(
:css => '.active .newTicket [data-name="body"]',
:value => 'OUTBOUND BODY TEST#1',
)
sleep 10
logout()
sleep 4
# relogin with master - task are not viewable
login(
:username => 'master@example.com',
:password => 'test',
:url => browser_url,
)
sleep 3
match_not(
:css => 'body', :css => 'body',
:value => 'INBOUND TEST#1', :value => 'INBOUND TEST#1',
:match_result => true, )
}, match_not(
{
:execute => 'match',
:css => 'body', :css => 'body',
:value => 'OUTBOUND TEST#1', :value => 'OUTBOUND TEST#1',
:match_result => true, )
}, logout()
], sleep 2
},
] match_not(
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' }) :css => 'body',
:value => 'INBOUND TEST#1',
)
match_not(
:css => 'body',
:value => 'OUTBOUND TEST#1',
)
# relogin with agent - task are viewable
login(
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
sleep 3
match(
:css => 'body',
:value => 'INBOUND TEST#1',
)
match(
:css => 'body',
:value => 'OUTBOUND TEST#1',
)
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(