Added login/logout support for taskbar. Added browser tests.

This commit is contained in:
Martin Edenhofer 2013-06-25 14:46:19 +02:00
parent 949686a369
commit 951b3d1b6a
3 changed files with 132 additions and 4 deletions

View file

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

View file

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

View file

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