Mailspring/spec-nylas/action-bridge-spec.coffee
Ben Gotow 91998d3b36 fix(onboarding): Tweaks, styles, etc. for new onboarding experience
Summary:
Remove logout menu item and buttons, turn Link External Account to Add Account

Onboarding window starts hidden, is shown when react component is mounted and sized

Use get/setBounds to animate position and size at the same time smoothly

Fix specs, change 401 notice

Delay bouncing to Gmail to show users the Gmail screen momentarily

Make the animated resizing code defer so it doesn't run in a hard loop, and other animations can run at the same time

Bring back crossfade between screens, remove left/right shift on welcome screens

Test Plan: Run tests

Reviewers: drew, evan

Reviewed By: evan

Maniphest Tasks: T3529

Differential Revision: https://phab.nylas.com/D2054
2015-09-23 09:59:34 -07:00

101 lines
4 KiB
CoffeeScript

Reflux = require 'reflux'
Actions = require '../src/flux/actions'
Message = require '../src/flux/models/message'
DatabaseStore = require '../src/flux/stores/database-store'
AccountStore = require '../src/flux/stores/account-store'
ActionBridge = require '../src/flux/action-bridge',
_ = require 'underscore'
ipc =
on: ->
send: ->
describe "ActionBridge", ->
describe "in the work window", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "default"
spyOn(atom, "isWorkWindow").andReturn true
@bridge = new ActionBridge(ipc)
it "should have the role Role.WORK", ->
expect(@bridge.role).toBe(ActionBridge.Role.WORK)
it "should rebroadcast global actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.globalActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should rebroadcast when the DatabaseStore triggers", ->
spyOn(@bridge, 'onRebroadcast')
DatabaseStore.trigger({})
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should not rebroadcast mainWindow actions since it is the main window", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions.didMakeAPIRequest
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
it "should not rebroadcast window actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.windowActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
describe "in another window", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "popout"
spyOn(atom, "isWorkWindow").andReturn false
@bridge = new ActionBridge(ipc)
@message = new Message
id: 'test-id'
accountId: TEST_ACCOUNT_ID
it "should have the role Role.SECONDARY", ->
expect(@bridge.role).toBe(ActionBridge.Role.SECONDARY)
it "should rebroadcast global actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.globalActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should rebroadcast mainWindow actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions.didMakeAPIRequest
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should not rebroadcast window actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.windowActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
describe "onRebroadcast", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "popout"
spyOn(atom, "isMainWindow").andReturn false
@bridge = new ActionBridge(ipc)
describe "when called with TargetWindows.ALL", ->
it "should broadcast the action over IPC to all windows", ->
spyOn(ipc, 'send')
Actions.didPassivelyReceiveNewModels.firing = false
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didPassivelyReceiveNewModels', [{oldModel: '1', newModel: 2}])
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-all', 'popout', 'didPassivelyReceiveNewModels', '[{"oldModel":"1","newModel":2}]')
describe "when called with TargetWindows.WORK", ->
it "should broadcast the action over IPC to the main window only", ->
spyOn(ipc, 'send')
Actions.didPassivelyReceiveNewModels.firing = false
@bridge.onRebroadcast(ActionBridge.TargetWindows.WORK, 'didPassivelyReceiveNewModels', [{oldModel: '1', newModel: 2}])
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-work', 'popout', 'didPassivelyReceiveNewModels', '[{"oldModel":"1","newModel":2}]')
it "should not do anything if the current invocation of the Action was triggered by itself", ->
spyOn(ipc, 'send')
Actions.didPassivelyReceiveNewModels.firing = true
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didPassivelyReceiveNewModels', [{oldModel: '1', newModel: 2}])
expect(ipc.send).not.toHaveBeenCalled()