Added task modified tests. Added attachment reference tests.
This commit is contained in:
parent
cf16efcc17
commit
87be963296
7 changed files with 231 additions and 25 deletions
|
@ -419,6 +419,13 @@ class App.TicketCreate extends App.Controller
|
|||
# save ticket, create article
|
||||
else
|
||||
|
||||
# check attachment
|
||||
if article['body']
|
||||
if App.Utils.checkAttachmentReference( article['body'] )
|
||||
if @$('.richtext .attachments .attachment').length < 1
|
||||
if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') )
|
||||
return
|
||||
|
||||
# disable form
|
||||
@formDisable(e)
|
||||
ui = @
|
||||
|
|
|
@ -262,6 +262,7 @@ class App.TicketZoom extends App.Controller
|
|||
ticket: @ticket
|
||||
overview_id: @overview_id
|
||||
el: @el.find('.ticket-title')
|
||||
task_key: @task_key
|
||||
)
|
||||
|
||||
new TicketMeta(
|
||||
|
@ -639,26 +640,25 @@ class App.TicketZoom extends App.Controller
|
|||
# validate article
|
||||
articleParams = @formParam( @$('.article-add') )
|
||||
console.log "submit article", articleParams
|
||||
articleAttributes = App.TicketArticle.attributesGet( 'edit' )
|
||||
if articleParams['body'] #&& $( articleParams['body'] ).text()
|
||||
articleParams.from = @Session.get().displayName()
|
||||
articleParams.ticket_id = ticket.id
|
||||
articleParams.form_id = @form_id
|
||||
if articleParams['body']
|
||||
articleParams.from = @Session.get().displayName()
|
||||
articleParams.ticket_id = ticket.id
|
||||
articleParams.form_id = @form_id
|
||||
articleParams.content_type = 'text/html'
|
||||
|
||||
if !articleParams['internal']
|
||||
articleParams['internal'] = false
|
||||
|
||||
if @isRole('Customer')
|
||||
sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' )
|
||||
type = App.TicketArticleType.findByAttribute( 'name', 'web' )
|
||||
articleParams.type_id = type.id
|
||||
articleParams.sender_id = sender.id
|
||||
sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' )
|
||||
type = App.TicketArticleType.findByAttribute( 'name', 'web' )
|
||||
articleParams.type_id = type.id
|
||||
articleParams.sender_id = sender.id
|
||||
else
|
||||
sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' )
|
||||
articleParams.sender_id = sender.id
|
||||
type = App.TicketArticleType.findByAttribute( 'name', articleParams['type'] )
|
||||
articleParams.type_id = type.id
|
||||
sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' )
|
||||
articleParams.sender_id = sender.id
|
||||
type = App.TicketArticleType.findByAttribute( 'name', articleParams['type'] )
|
||||
articleParams.type_id = type.id
|
||||
|
||||
article = new App.TicketArticle
|
||||
for key, value of articleParams
|
||||
|
@ -670,23 +670,25 @@ class App.TicketZoom extends App.Controller
|
|||
# check if recipient exists
|
||||
if !articleParams['to'] && !articleParams['cc']
|
||||
alert( App.i18n.translateContent('Need recipient in "To" or "Cc".') )
|
||||
@formEnable(e)
|
||||
@autosaveStart()
|
||||
return
|
||||
|
||||
# check if message exists
|
||||
if !articleParams['body']
|
||||
alert( App.i18n.translateContent('Text needed') )
|
||||
@formEnable(e)
|
||||
@autosaveStart()
|
||||
return
|
||||
|
||||
# check attachment
|
||||
if articleParams['body']
|
||||
attachmentTranslated = App.i18n.translateContent('Attachment')
|
||||
attachmentTranslatedRegExp = new RegExp( attachmentTranslated, 'i' )
|
||||
if articleParams['body'].match(/attachment/i) || articleParams['body'].match( attachmentTranslatedRegExp )
|
||||
if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') )
|
||||
@autosaveStart()
|
||||
return
|
||||
if App.Utils.checkAttachmentReference( articleParams['body'] )
|
||||
if @$('.article-add .textBubble .attachments .attachment').length < 1
|
||||
if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') )
|
||||
@formEnable(e)
|
||||
@autosaveStart()
|
||||
return
|
||||
|
||||
article.load(articleParams)
|
||||
errors = article.validate()
|
||||
|
@ -714,6 +716,8 @@ class App.TicketZoom extends App.Controller
|
|||
# reset form after save
|
||||
@taskReset()
|
||||
|
||||
App.TaskManager.mute( @task_key )
|
||||
|
||||
@fetch( ticket.id, true )
|
||||
)
|
||||
|
||||
|
@ -800,6 +804,8 @@ class TicketTitle extends App.Controller
|
|||
|
||||
@ticket.save()
|
||||
|
||||
App.TaskManager.mute( @task_key )
|
||||
|
||||
# update taskbar with new meta data
|
||||
App.Event.trigger 'task:render'
|
||||
|
||||
|
|
|
@ -34,6 +34,11 @@ class App.TaskManager
|
|||
_instance ?= new _taskManagerSingleton
|
||||
_instance.notify( key )
|
||||
|
||||
@mute: ( key ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _taskManagerSingleton
|
||||
_instance.mute( key )
|
||||
|
||||
@reorder: ( order ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _taskManagerSingleton
|
||||
|
@ -328,6 +333,14 @@ class _taskManagerSingleton extends Spine.Module
|
|||
task.notify = true
|
||||
@taskUpdate( task )
|
||||
|
||||
# unset notify of task
|
||||
mute: ( key ) =>
|
||||
task = @get( key )
|
||||
if !task
|
||||
throw "No such task with '#{key}' to mute"
|
||||
task.notify = false
|
||||
@taskUpdate( task )
|
||||
|
||||
# set new order of tasks (needed for dnd)
|
||||
reorder: ( order ) =>
|
||||
prio = 0
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class App.TestHelper
|
||||
@attachmentUploadFake: ( selector ) ->
|
||||
|
||||
fileTemplate = '''<div class="attachment horizontal">
|
||||
<div class="attachment-name u-highlight">fake.file</div>
|
||||
<div class="attachment-size">30 KB</div>
|
||||
<div class="attachment-delete js-delete align-right u-clickable" data-id="33009">
|
||||
<div class="delete icon"></div>Delete File
|
||||
</div>
|
||||
</div>'''
|
||||
$(selector).append(fileTemplate)
|
|
@ -264,3 +264,12 @@ class App.Utils
|
|||
value = undefined
|
||||
|
||||
value
|
||||
|
||||
# check if attachment is referenced in message
|
||||
@checkAttachmentReference: (message) ->
|
||||
return false if !message
|
||||
return true if message.match(/attachment/i)
|
||||
attachmentTranslated = App.i18n.translateContent('Attachment')
|
||||
attachmentTranslatedRegExp = new RegExp( attachmentTranslated, 'i' )
|
||||
return true if message.match( attachmentTranslatedRegExp )
|
||||
false
|
||||
|
|
|
@ -69,7 +69,7 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
ticket_update(
|
||||
:browser => browser2,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
|
||||
:title => 'TTTsome level 2 <b>subject</b> 123äöü',
|
||||
},
|
||||
:do_not_submit => true,
|
||||
)
|
||||
|
@ -89,7 +89,8 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
verify_task(
|
||||
:browser => browser2,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => false,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -107,7 +108,8 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
verify_task(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => true,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -137,6 +139,13 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
:css => '.active div.ticket-article',
|
||||
:value => 'some update 4711',
|
||||
)
|
||||
verify_task(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => false,
|
||||
}
|
||||
)
|
||||
|
||||
# verify if text in input body is now empty
|
||||
ticket_verify(
|
||||
|
@ -154,6 +163,15 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
},
|
||||
)
|
||||
|
||||
# verify task
|
||||
verify_task(
|
||||
:browser => browser2,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => true,
|
||||
}
|
||||
)
|
||||
|
||||
# reload instances, verify again
|
||||
reload(
|
||||
:browser => browser1,
|
||||
|
@ -177,7 +195,8 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
verify_task(
|
||||
:browser => browser2,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => false, # modify was muted at reload ticket tab
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -194,7 +213,8 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
verify_task(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:title => 'TTTsome level 2 <b>subject<\/b> 123äöü',
|
||||
:modified => false,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -210,7 +230,6 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
:value => 'some update 4711',
|
||||
)
|
||||
|
||||
|
||||
# verify if text in input body is now empty
|
||||
ticket_verify(
|
||||
:browser => browser1,
|
||||
|
|
141
test/browser/agent_ticket_actions_level6_test.rb
Normal file
141
test/browser/agent_ticket_actions_level6_test.rb
Normal file
|
@ -0,0 +1,141 @@
|
|||
# encoding: utf-8
|
||||
require 'browser_test_helper'
|
||||
|
||||
class AgentTicketActionLevel6Test < TestCase
|
||||
def test_ticket
|
||||
|
||||
@browser = browser_instance
|
||||
login(
|
||||
:username => 'agent1@example.com',
|
||||
:password => 'test',
|
||||
:url => browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
#
|
||||
# attachment checks - new ticket
|
||||
#
|
||||
|
||||
# create new ticket with no attachment, attachment check should pop up
|
||||
ticket1 = ticket_create(
|
||||
:data => {
|
||||
:customer => 'nico',
|
||||
:group => 'Users',
|
||||
:title => 'test 6 - ticket 1',
|
||||
:body => 'test 6 - ticket 1 - with the word attachment, but not attachment atteched it should give an warning on submit',
|
||||
},
|
||||
:do_not_submit => true,
|
||||
)
|
||||
sleep 1
|
||||
|
||||
# submit form
|
||||
click( :css => '.content.active button.submit' )
|
||||
sleep 2
|
||||
|
||||
# check warning
|
||||
alert = @browser.switch_to.alert
|
||||
alert.dismiss()
|
||||
#alert.accept()
|
||||
#alert = alert.text
|
||||
|
||||
# add attachment, attachment check should quiet
|
||||
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .richtext .attachments')" )
|
||||
|
||||
# submit form
|
||||
click( :css => '.content.active button.submit' )
|
||||
sleep 5
|
||||
|
||||
# no warning
|
||||
#alert = @browser.switch_to.alert
|
||||
|
||||
# check if ticket is shown
|
||||
location_check( :url => '#ticket/zoom/' )
|
||||
|
||||
|
||||
|
||||
#
|
||||
# attachment checks - update ticket
|
||||
#
|
||||
|
||||
# update ticket with no attachment, attachment check should pop up
|
||||
ticket_update(
|
||||
:data => {
|
||||
:body => 'test 6 - ticket 1-1 - with the word attachment, but not attachment atteched it should give an warning on submit',
|
||||
},
|
||||
:do_not_submit => true,
|
||||
)
|
||||
|
||||
# submit form
|
||||
click(
|
||||
:css => '.active button.js-submit',
|
||||
)
|
||||
sleep 2
|
||||
|
||||
# check warning
|
||||
alert = @browser.switch_to.alert
|
||||
alert.dismiss()
|
||||
|
||||
# add attachment, attachment check should quiet
|
||||
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .article-add .textBubble .attachments')" )
|
||||
|
||||
# submit form
|
||||
click(
|
||||
:css => '.active button.js-submit',
|
||||
)
|
||||
sleep 2
|
||||
|
||||
# no warning
|
||||
#alert = @browser.switch_to.alert
|
||||
|
||||
# check if article exists
|
||||
|
||||
# discard changes should gone away
|
||||
watch_for_disappear(
|
||||
:css => '.content.active .js-reset',
|
||||
:value => '(Discard your unsaved changes.|Verwerfen der)',
|
||||
:no_quote => true,
|
||||
)
|
||||
ticket_verify(
|
||||
:data => {
|
||||
:body => '',
|
||||
},
|
||||
)
|
||||
|
||||
# check content and edit screen in instance 1
|
||||
match(
|
||||
:css => '.active div.ticket-article',
|
||||
:value => 'test 6 - ticket 1-1',
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# ticket customer change checks
|
||||
#
|
||||
|
||||
# update customer, check if new customer is shown in side bar
|
||||
|
||||
|
||||
# check if customer has changed in second browser
|
||||
|
||||
|
||||
#
|
||||
# ticket customer organization change checks
|
||||
#
|
||||
|
||||
# change org of customer, check if org is shown in sidebar
|
||||
|
||||
|
||||
# check if org has changed in second browser
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# form change/reset checks
|
||||
#
|
||||
|
||||
|
||||
# some form reset checks
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue