Fixed browser tests.

This commit is contained in:
Martin Edenhofer 2014-09-15 11:06:13 +02:00
parent 63f1cc581f
commit 414654b026
10 changed files with 49 additions and 32 deletions

View file

@ -1,5 +1,5 @@
<h1><span contenteditable="true" class="ticket-title-update inline-edit"><%= @P( @ticket.title ) %></span></h1> <h1><span contenteditable="true" class="ticket-title-update inline-edit"><%= @P( @ticket.title ) %></span></h1>
<small class="task-subline"> <small class="task-subline">
<%- @C('ticket_hook') %> <%- @ticket.number %> - <%- @T('created') %> <span class="humanTimeFromNow" data-time="<%- @ticket.created_at %>">?</span> <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> <span class="humanTimeFromNow escalation" data-time="<%- @ticket.escalation_time %>">?</span><% end %> <%- @C('ticket_hook') %> <span class="ticket-number"><%- @ticket.number %></span> - <%- @T('created') %> <span class="humanTimeFromNow" data-time="<%- @ticket.created_at %>">?</span> <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> <span class="humanTimeFromNow escalation" data-time="<%- @ticket.escalation_time %>">?</span><% end %>
</small> </small>

View file

@ -44,10 +44,10 @@ returns
def self.attributes_to_change(params) def self.attributes_to_change(params)
if params[:ticket_id] if params[:ticket_id]
params[:ticket] = self.find( params[:ticket_id] ) params[:ticket] = Ticket.find( params[:ticket_id] )
end end
if params[:article_id] if params[:article_id]
params[:article] = self.find( params[:article_id] ) params[:article] = Ticket::Article.find( params[:article_id] )
end end
filter = {} filter = {}

View file

@ -30,8 +30,8 @@ class AgentTicketActionLevel1Test < TestCase
# remember old ticket where we want to merge to # remember old ticket where we want to merge to
{ {
:execute => 'match', :execute => 'match',
:css => '.active .ticket_info h3', :css => '.active .ticket-number',
:value => '^#(.*)$', :value => '^(.*)$',
:no_quote => true, :no_quote => true,
:match_result => true, :match_result => true,
}, },
@ -158,7 +158,7 @@ class AgentTicketActionLevel1Test < TestCase
# check if megred to ticket is shown now # check if megred to ticket is shown now
{ {
:execute => 'match', :execute => 'match',
:css => '.active .ticket_info h3', :css => '.active .ticket-number',
:value => '###stack###', :value => '###stack###',
:match_result => true, :match_result => true,
}, },

View file

@ -46,8 +46,8 @@ class AgentTicketActionsLevel2Test < TestCase
{ {
:where => :instance1, :where => :instance1,
:execute => 'match', :execute => 'match',
:css => '.active .ticket_info h3', :css => '.active .ticket-number',
:value => '^#(.*)$', :value => '^(.*)$',
:no_quote => true, :no_quote => true,
:match_result => true, :match_result => true,
}, },

View file

@ -46,7 +46,7 @@ class AgentTicketActionsLevel3Test < TestCase
{ {
:where => :instance1, :where => :instance1,
:execute => 'match', :execute => 'match',
:css => '.active .ticket_info h3', :css => '.active .ticket-number',
:value => '^#(.*)$', :value => '^#(.*)$',
:no_quote => true, :no_quote => true,
:match_result => true, :match_result => true,

View file

@ -112,7 +112,7 @@ class AgentTicketActionLevel5Test < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_outbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',
@ -186,7 +186,7 @@ class AgentTicketActionLevel5Test < TestCase
{ {
:where => :instance2, :where => :instance2,
:execute => 'click', :execute => 'click',
:css => '.taskbar-new a[href="#ticket/create/call_inbound"]', :css => '.taskbar-new a[href="#ticket/create"]',
}, },
{ {
:where => :instance2, :where => :instance2,
@ -202,7 +202,7 @@ class AgentTicketActionLevel5Test < TestCase
{ {
:where => :instance2, :where => :instance2,
:execute => 'click', :execute => 'click',
:css => '.taskbar-new a[href="#ticket/create/call_outbound"]', :css => '.taskbar-new a[href="#ticket/create"]',
}, },
{ {
:where => :instance2, :where => :instance2,

View file

@ -24,7 +24,7 @@ class AgentUserManageTest < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_inbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'click', :execute => 'click',
@ -97,8 +97,7 @@ class AgentUserManageTest < TestCase
# call new ticket screen again # call new ticket screen again
{ {
:execute => 'click', :execute => 'close_all_tasks',
:css => '.taskbar span[data-type="close"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',
@ -120,7 +119,7 @@ class AgentUserManageTest < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_inbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',

View file

@ -7,19 +7,23 @@ class CustomerTicketCreateTest < TestCase
{ {
:name => 'customer ticket create', :name => 'customer ticket create',
:action => [ :action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#customer_ticket_new"]', :css => 'a[href="#customer_ticket_new"]',
}, },
{
:execute => 'wait',
:value => 2,
},
{ {
:execute => 'check', :execute => 'check',
:css => '.ticket-create', :css => '.ticket-create',
:result => true, :result => true,
}, },
{
:execute => 'wait',
:value => 1,
},
{ {
:execute => 'select', :execute => 'select',
:css => '.ticket-create select[name="group_id"]', :css => '.ticket-create select[name="group_id"]',

View file

@ -24,7 +24,7 @@ class TaskbarTaskTest < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_inbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',
@ -73,8 +73,7 @@ class TaskbarTaskTest < TestCase
:match_result => true, :match_result => true,
}, },
{ {
:execute => 'click', :execute => 'close_all_tasks',
:css => '.taskbar [data-type="close"]',
}, },
{ {
:execute => 'match', :execute => 'match',
@ -105,7 +104,7 @@ class TaskbarTaskTest < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_inbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',
@ -131,7 +130,7 @@ class TaskbarTaskTest < TestCase
}, },
{ {
:execute => 'click', :execute => 'click',
:css => 'a[href="#ticket/create/call_outbound"]', :css => 'a[href="#ticket/create"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',

View file

@ -229,6 +229,12 @@ class TestCase < Test::Unit::TestCase
element.send_keys( action[:password] ) element.send_keys( action[:password] )
instance.find_element( { :css => '#login button' } ).click instance.find_element( { :css => '#login button' } ).click
sleep 4 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 return
elsif action[:execute] == 'logout' elsif action[:execute] == 'logout'
instance.find_element( { :css => 'a[href="#current_user"]' } ).click instance.find_element( { :css => 'a[href="#current_user"]' } ).click
@ -250,6 +256,7 @@ class TestCase < Test::Unit::TestCase
text = element.text text = element.text
if text =~ /#{action[:value]}/i if text =~ /#{action[:value]}/i
assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" ) assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
sleep 0.4
return return
end end
sleep 0.33 sleep 0.33
@ -296,7 +303,7 @@ class TestCase < Test::Unit::TestCase
return return
elsif action[:execute] == 'create_ticket' elsif action[:execute] == 'create_ticket'
instance.find_element( { :css => 'a[href="#new"]' } ).click 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' } ) element = instance.find_element( { :css => '.active .ticket-create' } )
if !element if !element
assert( false, "(#{test[:name]}) no ticket create screen found!" ) assert( false, "(#{test[:name]}) no ticket create screen found!" )
@ -343,14 +350,20 @@ class TestCase < Test::Unit::TestCase
elsif action[:execute] == 'close_all_tasks' elsif action[:execute] == 'close_all_tasks'
for i in 1..100 for i in 1..100
begin 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 else
break break
end end
rescue rescue => e
puts e.message
break break
end end
end end
@ -433,7 +446,9 @@ class TestCase < Test::Unit::TestCase
end end
end end
else 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') text = element.attribute('value')
else else
text = element.text text = element.text