mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 10:12:00 +08:00
0ec108c906
Summary: This diff introduces several updates to mail merge to improve the procedure for sending a list of drafts. Specifically, sending mass email will now: - Clear mail merge metadata on the drafts that will actually be sent - Upload attached files only /once/, and reuse those files on the drafts that will actually be sent - Minimize database writes for new drafts being created - Will queue a SendManyDraftsTask that will subsequently queue the necessary SendDraftTasks and keep track of them, and notify of any failed tasks TODO: - Add state to MailMerge plugin for failed sends and ability to attempt to re send them Test Plan: - TODO Reviewers: evan, bengotow, jackie Reviewed By: bengotow, jackie Subscribers: jackie Differential Revision: https://phab.nylas.com/D2973
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import {
|
|
Actions,
|
|
Message,
|
|
DraftHelpers,
|
|
SyncbackDraftFilesTask,
|
|
} from 'nylas-exports';
|
|
|
|
describe('DraftHelpers', function describeBlock() {
|
|
describe('prepareForSyncback', () => {
|
|
beforeEach(() => {
|
|
spyOn(DraftHelpers, 'applyExtensionTransformsToDraft').andCallFake((draft) => Promise.resolve(draft))
|
|
spyOn(Actions, 'queueTask')
|
|
});
|
|
|
|
it('queues tasks to upload files and send the draft', () => {
|
|
const draft = new Message({
|
|
clientId: "local-123",
|
|
threadId: "thread-123",
|
|
replyToMessageId: "message-123",
|
|
uploads: ['stub'],
|
|
});
|
|
const session = {
|
|
ensureCorrectAccount() { return Promise.resolve() },
|
|
draft() { return draft },
|
|
}
|
|
runs(() => {
|
|
DraftHelpers.prepareDraftForSyncback(session);
|
|
});
|
|
waitsFor(() => Actions.queueTask.calls.length > 0);
|
|
runs(() => {
|
|
const saveAttachments = Actions.queueTask.calls[0].args[0];
|
|
expect(saveAttachments instanceof SyncbackDraftFilesTask).toBe(true);
|
|
expect(saveAttachments.draftClientId).toBe(draft.clientId);
|
|
});
|
|
});
|
|
});
|
|
});
|