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

View file

@ -3,305 +3,238 @@ require 'browser_test_helper'
class AgentTicketActionsLevel3Test < TestCase
def test_work_with_two_browser_on_same_ticket_edit
message = 'message 3 äöüß ' + 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',
},
# create ticket
{
:where => :instance1,
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some level 3 <b>subject</b> 123äöü',
:body => 'some level 3 <b>body</b> 123äöü',
},
browser1 = browser_instance
login(
:browser => browser1,
:username => 'master@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all( :browser => browser1 )
# check ticket
{
:where => :instance1,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> 123äöü',
:match_result => true,
},
browser2 = browser_instance
login(
:browser => browser2,
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all( :browser => browser2 )
# 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,
},
# create ticket
ticket1 = ticket_create(
:browser => browser1,
:data => {
:group => 'Users',
:customer => 'nicole',
:title => 'some level 3 <b>subject</b> 123äöü',
:body => 'some level 3 <b>body</b> 123äöü',
}
)
# open ticket in second browser
{
:where => :instance2,
:execute => 'search_ticket',
:number => '###stack###',
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> 123äöü',
:match_result => true,
},
# open ticket in second browser
ticket_open_by_search(
:browser => browser2,
:number => ticket1[:number],
)
watch_for(
:browser => browser2,
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> 123äöü',
)
# change edit screen in instance 1
{
:where => :instance1,
:execute => 'set_ticket_attributes',
:body => 'some level 3 <b>body</b> in instance 1',
},
{
:execute => 'wait',
:value => 3,
},
# update ticket in instance 2
{
:where => :instance2,
:execute => 'set_ticket_attributes',
:body => 'some level 3 <b>body</b> in instance 2',
},
{
:execute => 'wait',
:value => 6,
},
{
: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',
},
{
:execute => 'wait',
:value => 12,
},
{
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
# check content and edit screen in instance 1
{
:where => :instance1,
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2',
:match_result => true,
},
{
:where => :instance1,
:execute => 'verify_ticket_attributes',
: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
{
:where => :instance1,
:execute => 'click',
:css => '.active button.js-submit',
},
{
:execute => 'wait',
:value => 16,
},
# check content in instance 2
{
: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',
:value => 'some level 3 <b>body</b> in instance 2',
:match_result => true,
},
# check content and edit screen in instance 1+2
{
:where => :instance1,
:execute => 'verify_ticket_attributes',
:body => '',
},
{
:where => :instance1,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
{
:where => :instance2,
:execute => 'verify_ticket_attributes',
:body => '',
},
{
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
# reload instances, verify again
{
:where => :instance1,
:execute => 'reload',
},
{
:where => :instance2,
:execute => 'reload',
},
# check content and edit screen in instance 1+2
{
:where => :instance1,
:execute => 'verify_ticket_attributes',
:body => '',
},
{
:where => :instance1,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
{
:where => :instance2,
:execute => 'verify_ticket_attributes',
:body => '',
},
{
:where => :instance2,
:execute => 'match',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
# change form of ticket in instance 2
{
:where => :instance2,
:execute => 'set_ticket_attributes',
:body => '22 some level 3 <b>body</b> in instance 2',
},
{
:execute => 'wait',
:value => 4,
},
{
: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 => 'reload',
},
{
:where => :instance2,
:execute => 'verify_ticket_attributes',
:body => '22 some level 3 <b>body</b> in instance 2',
},
{
: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',
},
{
:execute => 'wait',
:value => 8,
},
{
:where => :instance2,
:execute => 'match',
:css => '.content_permanent.active',
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
:match_result => false,
},
{
:where => :instance2,
:execute => 'match',
:css => '.active div.ticket-article',
:value => '22 some level 3 <b>body</b> in instance 2',
:match_result => true,
},
],
# change edit screen in instance 1
ticket_update(
:browser => browser1,
:data => {
:body => 'some level 3 <b>body</b> in instance 1',
},
]
browser_double_test(tests)
:do_not_submit => true,
)
# update ticket in instance 2
ticket_update(
:browser => browser2,
:data => {
:body => 'some level 3 <b>body</b> in instance 2',
},
:do_not_submit => true,
)
click(
:browser => browser2,
:css => '.active button.js-submit',
)
# discard changes should gone away
watch_for_disappear(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
ticket_verify(
:browser => browser2,
:data => {
:body => '',
},
)
# check content and edit screen in instance 1
match(
:browser => browser2,
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2',
)
ticket_verify(
:browser => browser1,
:data => {
:body => 'some level 3 <b>body</b> in instance 1',
},
)
# update ticket in instance 1
click(
:browser => browser1,
:css => '.active button.js-submit',
)
watch_for(
:browser => browser1,
:css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2',
)
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
ticket_verify(
:browser => browser1,
:data => {
:body => '',
},
)
match_not(
:browser => browser1,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
ticket_verify(
:browser => browser2,
:data => {
:body => '',
},
)
match_not(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
# reload instances, verify again
reload(
:browser => browser1,
)
reload(
:browser => browser2,
)
# check content and edit screen in instance 1+2
ticket_verify(
:browser => browser1,
:data => {
:body => '',
},
)
match_not(
:browser => browser1,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
ticket_verify(
:browser => browser2,
:data => {
:body => '',
},
)
match_not(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
# change form of ticket in instance 2
ticket_update(
:browser => browser2,
:data => {
:body => '22 some level 3 <b>body</b> in instance 2',
},
:do_not_submit => true,
)
watch_for(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
sleep 2
reload(
:browser => browser2,
)
ticket_verify(
:browser => browser2,
:data => {
:body => '22 some level 3 <b>body</b> in instance 2',
},
)
watch_for(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
click(
:browser => browser2,
:css => '.active button.js-submit',
)
# discard changes should gone away
watch_for_disappear(
:browser => browser2,
:css => '.content.active .js-reset',
:value => '(Discard your unsaved changes.|Verwerfen der)',
:no_quote => true,
)
watch_for(
:browser => browser2,
:css => '.active div.ticket-article',
:value => '22 some level 3 <b>body</b> in instance 2',
)
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}'"
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
file_upload(
@ -596,12 +642,24 @@ class TestCase < Test::Unit::TestCase
=begin
wait untill selector disabppears
watch_for_disappear(
:browser => browser1,
:css => '#content .text-1',
: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
def watch_for_disappear(params = {})
@ -620,6 +678,18 @@ class TestCase < Test::Unit::TestCase
sleep 1
return true
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
}
raise "#{params[:css]}) still exsists"
@ -818,12 +888,13 @@ class TestCase < Test::Unit::TestCase
sleep 0.3
end
#file_upload(
# :browser => instance,
# :css => '#content .text-1',
# :value => 'some text',
#)
if data[:attachment]
file_upload(
:browser => instance,
:css => '#content .text-1',
:value => 'some text',
)
end
if params[:do_not_submit]
assert( true, "ticket created without submit" )
@ -949,7 +1020,7 @@ class TestCase < Test::Unit::TestCase
end
if params[:do_not_submit]
assert( true, "(#{test[:name]}) ticket updated without submit" )
assert( true, "ticket updated without submit" )
return true
end
@ -969,6 +1040,44 @@ class TestCase < Test::Unit::TestCase
raise "unable to update ticket"
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
ticket_open_by_overview(