Improved agent browser tests.

This commit is contained in:
Martin Edenhofer 2013-04-23 20:36:09 +02:00
parent 0e60699d45
commit 062fe08215
6 changed files with 328 additions and 127 deletions

View file

@ -50,7 +50,9 @@ class _Singleton extends App.Controller
return key if to_not_show
$('#content').empty()
$('.content_permanent').hide()
$('.content_permanent').removeClass('active')
$('#content_permanent_' + key ).show()
$('#content_permanent_' + key ).addClass('active')
@tasks[key].worker.activate()
for task_key, task of @tasks
if task_key isnt key
@ -75,8 +77,11 @@ class _Singleton extends App.Controller
if active
$('.content_permanent').hide()
$('.content_permanent').removeClass('active')
$('#content_permanent_' + @task_count ).show()
$('#content_permanent_' + @task_count ).addClass('active')
else
$('#content_permanent_' + @task_count ).removeClass('active')
$('#content_permanent_' + @task_count ).hide()
params_app = _.clone(params)
params_app['el'] = $('#content_permanent_' + @task_count )

View file

@ -1,4 +1,4 @@
<div class="page-header">
<div class="page-header ticket-zoom">
<div class="row">
<div class="span10">
<h1><span contenteditable="true" class="title_update inline-edit"><%= @P( @ticket.title ) %></span> <small><%= @ticket.number %></small></h1>

View file

@ -1,5 +1,5 @@
<div class="well taskbar">
<% for item in @item_list: %>
<span class="label <% if item.task.active: %>label-success<% else: %>label-info<% end %>" data-id="<%- item.key %>"><span class="task"><a href="<%- item.data.url %>" title="<%= item.data.title %>"><%- item.data.head %></a></span><a href="#" data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a></span>
<span class="label <% if item.task.active: %>active label-success<% else: %>label-info<% end %>" data-id="<%- item.key %>"><span class="task"><a href="<%- item.data.url %>" title="<%= item.data.title %>"><%- item.data.head %></a></span><a href="#" data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a></span>
<% end %>
</div>

View file

@ -0,0 +1,298 @@
# encoding: utf-8
require 'browser_test_helper'
class AgentTicketActionSimpleTest < TestCase
def test_customer_ticket_create
tests = [
{
:name => 'agent ticket create 1',
:action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.ticket_create input[name="subject"]',
:value => 'some subject 123äöü',
},
{
:execute => 'set',
:css => '.ticket_create textarea[name="body"]',
:value => 'some body 123äöü',
},
{
:execute => 'click',
:css => '.form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket
{
:execute => 'match',
:css => 'div.article',
:value => 'some body 123äöü',
:match_result => true,
},
# remember old ticket where we want to merge to
{
:execute => 'match',
:css => '.ticket-zoom small',
:value => '^(.*)$',
:no_quote => true,
:match_result => true,
},
# update ticket
{
:execute => 'check',
:css => 'textarea[name="body"]',
:result => true,
},
{
:execute => 'set',
:css => 'textarea[name="body"]',
:value => 'some body 1234 äöüß',
},
{
:execute => 'click',
:css => 'button',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => 'body',
:value => 'some body 1234 äöüß',
:match_result => true,
},
{
:execute => 'click',
:css => '#task [data-type="close"]',
},
],
},
{
:name => 'agent ticket create 2',
:action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.ticket_create input[name="subject"]',
:value => 'test to merge',
},
{
:execute => 'set',
:css => '.ticket_create textarea[name="body"]',
:value => 'some body 123äöü 222',
},
{
:execute => 'click',
:css => '.form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket
{
:execute => 'match',
:css => '.content_permanent.active',
:value => 'some body 123äöü 222',
:match_result => true,
},
# update ticket
{
:execute => 'check',
:css => '.content_permanent.active textarea[name="body"]',
:result => true,
},
{
:execute => 'set',
:css => 'textarea[name="body"]',
:value => 'some body 1234 äöüß 222',
},
{
:execute => 'click',
:css => 'button',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => '.ticket-answer',
:value => 'some body 1234 äöüß 222',
:match_result => true,
},
# check if task is shown
{
:execute => 'match',
:css => 'body',
:value => 'test to merge',
:match_result => true,
},
],
},
{
:name => 'agent ticket merge',
:action => [
{
:execute => 'click',
:css => 'a[data-type="merge"]',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'set',
:css => '.modal input[name="master_ticket_number"]',
:value => '###stack###',
},
{
:execute => 'click',
:css => '.modal button[type="submit"]',
},
{
:execute => 'wait',
:value => 4,
},
# check if megred to ticket is shown now
{
:execute => 'match',
:css => '.ticket-zoom small',
:value => '###stack###',
:match_result => true,
},
# check if task is now gone
{
:execute => 'match',
:css => 'body',
:value => 'test to merge',
:match_result => false,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end
end

View file

@ -1,123 +0,0 @@
# encoding: utf-8
require 'browser_test_helper'
class AgentTicketCreateTest < TestCase
def test_customer_ticket_create
tests = [
{
:name => 'agent ticket create',
:action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.ticket_create input[name="subject"]',
:value => 'some subject 123äöü',
},
{
:execute => 'set',
:css => '.ticket_create textarea[name="body"]',
:value => 'some body 123äöü',
},
{
:execute => 'click',
:css => '.form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket
{
:execute => 'match',
:css => 'div.article',
:value => 'some body 123äöü',
:match_result => true,
},
# update ticket
{
:execute => 'check',
:css => 'textarea[name="body"]',
:result => true,
},
{
:execute => 'set',
:css => 'textarea[name="body"]',
:value => 'some body 1234 äöüß',
},
{
:execute => 'click',
:css => 'button',
:type => 'submit',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => 'body',
:value => 'some body 1234 äöüß',
:match_result => true,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end
end

View file

@ -135,6 +135,7 @@ class TestCase < Test::Unit::TestCase
def browser_single_test(tests, keep_connection = false)
instance = nil
@stack = nil
tests.each { |test|
if test[:instance]
instance = test[:instance]
@ -183,7 +184,11 @@ class TestCase < Test::Unit::TestCase
end
if action[:execute] == 'set'
element.clear
element.send_keys( action[:value] )
if action[:value] == '###stack###'
element.send_keys( @stack )
else
element.send_keys( action[:value] )
end
elsif action[:execute] == 'sendkey'
element.send_keys( action[:value] )
elsif action[:execute] == 'select'
@ -227,7 +232,23 @@ class TestCase < Test::Unit::TestCase
else
text = element.text
end
if text =~ /#{Regexp.quote(action[:value])}/
if action[:value] == '###stack###'
action[:value] = @stack
end
match = false
if action[:no_quote]
if text =~ /#{action[:value]}/
if $1
@stack = $1
end
match = $1 || true
end
else
if text =~ /#{Regexp.quote(action[:value])}/
match = true
end
end
if match
if action[:match_result]
assert( true, "(#{test[:name]}) matching '#{action[:value]}' in content '#{text}'" )
else