mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
a31c2808a9
Summary: There were several issues causing uploading to not work: # The file upload response came back as a string instead of an Object. Needed to detect and `JSON.parse` # The `MessageAttachment` component was not available as a package on the popout composer (since it used to be inside of `MessageList`) # The `message.draft` bit was not set properly causing the DB changes to be ignored # The actions notifying of `uploadStateChanged` were only being broadcasted in the main window (where the `TaskStore` is) and never making it to the popout composer. Also keybindings for close window and up & down arrows were fixed. Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1157
83 lines
2.6 KiB
CoffeeScript
83 lines
2.6 KiB
CoffeeScript
_ = require "underscore-plus"
|
|
proxyquire = require "proxyquire"
|
|
|
|
React = require "react/addons"
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
{Contact,
|
|
Message,
|
|
Namespace,
|
|
DatabaseStore,
|
|
NamespaceStore} = require "inbox-exports"
|
|
|
|
u1 = new Contact(name: "Christine Spang", email: "spang@inboxapp.com")
|
|
u2 = new Contact(name: "Michael Grinich", email: "mg@inboxapp.com")
|
|
u3 = new Contact(name: "Evan Morikawa", email: "evan@inboxapp.com")
|
|
u4 = new Contact(name: "Zoë Leiper", email: "zip@inboxapp.com")
|
|
u5 = new Contact(name: "Ben Gotow", email: "ben@inboxapp.com")
|
|
users = [u1, u2, u3, u4, u5]
|
|
NamespaceStore._current = new Namespace(
|
|
{name: u1.name, provider: "inbox", emailAddress: u1.email})
|
|
|
|
reactStub = (className) ->
|
|
React.createClass({render: -> <div className={className}>{@props.children}</div>})
|
|
|
|
draftStoreProxyStub = (localId) ->
|
|
listen: -> # noop
|
|
draft: -> new Message()
|
|
|
|
searchContactStub = (email) ->
|
|
_.filter(users, (u) u.email.toLowerCase() is email.toLowerCase())
|
|
|
|
ComposerView = proxyquire "../lib/composer-view.cjsx",
|
|
"./file-uploads.cjsx": reactStub("file-uploads")
|
|
"./draft-store-proxy": draftStoreProxyStub
|
|
"./scribe-toolbar.cjsx": reactStub("scribe-toolbar")
|
|
"./scribe-component.cjsx": reactStub("scribe-component")
|
|
"./composer-participants.cjsx": reactStub("composer-participants")
|
|
"inbox-exports":
|
|
ContactStore:
|
|
searchContacts: (email) -> searchContactStub
|
|
ComponentRegistry:
|
|
listen: -> ->
|
|
findViewByName: (component) -> reactStub(component)
|
|
findAllViewsByRole: (role) -> [reactStub('a'),reactStub('b')]
|
|
|
|
describe "A blank composer view", ->
|
|
beforeEach ->
|
|
@view = ReactTestUtils.renderIntoDocument(
|
|
<ComposerView />
|
|
)
|
|
|
|
it 'should render into the document', ->
|
|
expect(ReactTestUtils.isCompositeComponentWithType @view, ComposerView).toBe true
|
|
|
|
|
|
beforeEach ->
|
|
# The NamespaceStore isn't set yet in the new window, populate it first.
|
|
NamespaceStore.populateItems().then ->
|
|
new Promise (resolve, reject) ->
|
|
draft = new Message
|
|
from: [NamespaceStore.current().me()]
|
|
date: (new Date)
|
|
draft: true
|
|
namespaceId: NamespaceStore.current().id
|
|
|
|
DatabaseStore.persistModel(draft).then ->
|
|
DatabaseStore.localIdForModel(draft).then(resolve).catch(reject)
|
|
.catch(reject)
|
|
|
|
describe "When composing a new message", ->
|
|
it "Can add someone in the to field", ->
|
|
|
|
it "Can add someone in the cc field", ->
|
|
|
|
it "Can add someone in the bcc field", ->
|
|
|
|
describe "When replying to a message", ->
|
|
|
|
describe "When replying all to a message", ->
|
|
|
|
describe "When forwarding a message", ->
|
|
|
|
describe "When changing the subject of a message", ->
|