2015-03-26 03:41:48 +08:00
|
|
|
React = require "react/addons"
|
|
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
|
2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
{AccountStore, Thread, Contact, Message} = require 'nylas-exports'
|
2015-03-26 03:41:48 +08:00
|
|
|
ThreadListParticipants = require '../lib/thread-list-participants'
|
|
|
|
|
|
|
|
describe "ThreadListParticipants", ->
|
|
|
|
|
|
|
|
it "renders into the document", ->
|
|
|
|
@participants = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ThreadListParticipants thread={new Thread}/>
|
|
|
|
)
|
|
|
|
expect(ReactTestUtils.isCompositeComponentWithType(@participants, ThreadListParticipants)).toBe true
|
|
|
|
|
|
|
|
it "renders unread contacts with .unread-true", ->
|
2015-05-15 08:08:30 +08:00
|
|
|
ben = new Contact(email: 'ben@nylas.com', name: 'ben')
|
2015-03-26 03:41:48 +08:00
|
|
|
ben.unread = true
|
|
|
|
thread = new Thread()
|
2015-04-07 02:46:20 +08:00
|
|
|
thread.metadata = [new Message(from: [ben], unread:true)]
|
2015-03-26 03:41:48 +08:00
|
|
|
|
|
|
|
@participants = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ThreadListParticipants thread={thread}/>
|
|
|
|
)
|
|
|
|
unread = ReactTestUtils.scryRenderedDOMComponentsWithClass(@participants, 'unread-true')
|
|
|
|
expect(unread.length).toBe(1)
|
|
|
|
|
|
|
|
describe "getParticipants", ->
|
|
|
|
beforeEach ->
|
2015-05-15 08:08:30 +08:00
|
|
|
@ben = new Contact(email: 'ben@nylas.com', name: 'ben')
|
|
|
|
@evan = new Contact(email: 'evan@nylas.com', name: 'evan')
|
|
|
|
@evanAgain = new Contact(email: 'evan@nylas.com', name: 'evan')
|
|
|
|
@michael = new Contact(email: 'michael@nylas.com', name: 'michael')
|
|
|
|
@kavya = new Contact(email: 'kavya@nylas.com', name: 'kavya')
|
2015-08-07 04:12:24 +08:00
|
|
|
@phab1 = new Contact(email: 'no-reply@phab.nylas.com', name: 'Ben')
|
|
|
|
@phab2 = new Contact(email: 'no-reply@phab.nylas.com', name: 'MG')
|
2015-03-26 03:41:48 +08:00
|
|
|
|
2015-03-26 04:01:22 +08:00
|
|
|
describe "when thread.messages is available", ->
|
2015-03-26 03:41:48 +08:00
|
|
|
it "correctly produces items for display in a wide range of scenarios", ->
|
|
|
|
scenarios = [{
|
|
|
|
name: 'single read email'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false}]
|
feat(*): draft icon, misc fixes, and WorkspaceStore / custom toolbar in secondary windows
Summary:
Features:
- ThreadListParticipants ignores drafts when computing participants, renders "Draft" label, pending design
- Put the WorkspaceStore in every window—means they all get toolbars and custom gumdrop icons on Mac OS X
Bug Fixes:
- Never display notifications for email the user just sent
- Fix obscure issue with DatabaseView trying to update metadata on items it froze. This resolves issue with names remaining bold after marking as read, drafts not appearing in message list immediately.
- When you pop out a draft, save it first and *wait* for the commit() promise to succeed.
- If you scroll very fast, you node.contentWindow can be null in eventedIframe
Other:
Make it OK to re-register the same component
Make it possible to unregister a hot window
Break the Sheet Toolbar out into it's own file to make things manageable
Replace `package.windowPropsReceived` with a store-style model where anyone can listen for changes to `windowProps`
When I put the WorkspaceStore in every window, I ran into a problem because the package was no longer rendering an instance of the Composer, it was declaring a root sheet with a composer in it. This meant that it was actually a React component that needed to listen to window props, not the package itself.
`atom` is already an event emitter, so I added a `onWindowPropsReceived` hook so that components can listen to window props as if they were listening to a store. I think this might be more flexible than only broadcasting the props change event to packages.
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1592
2015-06-04 07:02:19 +08:00
|
|
|
},{
|
|
|
|
name: 'single read email and draft'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(from: [@ben], draft: true),
|
|
|
|
]
|
|
|
|
out: [{contact: @ben, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'single unread email'
|
|
|
|
in: [
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @evan, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'single unread response'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false}, {contact: @evan, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'two unread responses'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
new Message(unread: true, from: [@kavya]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{contact: @evan, unread: true},
|
|
|
|
{contact: @kavya, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'two unread responses (repeated participants)'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
new Message(unread: true, from: [@evanAgain]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false}, {contact: @evan, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'three unread responses (repeated participants)'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
new Message(unread: true, from: [@michael]),
|
|
|
|
new Message(unread: true, from: [@evanAgain]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @michael, unread: true},
|
|
|
|
{contact: @evanAgain, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'three unread responses'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evan]),
|
|
|
|
new Message(unread: true, from: [@michael]),
|
|
|
|
new Message(unread: true, from: [@kavya]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @michael, unread: true},
|
|
|
|
{contact: @kavya, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'three unread responses to long thread'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: false, from: [@evan]),
|
|
|
|
new Message(unread: false, from: [@michael]),
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evanAgain]),
|
|
|
|
new Message(unread: true, from: [@michael]),
|
|
|
|
new Message(unread: true, from: [@evanAgain]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @michael, unread: true},
|
|
|
|
{contact: @evanAgain, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'single unread responses to long thread'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: false, from: [@evan]),
|
|
|
|
new Message(unread: false, from: [@michael]),
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: true, from: [@evanAgain]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @ben, unread: false},
|
|
|
|
{contact: @evanAgain, unread: true}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'long read thread'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
new Message(unread: false, from: [@evan]),
|
|
|
|
new Message(unread: false, from: [@michael]),
|
|
|
|
new Message(unread: false, from: [@ben]),
|
|
|
|
]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @michael, unread: false},
|
|
|
|
{contact: @ben, unread: false}]
|
2015-08-07 04:12:24 +08:00
|
|
|
},{
|
|
|
|
name: 'thread with different participants with the same email address'
|
|
|
|
in: [
|
|
|
|
new Message(unread: false, from: [@phab1]),
|
|
|
|
new Message(unread: false, from: [@phab2])
|
|
|
|
]
|
|
|
|
out: [{contact: @phab1, unread: false},
|
|
|
|
{contact: @phab2, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
}]
|
|
|
|
|
|
|
|
for scenario in scenarios
|
|
|
|
thread = new Thread()
|
2015-04-07 02:46:20 +08:00
|
|
|
thread.metadata = scenario.in
|
2015-03-26 03:41:48 +08:00
|
|
|
participants = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ThreadListParticipants thread={thread}/>
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(participants.getParticipants()).toEqual(scenario.out)
|
|
|
|
|
|
|
|
# Slightly misuse jasmine to get the output we want to show
|
|
|
|
if (!_.isEqual(participants.getParticipants(), scenario.out))
|
|
|
|
expect(scenario.name).toBe('correct')
|
|
|
|
|
2015-08-15 05:17:15 +08:00
|
|
|
describe "when getParticipants() called and current user is only sender", ->
|
|
|
|
beforeEach ->
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
@me = AccountStore.current().me()
|
2015-08-15 05:17:15 +08:00
|
|
|
@ben = new Contact(email: 'ben@nylas.com', name: 'ben')
|
|
|
|
@evan = new Contact(email: 'evan@nylas.com', name: 'evan')
|
2015-08-19 01:18:30 +08:00
|
|
|
@evanCapitalized = new Contact(email: 'EVAN@nylas.com', name: 'evan')
|
2015-08-15 05:17:15 +08:00
|
|
|
@michael = new Contact(email: 'michael@nylas.com', name: 'michael')
|
|
|
|
@kavya = new Contact(email: 'kavya@nylas.com', name: 'kavya')
|
|
|
|
|
|
|
|
getParticipants = (threadMetadata) ->
|
|
|
|
thread = new Thread()
|
|
|
|
thread.metadata = threadMetadata
|
|
|
|
participants = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ThreadListParticipants thread={thread}/>
|
|
|
|
)
|
|
|
|
participants.getParticipants()
|
|
|
|
|
|
|
|
it "shows only recipients for emails sent from me to different recipients", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@ben])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@ben])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @ben, unread: false}
|
|
|
|
{contact: @evan, unread: false}
|
|
|
|
{contact: @ben, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
2015-08-19 01:18:30 +08:00
|
|
|
it "is case insensitive", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evanCapitalized])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @evan, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
2015-08-15 05:17:15 +08:00
|
|
|
it "shows only first, spacer, second to last, and last recipients if recipients count > 3", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@ben])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@michael])
|
|
|
|
new Message(unread: false, from: [@me], to: [@kavya])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @ben, unread: false}
|
|
|
|
{spacer: true}
|
|
|
|
{contact: @michael, unread: false}
|
|
|
|
{contact: @kavya, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
|
|
|
it "shows correct recipients even if only one email", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@ben, @evan, @michael, @kavya])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @ben, unread: false}
|
|
|
|
{spacer: true}
|
|
|
|
{contact: @michael, unread: false}
|
|
|
|
{contact: @kavya, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
2015-03-26 03:41:48 +08:00
|
|
|
|
2015-08-19 01:18:30 +08:00
|
|
|
it "shows only one recipient if the sender only sent to one recipient", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@evan])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @evan, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
|
|
|
it "shows only the recipient for one sent email", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@evan])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @evan, unread: false}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
|
|
|
it "shows unread email as well", ->
|
|
|
|
input = [new Message(unread: false, from: [@me], to: [@evan])
|
|
|
|
new Message(unread: false, from: [@me], to: [@ben])
|
|
|
|
new Message(unread: true, from: [@me], to: [@kavya])
|
|
|
|
new Message(unread: true, from: [@me], to: [@michael])]
|
|
|
|
actualOut = getParticipants input
|
|
|
|
expectedOut = [{contact: @evan, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @kavya, unread: true},
|
|
|
|
{contact: @michael, unread: true}]
|
|
|
|
expect(actualOut).toEqual expectedOut
|
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
describe "when thread.messages is not available", ->
|
|
|
|
it "correctly produces items for display in a wide range of scenarios", ->
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
me = AccountStore.current().me()
|
2015-03-26 03:41:48 +08:00
|
|
|
scenarios = [{
|
|
|
|
name: 'one participant'
|
|
|
|
in: [@ben]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'one participant (me)'
|
|
|
|
in: [me]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: me, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'two participants'
|
|
|
|
in: [@evan, @ben]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @evan, unread: false}, {contact: @ben, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'two participants (me)'
|
|
|
|
in: [@ben, me]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
},{
|
|
|
|
name: 'lots of participants'
|
|
|
|
in: [@ben, @evan, @michael, @kavya]
|
2015-03-31 02:21:23 +08:00
|
|
|
out: [{contact: @ben, unread: false},
|
|
|
|
{spacer: true},
|
|
|
|
{contact: @michael, unread: false},
|
|
|
|
{contact: @kavya, unread: false}]
|
2015-03-26 03:41:48 +08:00
|
|
|
}]
|
|
|
|
|
|
|
|
for scenario in scenarios
|
|
|
|
thread = new Thread()
|
|
|
|
thread.participants = scenario.in
|
|
|
|
participants = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ThreadListParticipants thread={thread}/>
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(participants.getParticipants()).toEqual(scenario.out)
|
|
|
|
|
|
|
|
# Slightly misuse jasmine to get the output we want to show
|
|
|
|
if (!_.isEqual(participants.getParticipants(), scenario.out))
|
2015-03-26 04:01:22 +08:00
|
|
|
expect(scenario.name).toBe('correct')
|