Added task modified tests. Added attachment reference tests.

This commit is contained in:
Martin Edenhofer 2015-03-08 02:06:04 +01:00
parent cf16efcc17
commit 87be963296
7 changed files with 231 additions and 25 deletions

View file

@ -419,6 +419,13 @@ class App.TicketCreate extends App.Controller
# save ticket, create article # save ticket, create article
else 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 # disable form
@formDisable(e) @formDisable(e)
ui = @ ui = @

View file

@ -262,6 +262,7 @@ class App.TicketZoom extends App.Controller
ticket: @ticket ticket: @ticket
overview_id: @overview_id overview_id: @overview_id
el: @el.find('.ticket-title') el: @el.find('.ticket-title')
task_key: @task_key
) )
new TicketMeta( new TicketMeta(
@ -639,26 +640,25 @@ class App.TicketZoom extends App.Controller
# validate article # validate article
articleParams = @formParam( @$('.article-add') ) articleParams = @formParam( @$('.article-add') )
console.log "submit article", articleParams console.log "submit article", articleParams
articleAttributes = App.TicketArticle.attributesGet( 'edit' ) if articleParams['body']
if articleParams['body'] #&& $( articleParams['body'] ).text() articleParams.from = @Session.get().displayName()
articleParams.from = @Session.get().displayName() articleParams.ticket_id = ticket.id
articleParams.ticket_id = ticket.id articleParams.form_id = @form_id
articleParams.form_id = @form_id
articleParams.content_type = 'text/html' articleParams.content_type = 'text/html'
if !articleParams['internal'] if !articleParams['internal']
articleParams['internal'] = false articleParams['internal'] = false
if @isRole('Customer') if @isRole('Customer')
sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' ) sender = App.TicketArticleSender.findByAttribute( 'name', 'Customer' )
type = App.TicketArticleType.findByAttribute( 'name', 'web' ) type = App.TicketArticleType.findByAttribute( 'name', 'web' )
articleParams.type_id = type.id articleParams.type_id = type.id
articleParams.sender_id = sender.id articleParams.sender_id = sender.id
else else
sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' ) sender = App.TicketArticleSender.findByAttribute( 'name', 'Agent' )
articleParams.sender_id = sender.id articleParams.sender_id = sender.id
type = App.TicketArticleType.findByAttribute( 'name', articleParams['type'] ) type = App.TicketArticleType.findByAttribute( 'name', articleParams['type'] )
articleParams.type_id = type.id articleParams.type_id = type.id
article = new App.TicketArticle article = new App.TicketArticle
for key, value of articleParams for key, value of articleParams
@ -670,23 +670,25 @@ class App.TicketZoom extends App.Controller
# check if recipient exists # check if recipient exists
if !articleParams['to'] && !articleParams['cc'] if !articleParams['to'] && !articleParams['cc']
alert( App.i18n.translateContent('Need recipient in "To" or "Cc".') ) alert( App.i18n.translateContent('Need recipient in "To" or "Cc".') )
@formEnable(e)
@autosaveStart() @autosaveStart()
return return
# check if message exists # check if message exists
if !articleParams['body'] if !articleParams['body']
alert( App.i18n.translateContent('Text needed') ) alert( App.i18n.translateContent('Text needed') )
@formEnable(e)
@autosaveStart() @autosaveStart()
return return
# check attachment # check attachment
if articleParams['body'] if articleParams['body']
attachmentTranslated = App.i18n.translateContent('Attachment') if App.Utils.checkAttachmentReference( articleParams['body'] )
attachmentTranslatedRegExp = new RegExp( attachmentTranslated, 'i' ) if @$('.article-add .textBubble .attachments .attachment').length < 1
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?') )
if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') ) @formEnable(e)
@autosaveStart() @autosaveStart()
return return
article.load(articleParams) article.load(articleParams)
errors = article.validate() errors = article.validate()
@ -714,6 +716,8 @@ class App.TicketZoom extends App.Controller
# reset form after save # reset form after save
@taskReset() @taskReset()
App.TaskManager.mute( @task_key )
@fetch( ticket.id, true ) @fetch( ticket.id, true )
) )
@ -800,6 +804,8 @@ class TicketTitle extends App.Controller
@ticket.save() @ticket.save()
App.TaskManager.mute( @task_key )
# update taskbar with new meta data # update taskbar with new meta data
App.Event.trigger 'task:render' App.Event.trigger 'task:render'

View file

@ -34,6 +34,11 @@ class App.TaskManager
_instance ?= new _taskManagerSingleton _instance ?= new _taskManagerSingleton
_instance.notify( key ) _instance.notify( key )
@mute: ( key ) ->
if _instance == undefined
_instance ?= new _taskManagerSingleton
_instance.mute( key )
@reorder: ( order ) -> @reorder: ( order ) ->
if _instance == undefined if _instance == undefined
_instance ?= new _taskManagerSingleton _instance ?= new _taskManagerSingleton
@ -328,6 +333,14 @@ class _taskManagerSingleton extends Spine.Module
task.notify = true task.notify = true
@taskUpdate( task ) @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) # set new order of tasks (needed for dnd)
reorder: ( order ) => reorder: ( order ) =>
prio = 0 prio = 0

View file

@ -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)

View file

@ -264,3 +264,12 @@ class App.Utils
value = undefined value = undefined
value 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

View file

@ -69,7 +69,7 @@ class AgentTicketActionsLevel2Test < TestCase
ticket_update( ticket_update(
:browser => browser2, :browser => browser2,
:data => { :data => {
:title => 'TTTsome level 2 <b>subject</b> 123äöü', :title => 'TTTsome level 2 <b>subject</b> 123äöü',
}, },
:do_not_submit => true, :do_not_submit => true,
) )
@ -89,7 +89,8 @@ class AgentTicketActionsLevel2Test < TestCase
verify_task( verify_task(
:browser => browser2, :browser => browser2,
:data => { :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( verify_task(
:browser => browser1, :browser => browser1,
:data => { :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', :css => '.active div.ticket-article',
:value => 'some update 4711', :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 # verify if text in input body is now empty
ticket_verify( 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 instances, verify again
reload( reload(
:browser => browser1, :browser => browser1,
@ -177,7 +195,8 @@ class AgentTicketActionsLevel2Test < TestCase
verify_task( verify_task(
:browser => browser2, :browser => browser2,
:data => { :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( verify_task(
:browser => browser1, :browser => browser1,
:data => { :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', :value => 'some update 4711',
) )
# verify if text in input body is now empty # verify if text in input body is now empty
ticket_verify( ticket_verify(
:browser => browser1, :browser => browser1,

View 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