Fixed "Loading…" bug in task bar, added more tests.

This commit is contained in:
Martin Edenhofer 2013-07-17 17:30:54 +02:00
parent 72dbd0a291
commit c907a4dd50
2 changed files with 76 additions and 11 deletions

View file

@ -66,7 +66,6 @@ class _taskManagerSingleton extends App.Controller
super
@workers = {}
@workersStarted = {}
@taskUpdateProcess = {}
@allTasks = []
@tasksToUpdate = {}
@initialLoad = true
@ -77,14 +76,10 @@ class _taskManagerSingleton extends App.Controller
App.Event.bind 'auth:login', =>
@initialLoad = true
@all()
@tasksInitial()
# render on logout
App.Event.bind 'auth:logout', =>
for task in @allTasks
worker = @worker( task.key )
if worker && worker.release
worker.release()
delete @workersStarted[ task.key ]
@reset()
# send updates to server
@ -127,7 +122,8 @@ class _taskManagerSingleton extends App.Controller
# create new task if not exists
task = @get( key )
# console.log('add', key, callback, params, to_not_show, task)
console.log('TASKBAR RESET', @allTasks)
console.log('add', key, callback, params, to_not_show, task)
if !task
task = new App.Taskbar
task.load(
@ -279,8 +275,23 @@ class _taskManagerSingleton extends App.Controller
@taskUpdate( task )
reset: =>
@allTasks = []
# release tasks
for task in @allTasks
worker = @worker( task.key )
if worker && worker.release
worker.release()
delete @workersStarted[ task.key ]
# clear instance vars
@tasksToUpdate = {}
@allTasks = []
@activeTask = undefined
# clear inmem tasks
App.Taskbar.deleteAll()
# rerender task bar
App.Event.trigger 'task:render'
TaskbarId: =>
@ -338,6 +349,7 @@ class _taskManagerSingleton extends App.Controller
return
tasksInitial: =>
# reopen tasks
App.Event.trigger 'taskbar:init'

View file

@ -90,7 +90,7 @@ class TaskbarTaskTest < TestCase
def test_persistant_task_with_relogin
tests = [
{
:name => 'persistant task',
:name => 'agent1 - create persistant task',
:action => [
{
:execute => 'wait',
@ -137,7 +137,7 @@ class TaskbarTaskTest < TestCase
:execute => 'wait',
:value => 20,
},
{
{
:execute => 'click',
:css => 'a[href="#current_user"]',
},
@ -145,9 +145,57 @@ class TaskbarTaskTest < TestCase
:execute => 'click',
:css => 'a[href="#logout"]',
},
{
:execute => 'check',
:css => '#login',
:result => true,
},
{
:execute => 'wait',
:value => 1,
:value => 10,
},
],
},
{
:name => 'relogin with master - task are not viewable',
:action => [
{
:execute => 'set',
:css => 'input[name="username"]',
:value => 'master@example.com',
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => 'test'
},
{
:execute => 'click',
:css => '#login button',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'match',
:css => 'body',
:value => 'INBOUND TEST#1',
:match_result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'OUTBOUND TEST#1',
:match_result => false,
},
{
:execute => 'click',
:css => 'a[href="#current_user"]',
},
{
:execute => 'click',
:css => 'a[href="#logout"]',
},
{
:execute => 'check',
@ -166,6 +214,11 @@ class TaskbarTaskTest < TestCase
:value => 'OUTBOUND TEST#1',
:match_result => false,
},
],
},
{
:name => 'relogin with agent - task are viewable',
:action => [
{
:execute => 'set',
:css => 'input[name="username"]',