Improved tests.

This commit is contained in:
Martin Edenhofer 2015-02-23 07:56:45 +01:00
parent 2a19983638
commit 7a686b5c0e
4 changed files with 263 additions and 277 deletions

View file

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

View file

@ -8,215 +8,167 @@ class MaintenanceMessageTest < TestCase
title_text = "test <b>#{string}<\/b>" title_text = "test <b>#{string}<\/b>"
message_html = "message <b>1äöüß</b> #{string}\n\n\nhttp://zammad.org" message_html = "message <b>1äöüß</b> #{string}\n\n\nhttp://zammad.org"
message_text = "message <b>1äöüß<\/b> #{string}\n\nhttp:\/\/zammad.org" message_text = "message <b>1äöüß<\/b> #{string}\n\nhttp:\/\/zammad.org"
tests = [
{ # check #1
:name => 'check #1', browser1 = browser_instance
:instance1 => browser_instance, login(
:instance2 => browser_instance, :browser => browser1,
:instance1_username => 'master@example.com', :username => 'master@example.com',
:instance1_password => 'test', :password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url, :url => browser_url,
:action => [ )
{
:execute => 'wait', browser2 = browser_instance
:value => 1, login(
}, :browser => browser2,
{ :username => 'agent1@example.com',
:where => :instance1, :password => 'test',
:execute => 'click', :url => browser_url,
)
click(
:browser => browser1,
:css => 'a[href="#manage"]', :css => 'a[href="#manage"]',
}, )
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => 'a[href="#system/maintenance"]', :css => 'a[href="#system/maintenance"]',
}, )
{
:where => :instance1, set(
:execute => 'set', :browser => browser1,
:css => '#content input[name="head"]', :css => '#content input[name="head"]',
:value => title_html, :value => title_html,
}, )
{ set(
:where => :instance1, :browser => browser1,
:execute => 'set', :css => '#content input[name="message"]',
:css => '#content textarea[name="message"]',
:value => message_html, :value => message_html,
}, )
{
:where => :instance1, click(
:execute => 'click', :browser => browser1,
:css => '#content button[type="submit"]', :css => '#content button[type="submit"]',
}, )
{
:execute => 'wait', watch_for(
:value => 5, :browser => browser2,
}, :css => '.modal',
{
:where => :instance2,
:execute => 'watch_for',
:area => '.modal',
:value => title_text, :value => title_text,
}, )
{ watch_for(
:where => :instance2, :browser => browser2,
:execute => 'watch_for', :css => '.modal',
:area => '.modal',
:value => message_text, :value => message_text,
}, )
{
:where => :instance1, match_not(
:execute => 'match', :browser => browser1,
:css => 'body', :css => 'body',
:value => message_text, :value => message_text,
:match_result => false, )
},
{ click(
:where => :instance2, :browser => browser2,
:execute => 'click',
:css => 'div.modal-header .close', :css => 'div.modal-header .close',
}, )
{
:execute => 'wait', # check #2
:value => 2, click(
}, :browser => browser1,
],
},
{
:name => 'check #2',
:action => [
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#manage"]', :css => 'a[href="#manage"]',
}, )
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => 'a[href="#system/maintenance"]', :css => 'a[href="#system/maintenance"]',
}, )
{
:where => :instance1, set(
:execute => 'set', :browser => browser1,
:css => '#content input[name="head"]', :css => '#content input[name="head"]',
:value => title_html + ' #2', :value => title_html + ' #2',
}, )
{ set(
:where => :instance1, :browser => browser1,
:execute => 'set', :css => '#content input[name="message"]',
:css => '#content textarea[name="message"]',
:value => message_html + ' #2', :value => message_html + ' #2',
}, )
{
:where => :instance1, click(
:execute => 'click', :browser => browser1,
:css => '#content button[type="submit"]', :css => '#content button[type="submit"]',
}, )
{
:where => :instance2, watch_for(
:execute => 'watch_for', :browser => browser2,
:area => '.modal', :css => '.modal',
:value => title_text, :value => title_html + ' #2',
}, )
{ watch_for(
:where => :instance2, :browser => browser2,
:execute => 'watch_for', :css => '.modal',
:area => '.modal', :value => message_html + ' #2',
:value => message_text + ' #2', )
},
{ match_not(
:where => :instance1, :browser => browser1,
:execute => 'match',
:css => 'body', :css => 'body',
:value => message_text + ' #2', :value => message_text,
:match_result => false, )
},
{ click(
:where => :instance2, :browser => browser2,
:execute => 'click',
:css => 'div.modal-header .close', :css => 'div.modal-header .close',
}, )
{
:execute => 'wait', # check #3
:value => 2, click(
}, :browser => browser1,
],
},
{
:name => 'check #3',
:action => [
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#manage"]', :css => 'a[href="#manage"]',
}, )
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => 'a[href="#system/maintenance"]', :css => 'a[href="#system/maintenance"]',
}, )
{
:where => :instance1, set(
:execute => 'set', :browser => browser1,
:css => '#content input[name="head"]', :css => '#content input[name="head"]',
:value => title_html + ' #3' , :value => title_html + ' #3',
}, )
{ set(
:where => :instance1, :browser => browser1,
:execute => 'set', :css => '#content input[name="message"]',
:css => '#content textarea[name="message"]',
:value => message_html + ' #3', :value => message_html + ' #3',
}, )
{ check(
:where => :instance1, :browser => browser1,
:execute => 'setCheck',
:css => '#content input[name="reload"][value="1"]', :css => '#content input[name="reload"][value="1"]',
}, )
{ click(
:where => :instance1, :browser => browser1,
:execute => 'click',
:css => '#content button[type="submit"]', :css => '#content button[type="submit"]',
}, )
{
:execute => 'wait', watch_for(
:value => 5, :browser => browser2,
}, :css => '.modal',
{ :value => title_html + ' #3',
:where => :instance1, )
:execute => 'check', watch_for(
:css => 'div.modal-backdrop.fade.in', :browser => browser2,
:result => false, :css => '.modal',
}, :value => message_html + ' #3',
{ )
:where => :instance2, watch_for(
:execute => 'watch_for', :browser => browser2,
:area => '.modal', :css => '.modal',
:value => title_text,
},
{
:where => :instance2,
:execute => 'watch_for',
:area => '.modal',
:value => message_text + ' #3',
},
{
:where => :instance1,
:execute => 'match',
:css => 'body',
:value => message_text + ' #3',
:match_result => false,
},
{
:where => :instance2,
:execute => 'watch_for',
:area => '.modal',
:value => 'Reload application', :value => 'Reload application',
}, )
],
}, match_not(
] :browser => browser1,
browser_double_test(tests) :css => 'body',
:value => message_text,
)
end end
end end

View file

@ -3,75 +3,70 @@ require 'browser_test_helper'
class TaskbarSessionTest < TestCase class TaskbarSessionTest < TestCase
def test_current_session_a_same_agent def test_current_session_a_same_agent
tests = [
{ # check taken over session block screen with same user
:name => 'check taken over session block screen with same user', browser1 = browser_instance
:instance1 => browser_instance, login(
:instance2 => browser_instance, :browser => browser1,
:instance1_username => 'agent1@example.com', :username => 'agent1@example.com',
:instance1_password => 'test', :password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url, :url => browser_url,
:action => [ )
{
:execute => 'wait', browser2 = browser_instance
:value => 8, login(
}, :browser => browser2,
{ :username => 'agent1@example.com',
:where => :instance1, :password => 'test',
:execute => 'match', :url => browser_url,
)
sleep 8
match(
:browser => browser1,
:css => 'body', :css => 'body',
:value => 'Reload application', :value => 'Reload application',
:match_result => true, )
}, match_not(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => 'body', :css => 'body',
:value => 'Reload application', :value => 'Reload application',
:match_result => false, )
},
],
},
]
browser_double_test(tests)
end end
def test_current_session_b_different_agent def test_current_session_b_different_agent
tests = [
{ # check taken over session block screen with same user
:name => 'check taken over session block screen with same user', browser1 = browser_instance
:instance1 => browser_instance, login(
:instance2 => browser_instance, :browser => browser1,
:instance1_username => 'master@example.com', :username => 'master@example.com',
:instance1_password => 'test', :password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url, :url => browser_url,
:action => [ )
{
:execute => 'wait', browser2 = browser_instance
:value => 8, login(
}, :browser => browser2,
{ :username => 'agent1@example.com',
:where => :instance1, :password => 'test',
:execute => 'match', :url => browser_url,
)
sleep 8
match_not(
:browser => browser1,
:css => 'body', :css => 'body',
:value => 'Reload application', :value => 'Reload application',
:match_result => false, )
}, match_not(
{ :browser => browser2,
:where => :instance2,
:execute => 'match',
:css => 'body', :css => 'body',
:value => 'Reload application', :value => 'Reload application',
:match_result => false, )
},
],
},
]
browser_double_test(tests)
end end
end end

View file

@ -279,6 +279,44 @@ class TestCase < Test::Unit::TestCase
dropdown.select_by(:text, params[:value]) dropdown.select_by(:text, params[:value])
end end
=begin
check(
:browser => browser1,
:css => '.some_class',
)
=end
def check(params)
instance = params[:browser] || @browser
element = instance.find_elements( { :css => params[:css] } )[0]
checked = element.attribute('checked')
if !checked
element.click
end
end
=begin
uncheck(
:browser => browser1,
:css => '.some_class',
)
=end
def uncheck(params)
instance = params[:browser] || @browser
element = instance.find_elements( { :css => params[:css] } )[0]
checked = element.attribute('checked')
if checked
element.click
end
end
=begin =begin
sendkey( sendkey(