diff --git a/app/assets/javascripts/app/controllers/task_widget.js.coffee b/app/assets/javascripts/app/controllers/task_widget.js.coffee index 9ff02f63d..2d4f8c04a 100644 --- a/app/assets/javascripts/app/controllers/task_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/task_widget.js.coffee @@ -11,20 +11,19 @@ class App.TaskWidget extends App.Controller @render() # render view - App.Event.bind 'task:render', (data) => + App.Event.bind 'task:render', => @render() # render on login - App.Event.bind 'auth:login', (user) => + App.Event.bind 'auth:login', => @render() # reset current tasks on logout App.Event.bind 'auth:logout', => @el.html('') - App.TaskManager.reset() # only do take over check after spool messages are finised - App.Event.bind 'spool:sent', (data) => + App.Event.bind 'spool:sent', => @spoolSent = true # session take over message diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 45036ef33..de4458f0d 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -73,6 +73,21 @@ class _taskManagerSingleton extends App.Controller @activeTask = undefined @tasksInitial() + # render on login + App.Event.bind 'auth:login', => + @initialLoad = true + @all() + + # render on logout + App.Event.bind 'auth:logout', => + for task in @all + worker = @worker( task.key ) + if worker && worker.release + worker.release() + @workersStarted[ task.key ] = false + @reset() + + # send updates to server @interval( @taskUpdateLoop, 2500 ) all: -> diff --git a/test/browser/taskbar_task_test.rb b/test/browser/taskbar_task_test.rb index 3f1ae301b..ba0c26068 100644 --- a/test/browser/taskbar_task_test.rb +++ b/test/browser/taskbar_task_test.rb @@ -83,4 +83,118 @@ class TaskbarTaskTest < TestCase ] browser_signle_test_with_login(tests, { :username => 'agent1@example.com' }) end + def test_persistant_task_with_relogin + tests = [ + { + :name => 'persistant task', + :action => [ + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'close_all_tasks', + }, + { + :execute => 'click', + :css => 'a[href="#new"]', + }, + { + :execute => 'click', + :css => 'a[href="#ticket_create/call_inbound"]', + }, + { + :execute => 'wait', + :value => 3, + }, + { + :execute => 'set', + :css => '.active .ticket_create input[name="subject"]', + :value => 'INBOUND TEST#1', + }, + { + :execute => 'click', + :css => 'a[href="#new"]', + }, + { + :execute => 'click', + :css => 'a[href="#ticket_create/call_outbound"]', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :execute => 'set', + :css => '.active .ticket_create input[name="subject"]', + :value => 'OUTBOUND TEST#1', + }, + { + :execute => 'wait', + :value => 20, + }, + { + :execute => 'click', + :css => 'a[href="#current_user"]', + }, + { + :execute => 'click', + :css => 'a[href="#logout"]', + }, + { + :execute => 'wait', + :value => 1, + }, + { + :execute => 'check', + :css => '#login', + :result => true, + }, + { + :execute => 'match', + :css => 'body', + :value => 'INBOUND TEST#1', + :match_result => false, + }, + { + :execute => 'match', + :css => 'body', + :value => 'OUTBOUND TEST#1', + :match_result => false, + }, + { + :execute => 'set', + :css => 'input[name="username"]', + :value => 'agent1@example.com', + }, + { + :execute => 'set', + :css => 'input[name="password"]', + :value => 'test' + }, + { + :execute => 'click', + :css => '#login button', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'match', + :css => 'body', + :value => 'INBOUND TEST#1', + :match_result => true, + }, + { + :execute => 'match', + :css => 'body', + :value => 'OUTBOUND TEST#1', + :match_result => true, + }, + ], + }, + ] + browser_signle_test_with_login(tests, { :username => 'agent1@example.com' }) + end end