mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 06:06:35 +08:00
574f171fbd
Summary: We can't try to set or remove the sent label on gmail accounts because the operation will silently fail and cause the threads to later bounce back. This occurred when trying to delete or archive a thread that contained a sent message, and we incorrectly tried to overwrite or remove all of the labels on messages, without regard for sent. This was causing https://github.com/nylas/nylas-mail/issues/2706 and sending and archiving to immediately bounce back. Addresses T7757 Test Plan: unit tests Reviewers: halla, evan, spang Reviewed By: halla, evan, spang Differential Revision: https://phab.nylas.com/D3829
72 lines
2.5 KiB
JavaScript
72 lines
2.5 KiB
JavaScript
/* eslint global-require: 0 */
|
|
/* eslint import/no-dynamic-require: 0 */
|
|
const detectThread = require('../../src/message-processor/detect-thread');
|
|
const {FIXTURES_PATH, ACCOUNT_ID, getTestDatabase} = require('../helpers')
|
|
|
|
function messagesFromFixture({Message}, folder, name) {
|
|
const {A, B} = require(`${FIXTURES_PATH}/Threading/${name}`)
|
|
|
|
const msgA = Message.build(A);
|
|
msgA.folder = folder;
|
|
msgA.labels = [];
|
|
|
|
const msgB = Message.build(B);
|
|
msgB.folder = folder;
|
|
msgB.labels = [];
|
|
|
|
return {msgA, msgB};
|
|
}
|
|
|
|
xdescribe('threading', function threadingSpecs() {
|
|
beforeEach(() => {
|
|
waitsForPromise({timeout: 1000}, async () => {
|
|
this.db = await getTestDatabase()
|
|
this.folder = await this.db.Folder.create({
|
|
id: 'test-folder-id',
|
|
accountId: ACCOUNT_ID,
|
|
version: 1,
|
|
name: 'Test Folder',
|
|
role: null,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("when remote thread ids are present", () => {
|
|
it('threads emails with the same gthreadid', () => {
|
|
waitsForPromise(async () => {
|
|
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'remote-thread-id-yes');
|
|
const threadA = await detectThread({db: this.db, message: msgA});
|
|
const threadB = await detectThread({db: this.db, message: msgB});
|
|
expect(threadB.id).toEqual(threadA.id);
|
|
});
|
|
});
|
|
|
|
it('does not thread other emails', () => {
|
|
waitsForPromise(async () => {
|
|
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'remote-thread-id-no');
|
|
const threadA = await detectThread({db: this.db, message: msgA});
|
|
const threadB = await detectThread({db: this.db, message: msgB});
|
|
expect(threadB.id).not.toEqual(threadA.id);
|
|
});
|
|
});
|
|
});
|
|
describe("when subject matching", () => {
|
|
it('threads emails with the same subject', () => {
|
|
waitsForPromise(async () => {
|
|
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'subject-matching-yes');
|
|
const threadA = await detectThread({db: this.db, message: msgA});
|
|
const threadB = await detectThread({db: this.db, message: msgB});
|
|
expect(threadB.id).toEqual(threadA.id);
|
|
});
|
|
});
|
|
|
|
it('does not thread other emails', () => {
|
|
waitsForPromise(async () => {
|
|
const {msgA, msgB} = messagesFromFixture(this.db, this.folder, 'subject-matching-no');
|
|
const threadA = await detectThread({db: this.db, message: msgA});
|
|
const threadB = await detectThread({db: this.db, message: msgB});
|
|
expect(threadB.id).not.toEqual(threadA.id);
|
|
});
|
|
});
|
|
});
|
|
});
|