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