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
sleep 1 # needed to selenium cache issues
ticket_update(
:browser => browser2,
:data => {

View file

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

View file

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

View file

@ -279,6 +279,44 @@ class TestCase < Test::Unit::TestCase
dropdown.select_by(:text, params[:value])
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
sendkey(