Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-23 23:37:00 +01:00
parent 6b4436d17e
commit 1a3affa659
2 changed files with 347 additions and 552 deletions

View file

@ -2,170 +2,62 @@
require 'browser_test_helper' require 'browser_test_helper'
class AgentTicketActionLevel0Test < TestCase class AgentTicketActionLevel0Test < TestCase
def test_I def test_text_modules
random = 'text_module_test_' + rand(99999999).to_s random = 'text_module_test_' + rand(99999999).to_s
random2 = 'text_module_test_' + rand(99999999).to_s random2 = 'text_module_test_' + rand(99999999).to_s
# user @browser = browser_instance
tests = [ login(
{ :username => 'master@example.com',
:name => 'add #1', :password => 'test',
:action => [ :url => browser_url,
{ )
:execute => 'close_all_tasks', tasks_close_all()
},
{ # create new text modules
:execute => 'click', text_module_create(
:css => 'a[href="#manage"]', :data => {
}, :name => 'some name' + random,
{ :keywords => random,
:execute => 'click', :content => 'some content' + random,
:css => 'a[href="#manage/text_modules"]',
},
{
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.modal input[name=name]',
:value => 'some name' + random,
},
{
:execute => 'set',
:css => '.modal input[name="keywords"]',
:value => random,
},
{
:execute => 'set',
:css => '.modal textarea[name="content"]',
:value => 'some content' + random,
},
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'watch_for',
:area => '#content table',
:value => 'some name' + random,
},
{
:execute => 'watch_for_disappear',
:area => '.modal',
},
],
}, },
{ )
:name => 'add #2', text_module_create(
:action => [ :data => {
{ :name => 'some name' + random2,
:execute => 'click', :keywords => random2,
:css => 'a[href="#manage"]', :content => 'some content' + random2,
},
{
:execute => 'click',
:css => 'a[href="#manage/text_modules"]',
},
{
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.modal input[name=name]',
:value => 'some name' + random2,
},
{
:execute => 'set',
:css => '.modal input[name="keywords"]',
:value => random2,
},
{
:execute => 'set',
:css => '.modal textarea[name="content"]',
:value => 'some content' + random2,
},
{
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:execute => 'watch_for',
:area => '#content table',
:value => 'some name' + random2,
},
{
:execute => 'watch_for_disappear',
:area => '.modal',
},
],
}, },
{ )
:name => 'verify usage',
:action => [ # try to use them
{ click( :css => 'a[href="#new"]' )
:execute => 'click', click( :css => 'a[href="#ticket/create"]' )
:css => 'a[href="#new"]', sleep 2
},
{ set(
:execute => 'click', :css => '.active div[data-name=body]',
:css => 'a[href="#ticket/create"]', :value => 'test ::' + random
}, )
{ watch_for(
:execute => 'watch_for', :css => '.active .shortcut',
:area => '.active div[data-name=body]', :value => random,
:value => '', )
}, sendkey(
{ :value => :arrow_down,
:execute => 'wait', )
:value => 3, sleep 1
}, click( :css => '.active .shortcut > ul> li > a' )
{
:execute => 'set_ticket_attributes', watch_for(
:body => 'test ::' + random, :css => '.active div[data-name=body]',
}, :value => 'some content' + random,
{ )
:execute => 'watch_for', tasks_close_all( :discard_changes => true )
:area => '.active .shortcut',
:value => random,
},
{ # test with two browser windows
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => '.active .shortcut > ul> li > a',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => '.active div[data-name=body]',
:value => 'some content' + random,
:match_result => true,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
end
def test_II
random = 'text_II_module_test_' + rand(99999999).to_s random = 'text_II_module_test_' + rand(99999999).to_s
user_rand = rand(99999999).to_s user_rand = rand(99999999).to_s
@ -175,408 +67,238 @@ class AgentTicketActionLevel0Test < TestCase
email = 'agent-text-module-' + user_rand + '@example.com' email = 'agent-text-module-' + user_rand + '@example.com'
password = 'agentpw' password = 'agentpw'
# user # use current session
tests = [ browser1 = @browser
{
:name => 'start',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:action => [
# create ticket
{
:where => :instance2,
:execute => 'close_all_tasks',
},
{
:where => :instance2,
:execute => 'create_ticket',
:subject => 'A',
:customer => '',
:do_not_submit => true,
},
{
:where => :instance2,
:execute => 'create_ticket',
:customer => '',
:subject => 'B',
:do_not_submit => true,
},
# create new text module browser2 = browser_instance
{ login(
:where => :instance1, :browser => browser2,
:execute => 'click', :username => 'agent1@example.com',
:css => 'a[href="#manage"]', :password => 'test',
}, :url => browser_url,
{ )
:where => :instance1, tasks_close_all(
:execute => 'click', :browser => browser2,
:css => 'a[href="#manage/text_modules"]', )
},
{
:where => :instance1,
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance1,
:execute => 'set',
:css => '.modal input[name=name]',
:value => 'some name' + random,
},
{
:where => :instance1,
:execute => 'set',
:css => '.modal input[name="keywords"]',
:value => random,
},
{
:where => :instance1,
:execute => 'set',
:css => '.modal textarea[name="content"]',
:value => 'some content <%= @ticket.customer.lastname %>' + random,
},
{
:where => :instance1,
:execute => 'click',
:css => '.modal button.js-submit',
},
{
:where => :instance1,
:execute => 'watch_for',
:area => '#content table',
:value => random,
},
{
:where => :instance1,
:execute => 'watch_for_disappear',
:area => '.modal',
},
], # create new ticket
ticket_create(
:browser => browser2,
:data => {
:customer => '',
:title => 'A',
}, },
:do_not_submit => true,
# create user )
{ ticket_create(
:name => 'create user', :browser => browser2,
:action => [ :data => {
{ :customer => '',
:where => :instance1, :title => 'B',
:execute => 'create_user',
:login => login,
:firstname => firstname,
:lastname => lastname,
:email => email,
:password => password,
},
],
}, },
{ :do_not_submit => true,
:name => 'check if text module exists in instance2, for ready to use', )
:action => [
{ # create new text module
:execute => 'wait', text_module_create(
:value => 4, :browser => browser1,
}, :data => {
{ :name => 'some name' + random,
:where => :instance2, :keywords => random,
:execute => 'set_ticket_attributes', :content => 'some content <%= @ticket.customer.lastname %>' + random,
:body => '::' + random,
},
{
:execute => 'wait',
:value => 2,
},
{
:where => :instance2,
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'click',
:css => '.active .shortcut > ul> li > a',
},
{
:execute => 'wait',
:value => 1,
},
# instance.execute_script( '$(".content.active div[data-name=body]").focus()' )
#execute] == 'js'
# result = instance.execute_script( action[:value
{
:where => :instance2,
:execute => 'match',
:css => '.active div[data-name=body]',
:value => 'some content ' + random,
:match_result => true,
},
{
:execute => 'wait',
:value => 3,
},
{
:where => :instance2,
:execute => 'set',
:css => '.active .newTicket input[name="customer_id_completion"]',
:value => 'nicole',
},
{
:execute => 'wait',
:value => 4,
},
{
:where => :instance2,
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'click',
:css => '.active .newTicket .recipientList-entry.js-user.is-active',
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'set_ticket_attributes',
:body => '::' + random,
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'click',
:css => '.active .shortcut > ul> li > a',
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div[data-name=body]',
:value => 'some content Braun' + random,
:match_result => true,
},
],
}, },
{ )
:name => 'verify zoom',
:action => [
{ # create user to test placeholder
:where => :instance1, user_create(
:execute => 'click', :browser => browser1,
:css => 'a[href="#manage"]', :data => {
}, :login => login,
:firstname => firstname,
# create ticket :lastname => lastname,
{ :email => email,
:where => :instance2, :password => password,
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some subject 123äöü',
:body => 'some body 123äöü',
},
# check ticket
{
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some body 123äöü',
:match_result => true,
},
# check ticket zoom
{
:execute => 'wait',
:value => 4,
},
{
:where => :instance2,
:execute => 'set_ticket_attributes',
:body => 'test',
},
{
:execute => 'wait',
:value => 2,
},
{
:where => :instance2,
:execute => 'set_ticket_attributes',
:body => '::' + random,
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'sendkey',
:value => [:arrow_down]
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'click',
:css => '.active .shortcut > ul> li > a',
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div[data-name=body]',
:value => 'some content Braun' + random,
:match_result => true,
},
],
}, },
{ )
:name => 'change customer',
:action => [
{ # check if text module exists in instance2, for ready to use
:where => :instance1, set(
:execute => 'click', :browser => browser2,
:css => 'a[href="#manage"]', :css => '.active div[data-name=body]',
}, :value => 'test ::' + random
{ )
:where => :instance2, watch_for(
:execute => 'click', :browser => browser2,
:css => '.active div[data-tab="ticket"] .js-actions .select-arrow', :css => '.active .shortcut',
}, :value => random,
{ )
:where => :instance2, sendkey(
:execute => 'click', :browser => browser2,
:css => '.active div[data-tab="ticket"] .js-actions a[data-type="customer-change"]', :value => :arrow_down,
}, )
{ sleep 1
:execute => 'wait', click(
:value => 1, :browser => browser2,
}, :css => '.active .shortcut > ul> li > a',
{ )
:where => :instance2,
:execute => 'set', watch_for(
:css => '.modal [name="customer_id_completion"]', :browser => browser2,
:value => firstname, :css => '.active div[data-name=body]',
}, :value => 'some content' + random,
{ )
:execute => 'wait', sleep 2
:value => 4,
},
{ set(
:where => :instance2, :browser => browser2,
:execute => 'sendkey', :css => '.active .newTicket input[name="customer_id_completion"]',
:value => [:arrow_down] :value => 'nicole',
}, )
{ sleep 4
:execute => 'wait', sendkey(
:value => 1, :browser => browser2,
}, :value => :arrow_down,
{ )
:where => :instance2, sleep 1
:execute => 'click',
:css => '.modal .recipientList-entry.js-user.is-active', click(
}, :browser => browser2,
{ :css => '.active .newTicket .recipientList-entry.js-user.is-active',
:execute => 'wait', )
:value => 1, sleep 1
},
{ set(
:where => :instance2, :browser => browser2,
:execute => 'click', :css => '.active div[data-name=body]',
:css => '.modal-content .js-submit', :value => '::' + random,
}, )
{ sleep 1
:where => :instance2, sendkey(
:execute => 'watch_for_disappear', :browser => browser2,
:area => '.modal', :value => :arrow_down,
}, )
{ sleep 1
:execute => 'wait', click(
:value => 1, :browser => browser2,
}, :css => '.active .shortcut > ul> li > a',
{ )
:where => :instance2, watch_for(
:execute => 'set_ticket_attributes', :browser => browser2,
:body => '::' + random, :css => '.active div[data-name=body]',
}, :value => 'some content Braun' + random,
{ )
:execute => 'wait',
:value => 1, # verify zoom
}, click(
{ :browser => browser1,
:where => :instance2, :css => 'a[href="#manage"]',
:execute => 'sendkey', )
:value => [:arrow_down]
}, # create ticket
{ ticket_create(
:execute => 'wait', :browser => browser2,
:value => 1, :data => {
}, :group => 'Users',
{ :subject => 'some subject 123äöü',
:where => :instance2, :body => 'some body 123äöü',
:execute => 'click',
:css => '.active .shortcut > ul> li > a',
},
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div[data-name=body]',
:value => 'some content ' + lastname,
:match_result => true,
},
{
:execute => 'wait',
:value => 2,
},
],
}, },
)
set(
:browser => browser2,
:css => '.active div[data-name=body]',
:value => 'test',
)
sleep 1
] set(
browser_double_test(tests) :browser => browser2,
:css => '.active div[data-name=body]',
:value => '::' + random,
)
sleep 1
sendkey(
:browser => browser2,
:value => :arrow_down,
)
sleep 1
click(
:browser => browser2,
:css => '.active .shortcut > ul> li > a',
)
watch_for(
:browser => browser2,
:css => '.active div[data-name=body]',
:value => 'some content Braun' + random,
)
# change customer
click(
:browser => browser1,
:css => 'a[href="#manage"]',
)
click(
:browser => browser2,
:css => '.active div[data-tab="ticket"] .js-actions .select-arrow',
)
click(
:browser => browser2,
:css => '.active div[data-tab="ticket"] .js-actions a[data-type="customer-change"]',
)
sleep 1
set(
:browser => browser2,
:css => '.modal [name="customer_id_completion"]',
:value => firstname,
)
sleep 4
sendkey(
:browser => browser2,
:value => :arrow_down,
)
sleep 1
click(
:browser => browser2,
:css => '.modal .recipientList-entry.js-user.is-active',
)
sleep 1
click(
:browser => browser2,
:css => '.modal-content .js-submit',
)
watch_for_disappear(
:browser => browser2,
:css => '.modal',
)
sleep 1
watch_for(
:browser => browser2,
:css => '.active div[data-name=body]',
:value => '::' + random,
)
sleep 1
sendkey(
:browser => browser2,
:value => :arrow_down,
)
sleep 1
click(
:browser => browser2,
:css => '.active .shortcut > ul> li > a',
)
watch_for(
:browser => browser2,
:css => '.active div[data-name=body]',
:value => 'some content ' + lastname,
)
end end
end end

View file

@ -518,6 +518,35 @@ class TestCase < Test::Unit::TestCase
raise "'#{params[:value]}' found in '#{text}'" raise "'#{params[:value]}' found in '#{text}'"
end end
=begin
watch_for_disappear(
:browser => browser1,
:css => true,
:timeout => '16', # in sec, default 16
)
=end
def watch_for_disappear(params = {})
instance = params[:browser] || @browser
timeout = 16
if action[:timeout]
timeout = params[:timeout]
end
loops = (timeout).to_i
text = ''
(1..loops).each { |loop|
element = instance.find_elements( { :css => params[:css] } )[0]
if !element #|| element.displayed?
assert( true, "not found" )
return true
end
sleep 1
}
raise "#{test[:css]}) still exsists"
end
=begin =begin
@ -1086,6 +1115,50 @@ class TestCase < Test::Unit::TestCase
raise "sla creation failed" raise "sla creation failed"
end end
=begin
text_module_create(
:browser => browser2,
:data => {
:name => 'some sla' + random,
:keywords => 'some keywords',
:content => 'some content',
},
)
=end
def text_module_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/text_modules"]' } )[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=keywords]' } )[0]
element.clear
element.send_keys( data[:keywords] )
element = instance.find_elements( { :css => '.modal textarea[name=content]' } )[0]
element.clear
element.send_keys( data[:content] )
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, "text module created" )
return true
end
sleep 1
}
raise "text module 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 = [