Add conversation threads and prepare 0.6.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-11-17 22:46:11 +02:00
co-authored by Copilot
parent 93ff651e9d
commit bb34eedb44
38 changed files with 532 additions and 23 deletions
+16 -3
View File
@@ -9,7 +9,7 @@ const mailSource = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
const pgpSource = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
const setupSource = mailSource.slice(mailSource.indexOf('function setupDraftComposer()'), mailSource.indexOf('\nasync function syncMailbox('));
function harness(initialDraft = null) {
function harness(initialDraft = null, reply = null, forward = false) {
const saved = [];
const deleted = [];
const toasts = [];
@@ -40,7 +40,7 @@ function harness(initialDraft = null) {
appShell: { wrapShowCompose(fn) { wrapped = fn(() => {}); } },
selectMailUi: selector => selector === '#modal-root' ? modalRoot : elements.get(selector),
document: { createElement: node },
window: { crypto: { randomUUID: () => 'new-id' }, daybreakMail: {
window: { epMailConversationThreads: require('../conversation-threads.js'), crypto: { randomUUID: () => 'new-id' }, daybreakMail: {
saveDraft: values => saveDraft(values),
async deleteDraft(id) { deleted.push(id); }
} },
@@ -52,7 +52,7 @@ function harness(initialDraft = null) {
btoa: value => Buffer.from(value, 'binary').toString('base64')
};
vm.runInNewContext(`${setupSource}\nsetupDraftComposer();`, context);
wrapped(null, false, initialDraft);
wrapped(reply, forward, initialDraft);
return {
modal, modalRoot, elements, saved, deleted, toasts,
setSave(fn) { saveDraft = fn; },
@@ -85,6 +85,19 @@ test('reopening a draft restores fields, attachments, and its identity', () => {
assert.equal(h.elements.get('.modal-head span').textContent, 'Edit draft');
});
test('reply draft preserves thread headers when saved and restored; forwards do not inherit them', async () => {
const h = harness(null, { messageId: '<parent@example.test>', references: '<root@example.test>' });
h.elements.get('#compose-body').value = 'Reply';
h.modal.dispatch('input');
await h.runTimers();
assert.equal(h.saved[0].inReplyTo, '<parent@example.test>');
assert.equal(h.saved[0].references, '<root@example.test> <parent@example.test>');
const restored = harness(h.saved[0]);
assert.equal(restored.modal._replyHeaders.inReplyTo, '<parent@example.test>');
const forward = harness(null, { messageId: '<parent@example.test>' }, true);
assert.equal(forward.modal._replyHeaders.inReplyTo, '');
});
test('blank and whitespace-only new messages are not saved on close or manual save', async () => {
const h = harness();
h.elements.get('#compose-body').value = ' \n ';