mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-29 11:52:34 +08:00
8133cc88d6
Summary: - We now make verbose log files continuously as you use the app - We ship the logs to LogStash via S3 when an exception occurs - We log the DatabaseStore, ActionBridge and Analytics packages - We are now on the latest version of Electron 0.26.0 - We are now on Chrome 42 and io.js 1.4.3 - We should be setup to use ASAR soon. Update atom.sh to reflect that we're now electron oniguruma was unnecessary correctly find log files that haven't been shipped yet Fix a small issue with nodeIsVisible after upgrade to Chrome 42 Delete old logs, better logging from database store, don't ship empty logs Test Plan: Run existing tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1531
101 lines
3.9 KiB
CoffeeScript
101 lines
3.9 KiB
CoffeeScript
Reflux = require 'reflux'
|
|
Actions = require '../src/flux/actions'
|
|
Message = require '../src/flux/models/message'
|
|
DatabaseStore = require '../src/flux/stores/database-store'
|
|
NamespaceStore = require '../src/flux/stores/namespace-store'
|
|
ActionBridge = require '../src/flux/action-bridge',
|
|
_ = require 'underscore'
|
|
|
|
ipc =
|
|
on: ->
|
|
send: ->
|
|
|
|
describe "ActionBridge", ->
|
|
|
|
describe "in the editor window", ->
|
|
beforeEach ->
|
|
spyOn(atom, "getWindowType").andReturn "default"
|
|
spyOn(atom, "isMainWindow").andReturn true
|
|
@bridge = new ActionBridge(ipc)
|
|
|
|
it "should have the role Role.ROOT", ->
|
|
expect(@bridge.role).toBe(ActionBridge.Role.ROOT)
|
|
|
|
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 a secondary window", ->
|
|
beforeEach ->
|
|
spyOn(atom, "getWindowType").andReturn "popout"
|
|
spyOn(atom, "isMainWindow").andReturn false
|
|
@bridge = new ActionBridge(ipc)
|
|
@message = new Message
|
|
id: 'test-id'
|
|
namespaceId: 'test-namespace-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.didSwapModel.firing = false
|
|
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didSwapModel', [{oldModel: '1', newModel: 2}])
|
|
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-all', 'popout', 'didSwapModel', '[{"oldModel":"1","newModel":2}]')
|
|
|
|
describe "when called with TargetWindows.MAIN", ->
|
|
it "should broadcast the action over IPC to the main window only", ->
|
|
spyOn(ipc, 'send')
|
|
Actions.didSwapModel.firing = false
|
|
@bridge.onRebroadcast(ActionBridge.TargetWindows.MAIN, 'didSwapModel', [{oldModel: '1', newModel: 2}])
|
|
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-main', 'popout', 'didSwapModel', '[{"oldModel":"1","newModel":2}]')
|
|
|
|
it "should not do anything if the current invocation of the Action was triggered by itself", ->
|
|
spyOn(ipc, 'send')
|
|
Actions.didSwapModel.firing = true
|
|
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didSwapModel', [{oldModel: '1', newModel: 2}])
|
|
expect(ipc.send).not.toHaveBeenCalled()
|