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

View file

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

View file

@ -632,7 +632,7 @@ class TestCase < Test::Unit::TestCase
:data => {
:customer => 'nico',
:group => 'Users',
:subject => 'overview #1',
:title => 'overview #1',
:body => 'overview #1',
},
:do_not_submit => true,
@ -887,6 +887,129 @@ class TestCase < Test::Unit::TestCase
overviews
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...
def browser_login(data)
all_tests = [