Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-28 19:51:40 +01:00
parent 8cc386a10c
commit 18838cb7c5
3 changed files with 561 additions and 536 deletions

View file

@ -3,245 +3,228 @@ require 'browser_test_helper'
class AgentTicketActionsLevel2Test < TestCase class AgentTicketActionsLevel2Test < TestCase
def test_work_with_two_browser_on_same_ticket def test_work_with_two_browser_on_same_ticket
# work on one ticket with two browsers
message = 'message 1äöüß ' + rand(99999999999999999).to_s message = 'message 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( :browser => browser1 )
:where => :instance1,
:execute => 'close_all_tasks', browser2 = browser_instance
}, login(
{ :browser => browser2,
:where => :instance2, :username => 'agent1@example.com',
:execute => 'close_all_tasks', :password => 'test',
}, :url => browser_url,
)
tasks_close_all( :browser => browser2 )
# create ticket # create ticket
{ ticket1 = ticket_create(
:where => :instance1, :browser => browser1,
:execute => 'create_ticket', :data => {
:group => 'Users', :group => 'Users',
:subject => 'some level 2 <b>subject</b> 123äöü', :customer => 'nicole',
:title => 'some level 2 <b>subject</b> 123äöü',
:body => 'some level 2 <b>body</b> 123äöü', :body => 'some level 2 <b>body</b> 123äöü',
}, }
)
# check ticket
{
:where => :instance1,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 2 <b>body</b> 123äöü',
:match_result => true,
},
# remember old ticket where we want to merge to
{
:where => :instance1,
:execute => 'match',
:css => '.active .page-header .ticket-number',
:value => '^(.*)$',
:no_quote => true,
:match_result => true,
},
# open ticket in second browser # open ticket in second browser
{ ticket_open_by_search(
:where => :instance2, :browser => browser2,
:execute => 'search_ticket', :number => ticket1[:number],
:number => '###stack###', )
}, watch_for(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => 'some level 2 <b>body</b> 123äöü', :value => 'some level 2 <b>body</b> 123äöü',
:match_result => true, )
# set body in edit area in second
ticket_update(
:browser => browser2,
:data => {
:body => 'some level 2 <b>body</b> in instance 2',
}, },
:do_not_submit => true,
)
# set body in edit area in first
ticket_update(
:browser => browser1,
:data => {
:body => 'some level 2 <b>body</b> in instance 1',
},
:do_not_submit => true,
)
# change title in second browser # change title in second browser
{ ticket_update(
:where => :instance2, :browser => browser2,
:execute => 'set_ticket_attributes', :data => {
:title => 'TTTsome level 2 <b>subject</b> 123äöü', :title => 'TTTsome level 2 <b>subject</b> 123äöü',
}, },
:do_not_submit => true,
)
sleep 2
# set body in edit area # verify title in second and first browser
{ verify_title(
:where => :instance2, :browser => browser2,
:execute => 'set_ticket_attributes', :value => 'TTTsome level 2 <b>subject<\/b> 123äöü',
:body => 'some level 2 <b>body</b> in instance 2', )
ticket_verify(
:browser => browser2,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
}, },
{ )
:where => :instance1, verify_task(
:execute => 'set_ticket_attributes', :browser => browser2,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
}
)
sleep 4
verify_title(
:browser => browser1,
:value => 'TTTsome level 2 <b>subject<\/b> 123äöü',
)
ticket_verify(
:browser => browser1,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
},
)
verify_task(
:browser => browser1,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
}
)
# verify text in input body, if still exists
ticket_verify(
:browser => browser1,
:data => {
:body => 'some level 2 <b>body</b> in instance 1', :body => 'some level 2 <b>body</b> in instance 1',
}, },
)
# change task and page title in second browser ticket_verify(
{ :browser => browser2,
:where => :instance2, :data => {
:execute => 'verify_task_attributes',
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance2,
:element => :title,
:value => 'TTTsome level 2 <b>subject</b> 123äöü',
},
# change task and page title in first browser
{
:execute => 'wait',
:value => 10,
},
{
:where => :instance1,
:execute => 'verify_ticket_attributes',
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance2,
:execute => 'verify_task_attributes',
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance1,
:element => :title,
:value => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance2,
:element => :title,
:value => 'TTTsome level 2 <b>subject</b> 123äöü',
},
# verify text in input body
{
:where => :instance1,
:execute => 'verify_ticket_attributes',
:body => 'some level 2 <b>body</b> in instance 1',
},
{
:where => :instance2,
:execute => 'verify_ticket_attributes',
:body => 'some level 2 <b>body</b> in instance 2', :body => 'some level 2 <b>body</b> in instance 2',
}, },
)
# add new article # set body in edit area in second
#{ ticket_update(
# :where => :instance1, :browser => browser1,
# :execute => 'select', :data => {
# :css => '.active .ticket-edit select[name="type_id"]',
# :value => 'note',
#},
{
:where => :instance1,
:execute => 'set_ticket_attributes',
:body => 'some update 4711', :body => 'some update 4711',
}, },
{ )
:where => :instance1, watch_for(
:execute => 'click', :browser => browser1,
:css => '.content.active button.js-submit', :css => '.active div.ticket-article',
},
{
:where => :instance1,
:execute => 'watch_for',
:area => '.active div.ticket-article',
:value => 'some update 4711', :value => 'some update 4711',
}, )
# verify empty text in input body # verify if text in input body is now empty
{ ticket_verify(
:where => :instance1, :browser => browser1,
:execute => 'verify_ticket_attributes', :data => {
:body => '', :body => '',
}, },
{ )
:where => :instance2,
:execute => 'verify_ticket_attributes', # check if body is still in second browser
ticket_verify(
:browser => browser2,
:data => {
:body => 'some level 2 <b>body</b> in instance 2', :body => 'some level 2 <b>body</b> in instance 2',
}, },
{ )
:execute => 'wait',
:value => 4,
},
# reload instances, verify again # reload instances, verify again
{ reload(
:where => :instance1, :browser => browser1,
:execute => 'reload', )
}, reload(
{ :browser => browser2,
:where => :instance2, )
:execute => 'reload',
},
# wait till application become ready # wait till application become ready
{ sleep 8
:execute => 'wait', verify_title(
:value => 8, :browser => browser2,
}, :value => 'TTTsome level 2 <b>subject<\/b> 123äöü',
{ )
:where => :instance1, ticket_verify(
:execute => 'verify_ticket_attributes', :browser => browser2,
:title => 'TTTsome level 2 <b>subject</b> 123äöü', :data => {
}, :title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
{
:where => :instance2,
:execute => 'verify_task_attributes',
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance1,
:element => :title,
:value => 'TTTsome level 2 <b>subject</b> 123äöü',
},
{
:where => :instance2,
:element => :title,
:value => 'TTTsome level 2 <b>subject</b> 123äöü',
}, },
)
verify_task(
:browser => browser2,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
}
)
# verify update verify_title(
{ :browser => browser1,
:where => :instance1, :value => 'TTTsome level 2 <b>subject<\/b> 123äöü',
:execute => 'match', )
:css => 'body', ticket_verify(
:value => 'some update 4711', :browser => browser1,
:match_result => true, :data => {
}, :title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:value => 'some update 4711',
:match_result => true,
}, },
)
verify_task(
:browser => browser1,
:data => {
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
}
)
# verify empty text in input body # verify if update is on ticket in each browser
{ watch_for(
:where => :instance1, :browser => browser1,
:execute => 'verify_ticket_attributes', :css => '.active div.ticket-article',
:value => 'some update 4711',
)
watch_for(
:browser => browser2,
:css => '.active div.ticket-article',
:value => 'some update 4711',
)
# verify if text in input body is now empty
ticket_verify(
:browser => browser1,
:data => {
:body => '', :body => '',
}, },
{ )
:where => :instance2,
:execute => 'verify_ticket_attributes', # check if body is still in second browser
ticket_verify(
:browser => browser2,
:data => {
:body => 'some level 2 <b>body</b> in instance 2', :body => 'some level 2 <b>body</b> in instance 2',
}, },
)
],
},
]
browser_double_test(tests)
end end
end end

View file

@ -3,305 +3,238 @@ require 'browser_test_helper'
class AgentTicketActionsLevel3Test < TestCase class AgentTicketActionsLevel3Test < TestCase
def test_work_with_two_browser_on_same_ticket_edit def test_work_with_two_browser_on_same_ticket_edit
message = 'message 3 äöüß ' + rand(99999999999999999).to_s
tests = [ browser1 = browser_instance
{ login(
:name => 'start', :browser => browser1,
:instance1 => browser_instance, :username => 'master@example.com',
:instance2 => browser_instance, :password => 'test',
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url, :url => browser_url,
:action => [ )
{ tasks_close_all( :browser => browser1 )
:where => :instance1,
:execute => 'close_all_tasks', browser2 = browser_instance
}, login(
{ :browser => browser2,
:where => :instance2, :username => 'agent1@example.com',
:execute => 'close_all_tasks', :password => 'test',
}, :url => browser_url,
)
tasks_close_all( :browser => browser2 )
# create ticket # create ticket
{ ticket1 = ticket_create(
:where => :instance1, :browser => browser1,
:execute => 'create_ticket', :data => {
:group => 'Users', :group => 'Users',
:subject => 'some level 3 <b>subject</b> 123äöü', :customer => 'nicole',
:title => 'some level 3 <b>subject</b> 123äöü',
:body => 'some level 3 <b>body</b> 123äöü', :body => 'some level 3 <b>body</b> 123äöü',
}, }
)
# check ticket
{
:where => :instance1,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> 123äöü',
:match_result => true,
},
# remember old ticket where we want to merge to
{
:where => :instance1,
:execute => 'match',
:css => '.active .page-header .ticket-number',
:value => '^(.*)$',
:no_quote => true,
:match_result => true,
},
# open ticket in second browser # open ticket in second browser
{ ticket_open_by_search(
:where => :instance2, :browser => browser2,
:execute => 'search_ticket', :number => ticket1[:number],
:number => '###stack###', )
}, watch_for(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> 123äöü', :value => 'some level 3 <b>body</b> 123äöü',
:match_result => true, )
},
# change edit screen in instance 1 # change edit screen in instance 1
{ ticket_update(
:where => :instance1, :browser => browser1,
:execute => 'set_ticket_attributes', :data => {
:body => 'some level 3 <b>body</b> in instance 1', :body => 'some level 3 <b>body</b> in instance 1',
}, },
{ :do_not_submit => true,
:execute => 'wait', )
:value => 3,
},
# update ticket in instance 2 # update ticket in instance 2
{ ticket_update(
:where => :instance2, :browser => browser2,
:execute => 'set_ticket_attributes', :data => {
:body => 'some level 3 <b>body</b> in instance 2', :body => 'some level 3 <b>body</b> in instance 2',
}, },
{ :do_not_submit => true,
:execute => 'wait', )
:value => 6,
}, click(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => true,
},
{
:where => :instance2,
:execute => 'click',
:css => '.active button.js-submit', :css => '.active button.js-submit',
}, )
{
:execute => 'wait', # discard changes should gone away
:value => 12, watch_for_disappear(
}, :browser => browser2,
{
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
ticket_verify(
:browser => browser2,
:data => {
:body => '',
}, },
)
# check content and edit screen in instance 1 # check content and edit screen in instance 1
{ match(
:where => :instance1, :browser => browser2,
:execute => 'match',
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2', :value => 'some level 3 <b>body</b> in instance 2',
:match_result => true, )
},
{ ticket_verify(
:where => :instance1, :browser => browser1,
:execute => 'verify_ticket_attributes', :data => {
:body => 'some level 3 <b>body</b> in instance 1', :body => 'some level 3 <b>body</b> in instance 1',
}, },
{ )
:where => :instance1,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => true,
},
# check edit screen in instance 2
{
:execute => 'wait',
:value => 1,
},
{
:where => :instance2,
:execute => 'verify_ticket_attributes',
:bdoy => '',
},
# update ticket in instance 1 # update ticket in instance 1
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => '.active button.js-submit', :css => '.active button.js-submit',
}, )
{
:execute => 'wait',
:value => 16,
},
# check content in instance 2 watch_for(
{ :browser => browser1,
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 1',
:match_result => true,
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2', :value => 'some level 3 <b>body</b> in instance 2',
:match_result => true, )
},
match_not(
:browser => browser1,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
# check content in instance 2
watch_for(
:browser => browser2,
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 1',
)
# check content and edit screen in instance 1+2 # check content and edit screen in instance 1+2
{ ticket_verify(
:where => :instance1, :browser => browser1,
:execute => 'verify_ticket_attributes', :data => {
:body => '', :body => '',
}, },
{ )
:where => :instance1, match_not(
:execute => 'match', :browser => browser1,
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
},
{ ticket_verify(
:where => :instance2, :browser => browser2,
:execute => 'verify_ticket_attributes', :data => {
:body => '', :body => '',
}, },
{ )
:where => :instance2, match_not(
:execute => 'match', :browser => browser2,
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
},
# reload instances, verify again # reload instances, verify again
{ reload(
:where => :instance1, :browser => browser1,
:execute => 'reload', )
}, reload(
{ :browser => browser2,
:where => :instance2, )
:execute => 'reload',
},
# check content and edit screen in instance 1+2 # check content and edit screen in instance 1+2
{ ticket_verify(
:where => :instance1, :browser => browser1,
:execute => 'verify_ticket_attributes', :data => {
:body => '', :body => '',
}, },
{ )
:where => :instance1, match_not(
:execute => 'match', :browser => browser1,
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
},
{ ticket_verify(
:where => :instance2, :browser => browser2,
:execute => 'verify_ticket_attributes', :data => {
:body => '', :body => '',
}, },
{ )
:where => :instance2, match_not(
:execute => 'match', :browser => browser2,
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
},
# change form of ticket in instance 2 # change form of ticket in instance 2
{ ticket_update(
:where => :instance2, :browser => browser2,
:execute => 'set_ticket_attributes', :data => {
:body => '22 some level 3 <b>body</b> in instance 2', :body => '22 some level 3 <b>body</b> in instance 2',
}, },
{ :do_not_submit => true,
:execute => 'wait', )
:value => 4,
}, watch_for(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => true, )
}, sleep 2
{
:where => :instance2, reload(
:execute => 'reload', :browser => browser2,
}, )
{ ticket_verify(
:where => :instance2, :browser => browser2,
:execute => 'verify_ticket_attributes', :data => {
:body => '22 some level 3 <b>body</b> in instance 2', :body => '22 some level 3 <b>body</b> in instance 2',
}, },
{ )
:where => :instance2, watch_for(
:execute => 'match', :browser => browser2,
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => true, )
},
{ click(
:where => :instance2, :browser => browser2,
:execute => 'click',
:css => '.active button.js-submit', :css => '.active button.js-submit',
}, )
{
:execute => 'wait', # discard changes should gone away
:value => 8, watch_for_disappear(
}, :browser => browser2,
{
:where => :instance2,
:execute => 'match',
:css => '.content_permanent.active',
:css => '.content.active .js-reset', :css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)', :value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true, :no_quote => true,
:match_result => false, )
},
{ watch_for(
:where => :instance2, :browser => browser2,
:execute => 'match',
:css => '.active div.ticket-article', :css => '.active div.ticket-article',
:value => '22 some level 3 <b>body</b> in instance 2', :value => '22 some level 3 <b>body</b> in instance 2',
:match_result => true, )
},
],
},
]
browser_double_test(tests)
end end
end end

View file

@ -522,6 +522,52 @@ class TestCase < Test::Unit::TestCase
raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'" raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'"
end end
=begin
verify_title(
:browser => browser1,
:value => 'some title',
)
=end
def verify_title(params = {})
instance = params[:browser] || @browser
title = instance.title
if title =~ /#{params[:value]}/i
assert( true, "matching '#{params[:value]}' in title '#{title}'" )
else
raise "not matching '#{params[:value]}' in title '#{title}'"
end
end
=begin
verify_task(
:browser => browser1,
:data => {
:title => 'some title',
}
)
=end
def verify_task(params = {})
instance = params[:browser] || @browser
data = params[:data]
if data[:title]
title = instance.find_elements( { :css => '.tasks .active' } )[0].text.strip
if title =~ /#{data[:title]}/i
assert( true, "matching '#{data[:title]}' in title '#{title}'" )
else
raise "not matching '#{data[:title]}' in title '#{title}'"
end
end
true
end
=begin =begin
file_upload( file_upload(
@ -596,12 +642,24 @@ class TestCase < Test::Unit::TestCase
=begin =begin
wait untill selector disabppears
watch_for_disappear( watch_for_disappear(
:browser => browser1, :browser => browser1,
:css => '#content .text-1', :css => '#content .text-1',
:timeout => '16', # in sec, default 16 :timeout => '16', # in sec, default 16
) )
wait untill text in selector disabppears
watch_for_disappear(
:browser => browser1,
:css => '#content .text-1',
:value => 'some value as regexp',
:timeout => '16', # in sec, default 16
)
=end =end
def watch_for_disappear(params = {}) def watch_for_disappear(params = {})
@ -620,6 +678,18 @@ class TestCase < Test::Unit::TestCase
sleep 1 sleep 1
return true return true
end end
if params[:value]
begin
text = instance.find_elements( { :css => params[:css] } )[0].text
if text !~ /#{params[:value]}/i
assert( true, "not matching '#{params[:value]}' in text '#{text}'" )
sleep 1
return true
end
rescue
# just try again
end
end
sleep 1 sleep 1
} }
raise "#{params[:css]}) still exsists" raise "#{params[:css]}) still exsists"
@ -818,12 +888,13 @@ class TestCase < Test::Unit::TestCase
sleep 0.3 sleep 0.3
end end
if data[:attachment]
#file_upload( file_upload(
# :browser => instance, :browser => instance,
# :css => '#content .text-1', :css => '#content .text-1',
# :value => 'some text', :value => 'some text',
#) )
end
if params[:do_not_submit] if params[:do_not_submit]
assert( true, "ticket created without submit" ) assert( true, "ticket created without submit" )
@ -949,7 +1020,7 @@ class TestCase < Test::Unit::TestCase
end end
if params[:do_not_submit] if params[:do_not_submit]
assert( true, "(#{test[:name]}) ticket updated without submit" ) assert( true, "ticket updated without submit" )
return true return true
end end
@ -969,6 +1040,44 @@ class TestCase < Test::Unit::TestCase
raise "unable to update ticket" raise "unable to update ticket"
end end
=begin
ticket_verify(
:browser => browser1,
:data => {
:title => 'some title',
:body => 'some body',
## :group => 'some group',
## :state => 'closed',
},
)
=end
def ticket_verify(params)
instance = params[:browser] || @browser
data = params[:data]
if data[:title]
title = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0].text.strip
if title =~ /#{data[:title]}/i
assert( true, "matching '#{data[:title]}' in title '#{title}'" )
else
raise "not matching '#{data[:title]}' in title '#{title}'"
end
end
if data[:body]
body = instance.find_elements( { :css => '.content.active [data-name="body"]' } )[0].text.strip
if body =~ /#{data[:body]}/i
assert( true, "matching '#{data[:body]}' in body '#{body}'" )
else
raise "not matching '#{data[:body]}' in body '#{body}'"
end
end
true
end
=begin =begin
ticket_open_by_overview( ticket_open_by_overview(