Improved tests with task and title check.

This commit is contained in:
Martin Edenhofer 2015-03-01 10:11:13 +01:00
parent 18838cb7c5
commit 08bc3bda3e
3 changed files with 179 additions and 67 deletions

View file

@ -1,4 +1,4 @@
class Index extends App.ControllerContent class App.Dashboard extends App.Controller
constructor: -> constructor: ->
super super
@ -10,10 +10,6 @@ class Index extends App.ControllerContent
@navigate '#' @navigate '#'
return return
# set title
@title 'Dashboard'
@navupdate '#dashboard'
@plugins = { @plugins = {
main: { main: {
my_assigned: { my_assigned: {
@ -132,6 +128,46 @@ class Index extends App.ControllerContent
ctx.closePath() ctx.closePath()
ctx.fill() ctx.fill()
App.Config.set( 'dashboard', Index, 'Routes' ) active: (state) =>
@activeState = state
isActive: =>
@activeState
url: =>
'#dashboard'
show: (params) =>
# set title
@title 'Dashboard'
# highlight navbar
@navupdate '#dashboard'
hide: =>
# no
changed: =>
false
release: =>
# no
class DashboardRouter extends App.ControllerPermanent
constructor: (params) ->
super
App.TaskManager.execute(
key: 'Dashboard'
controller: 'Dashboard'
params: {}
show: true
persistent: true
)
App.Config.set( 'dashboard', DashboardRouter, 'Routes' )
App.Config.set( 'Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', role: ['Agent'], class: 'dashboard' }, 'NavBar' ) App.Config.set( 'Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', role: ['Agent'], class: 'dashboard' }, 'NavBar' )
App.Config.set( 'Dashboard', 'Dashboard', 'permanentTask' )

View file

@ -3,65 +3,130 @@ require 'browser_test_helper'
class AgentTicketActionLevel4Test < TestCase class AgentTicketActionLevel4Test < TestCase
def test_agent_ticket_create_with_reload def test_agent_ticket_create_with_reload
tests = [
{
:name => 'agent ticket create with reload',
:action => [
{
:execute => 'close_all_tasks',
},
# create ticket @browser = browser_instance
{ login(
:execute => 'create_ticket', :username => 'agent1@example.com',
:group => 'Users', :password => 'test',
:subject => 'some subject 4 - 123äöü', :url => browser_url,
:body => 'some body 4 - 123äöü', )
:do_not_submit => true, tasks_close_all()
},
{
:execute => 'wait',
:value => 10,
},
# reload instances, verify autosave # create ticket
{ ticket_create(
:execute => 'reload', :data => {
}, :customer => 'nicole',
{ :group => 'Users',
:execute => 'wait', :title => 'some subject 4 - 123äöü',
:value => 4, :body => 'some body 4 - 123äöü',
},
{
:execute => 'click',
:css => '.content.active button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
},
# check ticket
{
:execute => 'match',
:css => '.active div.ticket-article',
:value => 'some body 4 - 123äöü',
:match_result => true,
},
# close task/cleanup
{
:execute => 'close_all_tasks',
},
],
}, },
] :do_not_submit => true,
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' }) )
sleep 8
# check if customer is shown in sidebar
match(
:css => '.active .sidebar[data-tab="customer"]',
:value => 'nicole',
)
# check task title
verify_task(
:data => {
:title => 'some subject 4 - 123äöü',
}
)
# check page title
verify_title(
:value => 'some subject 4 - 123äöü',
)
# reload instances, verify autosave
reload()
# check if customer is still shown in sidebar
watch_for(
:css => '.active .sidebar[data-tab="customer"]',
:value => 'nicole',
)
# finally create ticket
click( :css => '.content.active button.submit' )
sleep 5
location_check(
:url => '#ticket/zoom/',
)
# check ticket
match(
:css => '.active div.ticket-article',
:value => 'some body 4 - 123äöü',
)
ticket_id = nil
if @browser.current_url =~ /ticket\/zoom\/(.+?)$/i
ticket_id = $1
end
# check task title
verify_task(
:data => {
:title => 'some subject 4 - 123äöü',
}
)
# check page title
verify_title(
:value => 'some subject 4 - 123äöü',
)
# check if task is not marked as modified
exists(
:css => ".tasks a[href=\"#ticket/zoom/#{ticket_id}\"]",
)
exists_not(
:css => ".tasks a[href=\"#ticket/zoom/#{ticket_id}\"] .modified",
)
# reload
reload()
sleep 5
# check task title
verify_task(
:data => {
:title => 'some subject 4 - 123äöü',
}
)
# check page title
verify_title(
:value => 'some subject 4 - 123äöü',
)
# go to dashboard
location(
:url => browser_url
)
sleep 5
# check page title
verify_title(
:value => 'Dashboard',
)
# reload
reload()
sleep 5
# check page title
verify_title(
:value => 'Dashboard',
)
# cleanup
tasks_close_all()
end end
end end

View file

@ -274,7 +274,8 @@ class TestCase < Test::Unit::TestCase
if params[:contenteditable] if params[:contenteditable]
value = instance.find_elements( { :css => params[:css] } )[0].text value = instance.find_elements( { :css => params[:css] } )[0].text
if value != params[:value] if value != params[:value]
instance.execute_script( "$('#{params[:css]}').focus().html('#{params[:value]}').trigger('focusout')" ) body_quoted = quote( params[:value] )
instance.execute_script( "$('#{params[:css]}').focus().html('#{body_quoted}').trigger('focusout')" )
end end
end end
@ -863,7 +864,8 @@ wait untill text in selector disabppears
value = instance.find_elements( { :css => '.content .newTicket div[data-name=body]' } )[0].text value = instance.find_elements( { :css => '.content .newTicket div[data-name=body]' } )[0].text
puts "V #{value.inspect}" puts "V #{value.inspect}"
if value != data[:body] if value != data[:body]
instance.execute_script( "$('.content.active div[data-name=body]').html('#{data[:body]}').trigger('focusout')" ) body_quoted = quote( data[:body] )
instance.execute_script( "$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')" )
end end
end end
if data[:customer] if data[:customer]
@ -982,7 +984,8 @@ wait untill text in selector disabppears
value = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0].text value = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0].text
puts "V #{value.inspect}" puts "V #{value.inspect}"
if value != data[:body] if value != data[:body]
instance.execute_script( "$('.content.active div[data-name=body]').html('#{data[:body]}').trigger('focusout')" ) body_quoted = quote( data[:body] )
instance.execute_script( "$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')" )
end end
end end
@ -1391,6 +1394,14 @@ wait untill text in selector disabppears
raise "text module creation failed" raise "text module creation failed"
end end
def quote(string)
string_quoted = string
string_quoted.gsub!(/&/, '&amp;')
string_quoted.gsub!(/</, '&lt;')
string_quoted.gsub!(/>/, '&gt;')
string_quoted
end
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
def browser_login(data) def browser_login(data)
all_tests = [ all_tests = [