2015-02-25 08:20:57 +08:00
|
|
|
proxyquire = require 'proxyquire'
|
2016-03-29 16:41:24 +08:00
|
|
|
React = require "react"
|
|
|
|
ReactDOM = require "react-dom"
|
|
|
|
ReactTestUtils = require 'react-addons-test-utils'
|
2015-02-25 08:20:57 +08:00
|
|
|
|
|
|
|
{Contact,
|
|
|
|
Message,
|
|
|
|
File,
|
2015-03-11 02:05:30 +08:00
|
|
|
Thread,
|
2015-03-21 07:16:09 +08:00
|
|
|
Utils,
|
2015-12-08 07:34:03 +08:00
|
|
|
QuotedHTMLTransformer,
|
2015-08-18 07:23:12 +08:00
|
|
|
FileDownloadStore,
|
|
|
|
MessageBodyProcessor} = require "nylas-exports"
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-11-07 07:53:21 +08:00
|
|
|
MessageItemBody = React.createClass({render: -> <div></div>})
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
|
2015-05-15 08:08:30 +08:00
|
|
|
{InjectedComponent} = require 'nylas-component-kit'
|
2015-06-12 02:52:49 +08:00
|
|
|
|
2015-02-25 08:20:57 +08:00
|
|
|
file = new File
|
|
|
|
id: 'file_1_id'
|
|
|
|
filename: 'a.png'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
|
|
|
file_not_downloaded = new File
|
|
|
|
id: 'file_2_id'
|
|
|
|
filename: 'b.png'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
|
|
|
file_inline = new File
|
|
|
|
id: 'file_inline_id'
|
|
|
|
filename: 'c.png'
|
|
|
|
contentId: 'file_inline_id'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
|
|
|
file_inline_downloading = new File
|
|
|
|
id: 'file_inline_downloading_id'
|
|
|
|
filename: 'd.png'
|
|
|
|
contentId: 'file_inline_downloading_id'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
|
|
|
file_inline_not_downloaded = new File
|
|
|
|
id: 'file_inline_not_downloaded_id'
|
|
|
|
filename: 'e.png'
|
|
|
|
contentId: 'file_inline_not_downloaded_id'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
2015-03-14 01:55:28 +08:00
|
|
|
file_cid_but_not_referenced = new File
|
|
|
|
id: 'file_cid_but_not_referenced'
|
|
|
|
filename: 'f.png'
|
|
|
|
contentId: 'file_cid_but_not_referenced'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
2015-05-29 09:15:47 +08:00
|
|
|
file_cid_but_not_referenced_or_image = new File
|
|
|
|
id: 'file_cid_but_not_referenced_or_image'
|
|
|
|
filename: 'ansible notes.txt'
|
|
|
|
contentId: 'file_cid_but_not_referenced_or_image'
|
|
|
|
contentType: 'text/plain'
|
|
|
|
size: 300
|
2015-06-26 00:51:46 +08:00
|
|
|
file_without_filename = new File
|
|
|
|
id: 'file_without_filename'
|
|
|
|
contentType: 'image/png'
|
|
|
|
size: 10
|
2015-02-25 08:20:57 +08:00
|
|
|
|
|
|
|
download =
|
|
|
|
fileId: 'file_1_id'
|
|
|
|
download_inline =
|
|
|
|
fileId: 'file_inline_downloading_id'
|
|
|
|
|
|
|
|
user_1 = new Contact
|
|
|
|
name: "User One"
|
2015-05-15 08:08:30 +08:00
|
|
|
email: "user1@nylas.com"
|
2015-02-25 08:20:57 +08:00
|
|
|
user_2 = new Contact
|
|
|
|
name: "User Two"
|
2015-05-15 08:08:30 +08:00
|
|
|
email: "user2@nylas.com"
|
2015-02-25 08:20:57 +08:00
|
|
|
user_3 = new Contact
|
|
|
|
name: "User Three"
|
2015-05-15 08:08:30 +08:00
|
|
|
email: "user3@nylas.com"
|
2015-02-25 08:20:57 +08:00
|
|
|
user_4 = new Contact
|
|
|
|
name: "User Four"
|
2015-05-15 08:08:30 +08:00
|
|
|
email: "user4@nylas.com"
|
2015-02-25 08:20:57 +08:00
|
|
|
user_5 = new Contact
|
|
|
|
name: "User Five"
|
2015-05-15 08:08:30 +08:00
|
|
|
email: "user5@nylas.com"
|
2015-02-25 08:20:57 +08:00
|
|
|
|
|
|
|
|
2015-03-21 08:51:49 +08:00
|
|
|
MessageItem = proxyquire '../lib/message-item',
|
2015-11-07 07:53:21 +08:00
|
|
|
'./message-item-body': MessageItemBody
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2016-08-19 09:11:52 +08:00
|
|
|
MessageTimestamp = require('../lib/message-timestamp').default
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-02-25 08:20:57 +08:00
|
|
|
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
xdescribe "MessageItem", ->
|
2015-02-25 08:20:57 +08:00
|
|
|
beforeEach ->
|
|
|
|
spyOn(FileDownloadStore, 'pathForFile').andCallFake (f) ->
|
|
|
|
return '/fake/path.png' if f.id is file.id
|
|
|
|
return '/fake/path-inline.png' if f.id is file_inline.id
|
|
|
|
return '/fake/path-downloading.png' if f.id is file_inline_downloading.id
|
|
|
|
return null
|
2015-06-16 09:48:17 +08:00
|
|
|
spyOn(FileDownloadStore, 'downloadDataForFiles').andCallFake (ids) ->
|
2015-02-25 08:20:57 +08:00
|
|
|
return {'file_1_id': download, 'file_inline_downloading_id': download_inline}
|
|
|
|
|
2016-03-10 10:02:21 +08:00
|
|
|
spyOn(MessageBodyProcessor, '_addToCache').andCallFake ->
|
2015-08-18 07:23:12 +08:00
|
|
|
|
2015-02-25 08:20:57 +08:00
|
|
|
@message = new Message
|
|
|
|
id: "111"
|
|
|
|
from: [user_1]
|
|
|
|
to: [user_2]
|
|
|
|
cc: [user_3, user_4]
|
|
|
|
bcc: null
|
|
|
|
body: "Body One"
|
|
|
|
date: new Date(1415814587)
|
|
|
|
draft: false
|
|
|
|
files: []
|
|
|
|
unread: false
|
|
|
|
snippet: "snippet one..."
|
|
|
|
subject: "Subject One"
|
|
|
|
threadId: "thread_12345"
|
2015-08-29 02:12:53 +08:00
|
|
|
accountId: TEST_ACCOUNT_ID
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-03-11 02:05:30 +08:00
|
|
|
@thread = new Thread
|
|
|
|
id: 'thread-111'
|
2016-01-29 03:13:59 +08:00
|
|
|
accountId: TEST_ACCOUNT_ID
|
2015-03-11 02:05:30 +08:00
|
|
|
|
2015-02-25 08:20:57 +08:00
|
|
|
@threadParticipants = [user_1, user_2, user_3, user_4]
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-02-25 08:20:57 +08:00
|
|
|
# Generate the test component. Should be called after @message is configured
|
|
|
|
# for the test, since MessageItem assumes attributes of the message will not
|
|
|
|
# change after getInitialState runs.
|
|
|
|
@createComponent = ({collapsed} = {}) =>
|
|
|
|
collapsed ?= false
|
|
|
|
@component = ReactTestUtils.renderIntoDocument(
|
|
|
|
<MessageItem key={@message.id}
|
|
|
|
message={@message}
|
2015-03-11 02:05:30 +08:00
|
|
|
thread={@thread}
|
2015-07-24 01:57:13 +08:00
|
|
|
collapsed={collapsed} />
|
2015-02-25 08:20:57 +08:00
|
|
|
)
|
2015-03-10 02:17:22 +08:00
|
|
|
|
|
|
|
# TODO: We currently don't support collapsed messages
|
|
|
|
# describe "when collapsed", ->
|
|
|
|
# beforeEach ->
|
|
|
|
# @createComponent({collapsed: true})
|
|
|
|
#
|
|
|
|
# it "should not render the EmailFrame", ->
|
|
|
|
# expect( -> ReactTestUtils.findRenderedComponentWithType(@component, EmailFrameStub)).toThrow()
|
|
|
|
#
|
|
|
|
# it "should have the `collapsed` class", ->
|
2016-03-29 16:41:24 +08:00
|
|
|
# expect(ReactDOM.findDOMNode(@component).className.indexOf('collapsed') >= 0).toBe(true)
|
2015-03-10 02:17:22 +08:00
|
|
|
|
|
|
|
describe "when displaying detailed headers", ->
|
2015-02-25 08:20:57 +08:00
|
|
|
beforeEach ->
|
2015-03-10 02:17:22 +08:00
|
|
|
@createComponent({collapsed: false})
|
|
|
|
@component.setState detailedHeaders: true
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-03-10 02:17:22 +08:00
|
|
|
it "correctly sets the participant states", ->
|
2016-02-04 03:22:12 +08:00
|
|
|
participants = ReactTestUtils.scryRenderedDOMComponentsWithClass(@component, "expanded-participants")
|
|
|
|
expect(participants.length).toBe 2
|
2015-03-10 02:17:22 +08:00
|
|
|
expect(-> ReactTestUtils.findRenderedDOMComponentWithClass(@component, "collapsed-participants")).toThrow()
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-03-10 02:17:22 +08:00
|
|
|
it "correctly sets the timestamp", ->
|
|
|
|
ts = ReactTestUtils.findRenderedComponentWithType(@component, MessageTimestamp)
|
|
|
|
expect(ts.props.isDetailed).toBe true
|
2015-02-25 08:20:57 +08:00
|
|
|
|
|
|
|
describe "when not collapsed", ->
|
|
|
|
beforeEach ->
|
|
|
|
@createComponent({collapsed: false})
|
|
|
|
|
2015-11-07 07:53:21 +08:00
|
|
|
it "should render the MessageItemBody", ->
|
|
|
|
frame = ReactTestUtils.findRenderedComponentWithType(@component, MessageItemBody)
|
2015-02-25 08:20:57 +08:00
|
|
|
expect(frame).toBeDefined()
|
|
|
|
|
|
|
|
it "should not have the `collapsed` class", ->
|
2016-03-29 16:41:24 +08:00
|
|
|
expect(ReactDOM.findDOMNode(@component).className.indexOf('collapsed') >= 0).toBe(false)
|
2015-03-14 01:55:28 +08:00
|
|
|
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
xdescribe "when the message contains attachments", ->
|
2015-02-25 08:20:57 +08:00
|
|
|
beforeEach ->
|
2015-03-14 01:55:28 +08:00
|
|
|
@message.files = [
|
|
|
|
file,
|
|
|
|
file_not_downloaded,
|
|
|
|
file_cid_but_not_referenced,
|
2015-05-29 09:15:47 +08:00
|
|
|
file_cid_but_not_referenced_or_image,
|
2015-03-14 01:55:28 +08:00
|
|
|
|
|
|
|
file_inline,
|
|
|
|
file_inline_downloading,
|
|
|
|
file_inline_not_downloaded,
|
2015-06-26 00:51:46 +08:00
|
|
|
file_without_filename
|
2015-03-14 01:55:28 +08:00
|
|
|
]
|
|
|
|
@message.body = """
|
|
|
|
<img alt=\"A\" src=\"cid:#{file_inline.contentId}\"/>
|
|
|
|
<img alt=\"B\" src=\"cid:#{file_inline_downloading.contentId}\"/>
|
|
|
|
<img alt=\"C\" src=\"cid:#{file_inline_not_downloaded.contentId}\"/>
|
|
|
|
<img src=\"cid:missing-attachment\"/>
|
|
|
|
"""
|
2015-02-25 08:20:57 +08:00
|
|
|
@createComponent()
|
|
|
|
|
|
|
|
it "should include the attachments area", ->
|
|
|
|
attachments = ReactTestUtils.findRenderedDOMComponentWithClass(@component, 'attachments-area')
|
|
|
|
expect(attachments).toBeDefined()
|
|
|
|
|
:art:(attachments): DRY and cleanup attachment components code
Summary:
The attachment components were the only React Components which used
inheritance between components, which is an anti-pattern in react. I
deleted these components in favor of new purely functional/dumb
components exposed via the component-kit: Attachment Item and
ImageAttachmentItem. These are defined in the same file to reuse some
smaller components between them, like the progress-bar, etc.
The attachments pacakage still remains, and only registers a single component to
a new are called MessageAttachments. This InjectedComponent role is
shared by the Composer and MessageItem, and is the only reason this
exists as an injected component in a separate package.
MessageAttachments renders all image and non image attachments for a
message or draft, and binds the appropriate actions for removal, downloading, etc.
The composer still used FileUpload and ImageUpload components for rendering
uploads in the Composer (i.e. when you add an attachment (these are
different from files because they aren't saved until the draft is
sent)). These 2 components were pretty much copied and pasted from the
ones in the attachments package, with subtle differences-- I got rid of
these as well in favor of the new AttachmentItem and ImageAttachmentItem
Also convert more coffee to ES6!
Test Plan: Unit tests
Reviewers: bengotow, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D3381
2016-11-01 08:26:07 +08:00
|
|
|
it 'injects a MessageAttachments component for any present attachments', ->
|
|
|
|
els = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: "MessageAttachments"})
|
|
|
|
expect(els.length).toBe 1
|
2015-03-14 01:55:28 +08:00
|
|
|
|
|
|
|
it "should list attachments that are not mentioned in the body via cid", ->
|
:art:(attachments): DRY and cleanup attachment components code
Summary:
The attachment components were the only React Components which used
inheritance between components, which is an anti-pattern in react. I
deleted these components in favor of new purely functional/dumb
components exposed via the component-kit: Attachment Item and
ImageAttachmentItem. These are defined in the same file to reuse some
smaller components between them, like the progress-bar, etc.
The attachments pacakage still remains, and only registers a single component to
a new are called MessageAttachments. This InjectedComponent role is
shared by the Composer and MessageItem, and is the only reason this
exists as an injected component in a separate package.
MessageAttachments renders all image and non image attachments for a
message or draft, and binds the appropriate actions for removal, downloading, etc.
The composer still used FileUpload and ImageUpload components for rendering
uploads in the Composer (i.e. when you add an attachment (these are
different from files because they aren't saved until the draft is
sent)). These 2 components were pretty much copied and pasted from the
ones in the attachments package, with subtle differences-- I got rid of
these as well in favor of the new AttachmentItem and ImageAttachmentItem
Also convert more coffee to ES6!
Test Plan: Unit tests
Reviewers: bengotow, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D3381
2016-11-01 08:26:07 +08:00
|
|
|
els = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: "MessageAttachments"})
|
|
|
|
attachments = els[0].props.exposedProps.files
|
2015-06-26 00:51:46 +08:00
|
|
|
expect(attachments.length).toEqual(5)
|
:art:(attachments): DRY and cleanup attachment components code
Summary:
The attachment components were the only React Components which used
inheritance between components, which is an anti-pattern in react. I
deleted these components in favor of new purely functional/dumb
components exposed via the component-kit: Attachment Item and
ImageAttachmentItem. These are defined in the same file to reuse some
smaller components between them, like the progress-bar, etc.
The attachments pacakage still remains, and only registers a single component to
a new are called MessageAttachments. This InjectedComponent role is
shared by the Composer and MessageItem, and is the only reason this
exists as an injected component in a separate package.
MessageAttachments renders all image and non image attachments for a
message or draft, and binds the appropriate actions for removal, downloading, etc.
The composer still used FileUpload and ImageUpload components for rendering
uploads in the Composer (i.e. when you add an attachment (these are
different from files because they aren't saved until the draft is
sent)). These 2 components were pretty much copied and pasted from the
ones in the attachments package, with subtle differences-- I got rid of
these as well in favor of the new AttachmentItem and ImageAttachmentItem
Also convert more coffee to ES6!
Test Plan: Unit tests
Reviewers: bengotow, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D3381
2016-11-01 08:26:07 +08:00
|
|
|
expect(attachments[0]).toBe(file)
|
|
|
|
expect(attachments[1]).toBe(file_not_downloaded)
|
|
|
|
expect(attachments[2]).toBe(file_cid_but_not_referenced)
|
|
|
|
expect(attachments[3]).toBe(file_cid_but_not_referenced_or_image)
|
2015-05-29 09:15:47 +08:00
|
|
|
|
:art:(attachments): DRY and cleanup attachment components code
Summary:
The attachment components were the only React Components which used
inheritance between components, which is an anti-pattern in react. I
deleted these components in favor of new purely functional/dumb
components exposed via the component-kit: Attachment Item and
ImageAttachmentItem. These are defined in the same file to reuse some
smaller components between them, like the progress-bar, etc.
The attachments pacakage still remains, and only registers a single component to
a new are called MessageAttachments. This InjectedComponent role is
shared by the Composer and MessageItem, and is the only reason this
exists as an injected component in a separate package.
MessageAttachments renders all image and non image attachments for a
message or draft, and binds the appropriate actions for removal, downloading, etc.
The composer still used FileUpload and ImageUpload components for rendering
uploads in the Composer (i.e. when you add an attachment (these are
different from files because they aren't saved until the draft is
sent)). These 2 components were pretty much copied and pasted from the
ones in the attachments package, with subtle differences-- I got rid of
these as well in favor of the new AttachmentItem and ImageAttachmentItem
Also convert more coffee to ES6!
Test Plan: Unit tests
Reviewers: bengotow, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D3381
2016-11-01 08:26:07 +08:00
|
|
|
it "should provide the correct file download state for each attachment", ->
|
|
|
|
els = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: "MessageAttachments"})
|
2016-11-03 08:20:33 +08:00
|
|
|
{downloads} = els[0].props.exposedProps
|
|
|
|
expect(downloads['file_1_id']).toBe(download)
|
|
|
|
expect(downloads['file_not_downloaded']).toBe(undefined)
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-05-29 09:15:47 +08:00
|
|
|
it "should still list attachments when the message has no body", ->
|
|
|
|
@message.body = ""
|
|
|
|
@createComponent()
|
:art:(attachments): DRY and cleanup attachment components code
Summary:
The attachment components were the only React Components which used
inheritance between components, which is an anti-pattern in react. I
deleted these components in favor of new purely functional/dumb
components exposed via the component-kit: Attachment Item and
ImageAttachmentItem. These are defined in the same file to reuse some
smaller components between them, like the progress-bar, etc.
The attachments pacakage still remains, and only registers a single component to
a new are called MessageAttachments. This InjectedComponent role is
shared by the Composer and MessageItem, and is the only reason this
exists as an injected component in a separate package.
MessageAttachments renders all image and non image attachments for a
message or draft, and binds the appropriate actions for removal, downloading, etc.
The composer still used FileUpload and ImageUpload components for rendering
uploads in the Composer (i.e. when you add an attachment (these are
different from files because they aren't saved until the draft is
sent)). These 2 components were pretty much copied and pasted from the
ones in the attachments package, with subtle differences-- I got rid of
these as well in favor of the new AttachmentItem and ImageAttachmentItem
Also convert more coffee to ES6!
Test Plan: Unit tests
Reviewers: bengotow, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D3381
2016-11-01 08:26:07 +08:00
|
|
|
els = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: "MessageAttachments"})
|
|
|
|
attachments = els[0].props.exposedProps.files
|
2015-06-26 00:51:46 +08:00
|
|
|
expect(attachments.length).toEqual(8)
|