Improved speed of tests.

This commit is contained in:
Martin Edenhofer 2015-02-23 16:35:48 +01:00
parent 809246aab5
commit 6b4436d17e
6 changed files with 268 additions and 381 deletions

View file

@ -19,12 +19,14 @@ class AAbUnitTest < TestCase
:css => '.result .failed', :css => '.result .failed',
:value => '0', :value => '0',
) )
location( :url => browser_url + '/tests-model' ) location( :url => browser_url + '/tests-model' )
sleep 8 sleep 8
match( match(
:css => '.result .failed', :css => '.result .failed',
:value => '0', :value => '0',
) )
location( :url => browser_url + '/tests-model-ui' ) location( :url => browser_url + '/tests-model-ui' )
sleep 8 sleep 8
match( match(
@ -40,15 +42,14 @@ class AAbUnitTest < TestCase
:css => '.result .failed', :css => '.result .failed',
:value => '0', :value => '0',
) )
location( :url => browser_url + '/tests-form-extended' ) location( :url => browser_url + '/tests-form-extended' )
sleep 8 sleep 8
match( match(
:css => '.result .failed', :css => '.result .failed',
:value => '0', :value => '0',
) )
end
def test_form_validation
@browser = browser_instance
location( :url => browser_url + '/tests-form-validation' ) location( :url => browser_url + '/tests-form-validation' )
sleep 4 sleep 4
match( match(
@ -64,6 +65,7 @@ class AAbUnitTest < TestCase
:css => '.result .failed', :css => '.result .failed',
:value => '0', :value => '0',
) )
location( :url => browser_url + '/tests-html-utils' ) location( :url => browser_url + '/tests-html-utils' )
sleep 4 sleep 4
match( match(

View file

@ -2,60 +2,8 @@
require 'browser_test_helper' require 'browser_test_helper'
class AgentOrganizationProfileTest < TestCase class AgentOrganizationProfileTest < TestCase
def test_search_and_edit_verify_in_second def test_org_profile
message = 'comment 1 ' + rand(99999999999999999).to_s # work in one browser window
browser1 = browser_instance
login(
:browser => browser1,
:username => 'master@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all(
:browser => browser1,
)
browser2 = browser_instance
login(
:browser => browser2,
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all(
:browser => browser2,
)
organization_open_by_search(
:browser => browser1,
:value => 'Zammad Foundation',
)
organization_open_by_search(
:browser => browser2,
:value => 'Zammad Foundation',
)
# update note
set(
:browser => browser1,
:css => '.active [data-name="note"]',
:value => message,
)
click(
:browser => browser1,
:css => '.active .profile',
)
# verify
watch_for(
:browser => browser2,
:css => '.active .profile-window',
:value => message,
)
end
def test_search_and_edit_in_one
message = '1 ' + rand(99999999).to_s message = '1 ' + rand(99999999).to_s
@browser = browser_instance @browser = browser_instance
@ -131,5 +79,52 @@ class AgentOrganizationProfileTest < TestCase
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'org profile check ' + message, :value => 'org profile check ' + message,
) )
tasks_close_all()
# work with two browser windows
message = 'comment 1 ' + rand(99999999999999999).to_s
# use current session
browser1 = @browser
browser2 = browser_instance
login(
:browser => browser2,
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all(
:browser => browser2,
)
organization_open_by_search(
:browser => browser1,
:value => 'Zammad Foundation',
)
organization_open_by_search(
:browser => browser2,
:value => 'Zammad Foundation',
)
# update note
set(
:browser => browser1,
:css => '.active [data-name="note"]',
:value => message,
)
click(
:browser => browser1,
:css => '.active .profile',
)
# verify
watch_for(
:browser => browser2,
:css => '.active .profile-window',
:value => message,
)
end end
end end

View file

@ -3,292 +3,150 @@ require 'browser_test_helper'
class AgentTicketActionLevel1Test < TestCase class AgentTicketActionLevel1Test < TestCase
def test_agent_ticket_merge_closed_tab def test_agent_ticket_merge_closed_tab
tests = [
{
:name => 'agent ticket create 1',
:action => [
{
:execute => 'close_all_tasks',
},
# create ticket # merge ticket with closed tab
{ @browser = browser_instance
:execute => 'create_ticket', login(
:username => 'agent1@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all()
# create new ticket
ticket1 = ticket_create(
:data => {
:customer => 'nico',
:group => 'Users', :group => 'Users',
:subject => 'some subject 123äöü', :title => 'some subject 123äöü - with closed tab',
:body => 'some body 123äöü - with closed tab', :body => 'some body 123äöü - with closed tab',
}, },
)
# check ticket sleep 1
{
:execute => 'match',
:css => '.content.active .ticket-article',
:value => 'some body 123äöü - with closed tab',
:match_result => true,
},
# remember old ticket where we want to merge to
{
:execute => 'match',
:css => '.content.active .page-header .ticket-number',
:value => '^(.*)$',
:no_quote => true,
:match_result => true,
},
# update ticket # update ticket
#{ ticket_update(
# :execute => 'select', :data => {
# :css => '.active select[name="type_id"]',
# :value => 'note',
#},
{
:execute => 'set_ticket_attributes',
:body => 'some body 1234 äöüß - with closed tab', :body => 'some body 1234 äöüß - with closed tab',
}, },
{ )
:execute => 'click',
:css => '.content.active button.js-submit',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 1234 äöüß - with closed tab',
},
{
:execute => 'close_all_tasks',
},
],
},
{ tasks_close_all()
:name => 'agent ticket create 2',
:action => [
# create ticket # create second ticket to merge
{ ticket2 = ticket_create(
:execute => 'create_ticket', :data => {
:customer => 'nico',
:group => 'Users', :group => 'Users',
:subject => 'test to merge', :title => 'test to merge - with closed tab',
:body => 'some body 123äöü 222 - test to merge - with closed tab', :body => 'some body 123äöü 222 - test to merge - with closed tab',
}, },
)
# check ticket ticket_update(
{ :data => {
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 123äöü 222 - test to merge - with closed tab',
},
# update ticket
#{
# :execute => 'select',
# :css => '.content_permanent.active select[name="type_id"]',
# :value => 'note',
#},
{
:execute => 'set_ticket_attributes',
:body => 'some body 1234 äöüß 333 - with closed tab', :body => 'some body 1234 äöüß 333 - with closed tab',
}, },
{ )
:execute => 'click',
:css => '.content.active button.js-submit',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'watch_for',
:area => '.content.active .ticket-article',
:value => 'some body 1234 äöüß 333 - with closed tab',
},
# check if task is shown # check if task is shown
{ match(
:execute => 'match', :css => '.tasks',
:css => 'body', :value => 'test to merge - with closed tab',
:value => 'test to merge', )
:match_result => true,
}, # merge tickets
], click( :css => '.active div[data-tab="ticket"] .js-actions .select-arrow' )
}, click( :css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]' )
{ watch_for(
:name => 'agent ticket merge', :css => '.modal',
:action => [ :value => 'merge',
{ )
:execute => 'click',
:css => '.active div[data-tab="ticket"] .js-actions .select-arrow', set(
},
{
:execute => 'click',
:css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'set',
:css => '.modal input[name="master_ticket_number"]', :css => '.modal input[name="master_ticket_number"]',
:value => '###stack###', :value => ticket1[:number],
}, )
{
:execute => 'click', click( :css => '.modal button[type="submit"]' )
:css => '.modal button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
# check if merged to ticket is shown now # check if merged to ticket is shown now
{ watch_for(
:execute => 'match',
:css => '.active .page-header .ticket-number', :css => '.active .page-header .ticket-number',
:value => '###stack###', :value => ticket1[:number],
:match_result => true, )
}, watch_for(
:css => '.active .ticket-article',
:value => 'test to merge - with closed tab',
)
# check if task is now gone # check if task is now gone
{ match_not(
:execute => 'match', :css => '.tasks',
:css => 'body', :value => 'test to merge',
:value => 'test to merge - with closed tab', )
:match_result => true, match(
}, :css => '.tasks',
:value => 'some subject 123äöü - with closed tab',
)
# close task/cleanup # close task/cleanup
{ tasks_close_all()
:execute => 'close_all_tasks',
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end
def test_agent_ticket_merge_open_tab
tests = [
{
:name => 'agent ticket create 1',
:action => [
{
:execute => 'close_all_tasks',
},
# create ticket
{ # merge ticket with open tabs
:execute => 'create_ticket', ticket3 = ticket_create(
:data => {
:customer => 'nico',
:group => 'Users', :group => 'Users',
:subject => 'some subject 123äöü', :title => 'some subject 123äöü - with open tab',
:body => 'some body 123äöü - with open tab', :body => 'some body 123äöü - with open tab',
}, },
)
# check ticket ticket4 = ticket_create(
{ :data => {
:execute => 'match', :customer => 'nico',
:css => '.content.active .ticket-article',
:value => 'some body 123äöü - with open tab',
:match_result => true,
},
# remember old ticket where we want to merge to
{
:execute => 'match',
:css => '.content.active .page-header .ticket-number',
:value => '^(.*)$',
:no_quote => true,
:match_result => true,
},
],
},
{
:name => 'agent ticket create 2',
:action => [
# create ticket
{
:execute => 'create_ticket',
:group => 'Users', :group => 'Users',
:subject => 'test to merge', :title => 'test to merge - with open tab',
:body => 'some body 123äöü 222 - test to merge - with open tab', :body => 'some body 123äöü 222 - test to merge - with open tab',
}, },
)
# check ticket # merge tickets
{ click( :css => '.active div[data-tab="ticket"] .js-actions .select-arrow' )
:execute => 'watch_for', click( :css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]' )
:area => '.content.active .ticket-article', watch_for(
:value => 'some body 123äöü 222 - test to merge - with open tab', :css => '.modal',
}, :value => 'merge',
)
# check if task is shown set(
{
:execute => 'match',
:css => 'body',
:value => 'test to merge',
:match_result => true,
},
],
},
{
:name => 'agent ticket merge',
:action => [
{
:execute => 'click',
:css => '.active div[data-tab="ticket"] .js-actions .select-arrow',
},
{
:execute => 'click',
:css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'set',
:css => '.modal input[name="master_ticket_number"]', :css => '.modal input[name="master_ticket_number"]',
:value => '###stack###', :value => ticket3[:number],
}, )
{ click( :css => '.modal button[type="submit"]' )
:execute => 'click',
:css => '.modal button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
# check if merged to ticket is shown now # check if merged to ticket is shown now
{ watch_for(
:execute => 'match',
:css => '.active .page-header .ticket-number', :css => '.active .page-header .ticket-number',
:value => '###stack###', :value => ticket3[:number],
:match_result => true, )
}, watch_for(
:css => '.active .ticket-article',
:value => 'test to merge - with open tab',
)
# check if task is now gone # check if task is now gone
{ match_not(
:execute => 'match', :css => '.tasks',
:css => 'body', :value => 'test to merge',
:value => 'test to merge - with open tab', )
:match_result => true, match(
}, :css => '.tasks',
:value => 'some subject 123äöü - with open tab',
)
# close task/cleanup
{
:execute => 'close_all_tasks',
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end end
end end

View file

@ -125,7 +125,7 @@ class AgentTicketOverviewLevel1Test < TestCase
) )
# close ticket # close ticket
sleep 1 # needed to selenium cache issues sleep 2 # needed to selenium cache issues
ticket_update( ticket_update(
:browser => browser2, :browser => browser2,
:data => { :data => {

View file

@ -2,59 +2,7 @@
require 'browser_test_helper' require 'browser_test_helper'
class AgentUserProfileTest < TestCase class AgentUserProfileTest < TestCase
def test_search_and_edit_verify_in_second def test_user_profile
message = 'comment 1 ' + rand(99999999999999999).to_s
browser1 = browser_instance
login(
:browser => browser1,
:username => 'master@example.com',
:password => 'test',
:url => browser_url,
)
tasks_close_all(
:browser => browser1,
)
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 message = '1 ' + rand(99999999).to_s
@browser = browser_instance @browser = browser_instance
@ -127,5 +75,52 @@ class AgentUserProfileTest < TestCase
:css => '.active .profile-window', :css => '.active .profile-window',
:value => 'user profile check ' + message, :value => 'user profile check ' + message,
) )
tasks_close_all()
# work with two browser windows
message = 'comment 1 ' + rand(99999999999999999).to_s
# use current session
browser1 = @browser
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 end
end end

View file

@ -725,6 +725,8 @@ class TestCase < Test::Unit::TestCase
ticket_update( ticket_update(
:browser => browser1, :browser => browser1,
:data => { :data => {
:title => '',
:body => 'some body',
:group => 'some group', :group => 'some group',
:state => 'closed', :state => 'closed',
}, },
@ -737,6 +739,41 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
if data[:title]
#element = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0]
#element.clear
#sleep 0.5
#element = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0]
#element.send_keys( data[:title] )
#sleep 0.5
#element.send_keys( :tab )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").focus()' )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").text("' + data[:title] + '")' )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").blur()' )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").trigger("blur")' )
# {
# :where => :instance2,
# :execute => 'sendkey',
# :css => '.content.active .page-header .ticket-title-update',
# :value => 'TTT',
# },
# {
# :where => :instance2,
# :execute => 'sendkey',
# :css => '.content.active .page-header .ticket-title-update',
# :value => :tab,
# },
end
if data[:body]
#instance.execute_script( '$(".content.active div[data-name=body]").focus()' )
sleep 0.5
element = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0]
element.clear
element.send_keys( data[:body] )
end
if data[:group] if data[:group]
element = instance.find_elements( { :css => '.active .sidebar select[name="group_id"]' } )[0] element = instance.find_elements( { :css => '.active .sidebar select[name="group_id"]' } )[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)