From ac9e71c4f22918427e9113d7de08c785788f3957 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 23 Jun 2013 23:32:45 +0200 Subject: [PATCH] Improved unit tests, added IE support. --- .../agent_ticket_actions_level2_test.rb | 46 ++++++++++++++++--- test/browser_test_helper.rb | 14 ++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/test/browser/agent_ticket_actions_level2_test.rb b/test/browser/agent_ticket_actions_level2_test.rb index 05ab0dda0..ac37fc334 100644 --- a/test/browser/agent_ticket_actions_level2_test.rb +++ b/test/browser/agent_ticket_actions_level2_test.rb @@ -163,6 +163,24 @@ class AgentTicketActionsLevel2Test < TestCase :link => '###stack###', # :css => 'a:contains(\'###stack###\')', }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'js', + :value => '$("#global-search").focus()', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :where => :instance2, + :execute => 'js', + :value => '$("#global-search").blur()', + }, { :execute => 'wait', :value => 3, @@ -176,18 +194,34 @@ class AgentTicketActionsLevel2Test < TestCase }, # change title in second browser +# { +# :where => :instance2, +# :execute => 'sendkey', +# :css => '.active .ticket-title-update', +# :value => 'TTT', +# }, +# { +# :where => :instance2, +# :execute => 'sendkey', +# :css => '.active .ticket-title-update', +# :value => :tab, +# }, { :where => :instance2, - :execute => 'sendkey', - :css => '.active .ticket-title-update', - :value => 'TTT', + :execute => 'js', + :value => '$(".active .ticket-title .ticket-title-update").focus()', }, { :where => :instance2, - :execute => 'sendkey', - :css => '.active .ticket-title-update', - :value => :tab, + :execute => 'js', + :value => '$(".active .ticket-title .ticket-title-update").html("TTTsome level 2 <b>subject</b> 123äöü")', }, + { + :where => :instance2, + :execute => 'js', + :value => '$(".active .ticket-title .ticket-title-update").blur()', + }, + # set body in edit area { diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 52b67d8f2..1f123690a 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -193,6 +193,16 @@ class TestCase < Test::Unit::TestCase assert( false, "(#{test[:name]}) not matching '#{action[:value]}' in title" ) end return + elsif action[:element] == :cookie + cookies = instance.manage.all_cookies + cookies.each {|cookie| + if cookie.to_s =~ /#{action[:value]}/i + assert( true, "(#{test[:name]}) matching '#{action[:value]}' in cookie" ) + return + end + } + assert( false, "(#{test[:name]}) not matching '#{action[:value]}' in cookie" ) + return elsif action[:element] == :alert element = instance.switch_to.alert elsif action[:execute] == 'close_all_tasks' @@ -213,6 +223,9 @@ class TestCase < Test::Unit::TestCase instance.navigate.to( action[:to] ) elsif action[:execute] == 'reload' instance.navigate.refresh + elsif action[:execute] == 'js' + result = instance.execute_script( action[:value] ) + puts "JS RESULT" + result.inspect elsif action[:link] if action[:link].match '###stack###' action[:link].gsub! '###stack###', @stack @@ -311,6 +324,7 @@ class TestCase < Test::Unit::TestCase elsif action[:execute] == 'close_all_tasks' elsif action[:execute] == 'navigate' elsif action[:execute] == 'reload' + elsif action[:execute] == 'js' else assert( false, "(#{test[:name]}) unknow action '#{action[:execute]}'" ) end