Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-23 14:02:46 +01:00
parent 4a5fa073f8
commit 1e6989f6d1
3 changed files with 326 additions and 372 deletions

View file

@ -4,185 +4,128 @@ require 'browser_test_helper'
class AgentUserProfileTest < TestCase class AgentUserProfileTest < TestCase
def test_search_and_edit_verify_in_second def test_search_and_edit_verify_in_second
message = 'comment 1 ' + rand(99999999999999999).to_s message = 'comment 1 ' + rand(99999999999999999).to_s
tests = [
{ browser1 = browser_instance
:name => 'start', login(
:instance1 => browser_instance, :browser => browser1,
:instance2 => browser_instance, :username => 'master@example.com',
:instance1_username => 'master@example.com', :password => 'test',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url, :url => browser_url,
:action => [ )
{ tasks_close_all(
:where => :instance1, :browser => browser1,
:execute => 'close_all_tasks', )
},
{ browser2 = browser_instance
:where => :instance2, login(
:execute => 'close_all_tasks', :browser => browser2,
}, :username => 'agent1@example.com',
{ :password => 'test',
:where => :instance1, :url => browser_url,
:execute => 'search_user', )
:term => 'Braun', tasks_close_all(
}, :browser => browser2,
{ )
:where => :instance2,
:execute => 'search_user', user_open_by_search(
:term => 'Braun', :browser => browser1,
}, :value => 'Braun',
)
user_open_by_search(
:browser => browser2,
:value => 'Braun',
)
# update note # update note
{ set(
:where => :instance1, :browser => browser1,
:execute => 'set',
:css => '.active [data-name="note"]', :css => '.active [data-name="note"]',
:value => message, :value => message,
}, )
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => '.active .profile', :css => '.active .profile',
}, )
{
:where => :instance1,
:execute => 'wait',
:value => 3,
},
# verify watch_for(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => '.active .profile-window', :css => '.active .profile-window',
:value => message, :value => message,
:match_result => true, )
},
],
},
]
browser_double_test(tests)
end end
def test_search_and_edit_in_one def test_search_and_edit_in_one
message = '1 ' + rand(99999999).to_s message = '1 ' + rand(99999999).to_s
tests = [
{ @browser = browser_instance
:name => 'search and edit', login(
:action => [ :username => 'master@example.com',
{ :password => 'test',
:execute => 'close_all_tasks', :url => browser_url,
}, )
tasks_close_all()
# search and open user # search and open user
{ user_open_by_search( :value => 'Braun' )
:execute => 'search_user',
:term => 'Braun', watch_for(
},
{
:execute => 'match',
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'note', :value => 'note',
:match_result => true, )
}, watch_for(
{
:execute => 'match',
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'email', :value => 'email',
:match_result => true, )
},
# update note # update note
{ set(
:execute => 'set',
:css => '.active [data-name="note"]', :css => '.active [data-name="note"]',
:value => 'some note 123' :value => 'some note 123',
}, )
{
:execute => 'click', click( :css => '.active .profile' )
:css => '.active .profile', sleep 2
},
{
:execute => 'wait',
:value => 1,
},
# check and change note again in edit screen # check and change note again in edit screen
{ click( :css => '.active .js-action .select-arrow' )
:execute => 'click', click( :css => '.active .js-action a[data-type="edit"]' )
:css => '.active .js-action .select-arrow',
}, watch_for(
{
:execute => 'click',
:css => '.active .js-action a[data-type="edit"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => '.active .modal', :css => '.active .modal',
:value => 'note', :value => 'note',
:match_result => true, )
}, watch_for(
{
:execute => 'match',
:css => '.active .modal', :css => '.active .modal',
:value => 'some note 123', :value => 'some note 123',
:match_result => true, )
},
{ set(
:execute => 'set', :css => '.modal [data-name="note"]',
:css => '.active .modal [data-name="note"]', :value => 'some note abc',
:value => 'some note abc' )
}, click( :css => '.active .modal button.js-submit' )
{
:execute => 'click', watch_for(
:css => '.active .modal button.js-submit',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'some note abc', :value => 'some note abc',
:match_result => true, )
},
# create new ticket # create new ticket
{ ticket_create(
:execute => 'create_ticket', :data => {
:customer => 'nico',
:group => 'Users', :group => 'Users',
:subject => 'user profile check ' + message, :title => 'user profile check ' + message,
:body => 'user profile check ' + message, :body => 'user profile check ' + message,
}, },
{ )
:execute => 'wait', sleep 1
:value => 4,
},
# switch to org tab, verify if ticket is shown # switch to org tab, verify if ticket is shown
{ user_open_by_search( :value => 'Braun' )
:execute => 'search_user', watch_for(
:term => 'Braun',
},
{
:execute => 'match',
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'user profile check ' + message, :value => 'user profile check ' + message,
:match_result => true, )
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
end end
end end

View file

@ -6,212 +6,100 @@ class ManageTest < TestCase
random = 'manage-test-' + rand(999999).to_s random = 'manage-test-' + rand(999999).to_s
user_email = random + '@example.com' user_email = random + '@example.com'
# user # user management
tests = [ @browser = browser_instance
{ login(
:name => 'user', :username => 'master@example.com',
:action => [ :password => 'test',
{ :url => browser_url,
:execute => 'click', )
:css => 'a[href="#manage"]',
}, click( :css => 'a[href="#manage"]' )
{ click( :css => 'a[href="#manage/users"]' )
:execute => 'click',
:css => 'a[href="#manage/users"]', user_create(
}, :data => {
{
:execute => 'create_user',
:login => 'some login' + random, :login => 'some login' + random,
:firstname => 'Manage Firstname' + random, :firstname => 'Manage Firstname' + random,
:lastname => 'Manage Lastname' + random, :lastname => 'Manage Lastname' + random,
:email => user_email, :email => user_email,
:password => 'some-pass', :password => 'some-pass',
}, }
{ )
:execute => 'set',
:css => '.content .js-search', click( :css => '.table-overview tr:last-child td' )
:value => user_email, sleep 2
},
{ set(
:execute => 'watch_for',
:area => 'body',
:value => random,
},
{
:execute => 'click',
:css => '.table-overview tr:last-child td',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => '.modal input[name="lastname"]', :css => '.modal input[name="lastname"]',
:value => '2Manage Lastname' + random, :value => '2Manage Lastname' + random,
}, )
{ click( :css => '.modal button.js-submit' )
:execute => 'click',
:css => '.modal button.js-submit', watch_for(
}, :css => 'body',
{
:execute => 'watch_for',
:area => 'body',
:value => '2Manage Lastname' + random, :value => '2Manage Lastname' + random,
}, )
{
:execute => 'wait', # sla
:value => 1, sla_create(
}, :data => {
], :name => 'some sla' + random,
}, :first_response_time => 61
{ }
:name => 'sla', )
:action => [ watch_for(
{ :css => 'body',
:execute => 'click',
:css => 'a[href="#manage"]',
},
{
:execute => 'click',
:css => 'a[href="#manage/slas"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => '.modal input[name=name]',
:value => 'some sla' + random,
},
{
:execute => 'set',
:css => '.modal input[name="first_response_time"]',
:value => 61,
},
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'watch_for',
:area => 'body',
:value => random, :value => random,
}, )
{ sleep 1
:execute => 'wait',
:value => 3, click( :css => '.table-overview tr:last-child td' )
}, sleep 1
{
:execute => 'click', set(
:css => '.table-overview tr:last-child td',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.modal input[name=name]', :css => '.modal input[name=name]',
:value => 'some sla update ' + random, :value => 'some sla update ' + random,
}, )
{ set(
:execute => 'set',
:css => '.modal input[name="first_response_time"]', :css => '.modal input[name="first_response_time"]',
:value => 121, :value => 121,
}, )
{ click( :css => '.modal button.js-submit' )
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'watch_for',
:area => 'body table',
:value => 'some sla update ' + random,
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'click',
:css => 'a[data-type="destroy"]:last-child',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'match',
:css => 'body',
:value => 'some sla update ' + random,
:match_result => false,
},
{
:execute => 'click',
:css => 'a[href="#manage"]',
},
{
:execute => 'click',
:css => 'a[href="#manage/slas"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'match',
:css => 'body',
:value => 'some sla update ' + random,
:match_result => false,
},
{
:execute => 'reload',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'click',
:css => 'a[href="#manage"]',
},
{
:execute => 'click',
:css => 'a[href="#manage/slas"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'match',
:css => 'body',
:value => 'some sla update ' + random,
:match_result => false,
},
], watch_for(
:css => 'body',
:value => 'some sla update ' + random,
)
sleep 4
}, click( :css => 'a[data-type="destroy"]:last-child' )
] sleep 2
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
click( :css => '.modal button.js-submit' )
sleep 4
match_not(
:css => 'body',
:value => 'some sla update ' + random,
)
click( :css => 'a[href="#manage"]' )
click( :css => 'a[href="#manage/slas"]' )
sleep 2
match_not(
:css => 'body',
:value => 'some sla update ' + random,
)
relaod()
sleep 2
click( :css => 'a[href="#manage"]' )
click( :css => 'a[href="#manage/slas"]' )
sleep 2
match_not(
:css => 'body',
:value => 'some sla update ' + random,
)
end end
end end

View file

@ -632,7 +632,7 @@ class TestCase < Test::Unit::TestCase
:data => { :data => {
:customer => 'nico', :customer => 'nico',
:group => 'Users', :group => 'Users',
:subject => 'overview #1', :title => 'overview #1',
:body => 'overview #1', :body => 'overview #1',
}, },
:do_not_submit => true, :do_not_submit => true,
@ -887,6 +887,129 @@ class TestCase < Test::Unit::TestCase
overviews overviews
end end
=begin
user_open_by_search(
:browser => browser2,
:value => 'some value',
)
=end
def user_open_by_search(params = {})
instance = params[:browser] || @browser
element = instance.find_elements( { :css => '#global-search' } )[0]
element.click
element.clear
element.send_keys( params[:value] )
sleep 3
element = instance.find_element( { :partial_link_text => params[:value] } ).click
name = instance.find_elements( { :css => '.active h1' } )[0].text
if name !~ /#{params[:value]}/
raise "unable to search/find user #{params[:value]}!"
end
assert( true, "user #{params[:term]} found" )
true
end
=begin
user_create(
:browser => browser2,
:data => {
:login => 'some login' + random,
:firstname => 'Manage Firstname' + random,
:lastname => 'Manage Lastname' + random,
:email => user_email,
:password => 'some-pass',
},
)
=end
def user_create(params = {})
instance = params[:browser] || @browser
data = params[:data]
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
instance.find_elements( { :css => 'a[href="#manage/users"]' } )[0].click
sleep 2
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
sleep 2
element = instance.find_elements( { :css => '.modal input[name=firstname]' } )[0]
element.clear
element.send_keys( data[:firstname] )
element = instance.find_elements( { :css => '.modal input[name=lastname]' } )[0]
element.clear
element.send_keys( data[:lastname] )
element = instance.find_elements( { :css => '.modal input[name=email]' } )[0]
element.clear
element.send_keys( data[:email] )
element = instance.find_elements( { :css => '.modal input[name=password]' } )[0]
element.clear
element.send_keys( data[:password] )
element = instance.find_elements( { :css => '.modal input[name=password_confirm]' } )[0]
element.clear
element.send_keys( data[:password] )
instance.find_elements( { :css => '.modal input[name="role_ids"][value="3"]' } )[0].click
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
sleep 2
set(
:browser => instance,
:css => '.content .js-search',
:value => data[:email],
)
watch_for(
:browser => instance,
:css => 'body',
:value => data[:lastname],
)
assert( true, "user created" )
end
=begin
sla_create(
:browser => browser2,
:data => {
:name => 'some sla' + random,
:first_response_time => 61
},
)
=end
def sla_create(params = {})
instance = params[:browser] || @browser
data = params[:data]
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
instance.find_elements( { :css => 'a[href="#manage/slas"]' } )[0].click
sleep 2
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
sleep 2
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
element.clear
element.send_keys( data[:name] )
element = instance.find_elements( { :css => '.modal input[name=first_response_time]' } )[0]
element.clear
element.send_keys( data[:first_response_time] )
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
(1..8).each {|loop|
element = instance.find_elements( { :css => 'body' } )[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
assert( true, "sla created" )
return true
end
sleep 1
}
raise "sla creation failed"
end
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
def browser_login(data) def browser_login(data)
all_tests = [ all_tests = [