From 414654b026af6be8cb78534e43ce5fc7b1dbd2a0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 15 Sep 2014 11:06:13 +0200 Subject: [PATCH] Fixed browser tests. --- .../app/views/ticket_zoom/title.jst.eco | 2 +- app/models/ticket/screen_options.rb | 4 +-- .../agent_ticket_actions_level1_test.rb | 6 ++-- .../agent_ticket_actions_level2_test.rb | 4 +-- .../agent_ticket_actions_level3_test.rb | 2 +- .../agent_ticket_actions_level5_test.rb | 6 ++-- test/browser/agent_user_manage_test.rb | 7 ++--- test/browser/customer_ticket_create_test.rb | 12 +++++--- test/browser/taskbar_task_test.rb | 9 +++--- test/browser_test_helper.rb | 29 ++++++++++++++----- 10 files changed, 49 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco index 8381ed5b6..63781116e 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco @@ -1,5 +1,5 @@

<%= @P( @ticket.title ) %>

- <%- @C('ticket_hook') %> <%- @ticket.number %> - <%- @T('created') %> ? <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> ?<% end %> + <%- @C('ticket_hook') %> <%- @ticket.number %> - <%- @T('created') %> ? <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> ?<% end %> \ No newline at end of file diff --git a/app/models/ticket/screen_options.rb b/app/models/ticket/screen_options.rb index 9e7037882..fb435ebab 100644 --- a/app/models/ticket/screen_options.rb +++ b/app/models/ticket/screen_options.rb @@ -44,10 +44,10 @@ returns def self.attributes_to_change(params) if params[:ticket_id] - params[:ticket] = self.find( params[:ticket_id] ) + params[:ticket] = Ticket.find( params[:ticket_id] ) end if params[:article_id] - params[:article] = self.find( params[:article_id] ) + params[:article] = Ticket::Article.find( params[:article_id] ) end filter = {} diff --git a/test/browser/agent_ticket_actions_level1_test.rb b/test/browser/agent_ticket_actions_level1_test.rb index 359577e64..76960f397 100644 --- a/test/browser/agent_ticket_actions_level1_test.rb +++ b/test/browser/agent_ticket_actions_level1_test.rb @@ -30,8 +30,8 @@ class AgentTicketActionLevel1Test < TestCase # remember old ticket where we want to merge to { :execute => 'match', - :css => '.active .ticket_info h3', - :value => '^#(.*)$', + :css => '.active .ticket-number', + :value => '^(.*)$', :no_quote => true, :match_result => true, }, @@ -158,7 +158,7 @@ class AgentTicketActionLevel1Test < TestCase # check if megred to ticket is shown now { :execute => 'match', - :css => '.active .ticket_info h3', + :css => '.active .ticket-number', :value => '###stack###', :match_result => true, }, diff --git a/test/browser/agent_ticket_actions_level2_test.rb b/test/browser/agent_ticket_actions_level2_test.rb index f8e7e1b4e..d7ae1d9ea 100644 --- a/test/browser/agent_ticket_actions_level2_test.rb +++ b/test/browser/agent_ticket_actions_level2_test.rb @@ -46,8 +46,8 @@ class AgentTicketActionsLevel2Test < TestCase { :where => :instance1, :execute => 'match', - :css => '.active .ticket_info h3', - :value => '^#(.*)$', + :css => '.active .ticket-number', + :value => '^(.*)$', :no_quote => true, :match_result => true, }, diff --git a/test/browser/agent_ticket_actions_level3_test.rb b/test/browser/agent_ticket_actions_level3_test.rb index 80e535f07..76f7f9863 100644 --- a/test/browser/agent_ticket_actions_level3_test.rb +++ b/test/browser/agent_ticket_actions_level3_test.rb @@ -46,7 +46,7 @@ class AgentTicketActionsLevel3Test < TestCase { :where => :instance1, :execute => 'match', - :css => '.active .ticket_info h3', + :css => '.active .ticket-number', :value => '^#(.*)$', :no_quote => true, :match_result => true, diff --git a/test/browser/agent_ticket_actions_level5_test.rb b/test/browser/agent_ticket_actions_level5_test.rb index bedf4be63..9ed3f8036 100644 --- a/test/browser/agent_ticket_actions_level5_test.rb +++ b/test/browser/agent_ticket_actions_level5_test.rb @@ -112,7 +112,7 @@ class AgentTicketActionLevel5Test < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_outbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'wait', @@ -186,7 +186,7 @@ class AgentTicketActionLevel5Test < TestCase { :where => :instance2, :execute => 'click', - :css => '.taskbar-new a[href="#ticket/create/call_inbound"]', + :css => '.taskbar-new a[href="#ticket/create"]', }, { :where => :instance2, @@ -202,7 +202,7 @@ class AgentTicketActionLevel5Test < TestCase { :where => :instance2, :execute => 'click', - :css => '.taskbar-new a[href="#ticket/create/call_outbound"]', + :css => '.taskbar-new a[href="#ticket/create"]', }, { :where => :instance2, diff --git a/test/browser/agent_user_manage_test.rb b/test/browser/agent_user_manage_test.rb index 9c8e05082..c07f0cbe5 100644 --- a/test/browser/agent_user_manage_test.rb +++ b/test/browser/agent_user_manage_test.rb @@ -24,7 +24,7 @@ class AgentUserManageTest < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_inbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'click', @@ -97,8 +97,7 @@ class AgentUserManageTest < TestCase # call new ticket screen again { - :execute => 'click', - :css => '.taskbar span[data-type="close"]', + :execute => 'close_all_tasks', }, { :execute => 'wait', @@ -120,7 +119,7 @@ class AgentUserManageTest < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_inbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'wait', diff --git a/test/browser/customer_ticket_create_test.rb b/test/browser/customer_ticket_create_test.rb index 1a556846f..f89e459d1 100644 --- a/test/browser/customer_ticket_create_test.rb +++ b/test/browser/customer_ticket_create_test.rb @@ -7,19 +7,23 @@ class CustomerTicketCreateTest < TestCase { :name => 'customer ticket create', :action => [ + { + :execute => 'click', + :css => 'a[href="#new"]', + }, { :execute => 'click', :css => 'a[href="#customer_ticket_new"]', }, + { + :execute => 'wait', + :value => 2, + }, { :execute => 'check', :css => '.ticket-create', :result => true, }, - { - :execute => 'wait', - :value => 1, - }, { :execute => 'select', :css => '.ticket-create select[name="group_id"]', diff --git a/test/browser/taskbar_task_test.rb b/test/browser/taskbar_task_test.rb index 4d0970edb..d5dc93df5 100644 --- a/test/browser/taskbar_task_test.rb +++ b/test/browser/taskbar_task_test.rb @@ -24,7 +24,7 @@ class TaskbarTaskTest < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_inbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'wait', @@ -73,8 +73,7 @@ class TaskbarTaskTest < TestCase :match_result => true, }, { - :execute => 'click', - :css => '.taskbar [data-type="close"]', + :execute => 'close_all_tasks', }, { :execute => 'match', @@ -105,7 +104,7 @@ class TaskbarTaskTest < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_inbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'wait', @@ -131,7 +130,7 @@ class TaskbarTaskTest < TestCase }, { :execute => 'click', - :css => 'a[href="#ticket/create/call_outbound"]', + :css => 'a[href="#ticket/create"]', }, { :execute => 'wait', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index ca6de3afa..3a4e8d8cf 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -229,6 +229,12 @@ class TestCase < Test::Unit::TestCase element.send_keys( action[:password] ) instance.find_element( { :css => '#login button' } ).click sleep 4 + login = instance.find_element( { :css => '.user-menu .user a' } ).attribute('title') + if login != action[:username] + assert( false, "(#{test[:name]}) login failed" ) + return + end + assert( true, "(#{test[:name]}) login success" ) return elsif action[:execute] == 'logout' instance.find_element( { :css => 'a[href="#current_user"]' } ).click @@ -250,6 +256,7 @@ class TestCase < Test::Unit::TestCase text = element.text if text =~ /#{action[:value]}/i assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" ) + sleep 0.4 return end sleep 0.33 @@ -296,7 +303,7 @@ class TestCase < Test::Unit::TestCase return elsif action[:execute] == 'create_ticket' instance.find_element( { :css => 'a[href="#new"]' } ).click - instance.find_element( { :css => 'a[href="#ticket/create/call_inbound"]' } ).click + instance.find_element( { :css => 'a[href="#ticket/create"]' } ).click element = instance.find_element( { :css => '.active .ticket-create' } ) if !element assert( false, "(#{test[:name]}) no ticket create screen found!" ) @@ -343,14 +350,20 @@ class TestCase < Test::Unit::TestCase elsif action[:execute] == 'close_all_tasks' for i in 1..100 begin - element = instance.find_element( { :css => '.taskbar [data-type="close"]' } ) - if element - element.click - sleep 0.8 + sleep 0.8 + hover_element = instance.find_element( { :css => '.navigation .tasks .task:first-child' } ) + if hover_element + instance.mouse.move_to(hover_element) + click_element = instance.find_element( { :css => '.navigation .tasks .task:first-child [data-type="close"]' } ) + if click_element + click_element.click + sleep 0.2 + end else break end - rescue + rescue => e + puts e.message break end end @@ -433,7 +446,9 @@ class TestCase < Test::Unit::TestCase end end else - if action[:css] =~ /(input|textarea)/i + if action[:attribute] + text = element.attribute( action[:attribute] ) + elsif action[:css] =~ /(input|textarea)/i text = element.attribute('value') else text = element.text