Files
Toju/toju-app/src/app/domains/direct-message/domain/rules/dm-message-send.rules.spec.ts
T
myxeliumandCursor fa45052432 fix: Bug - Sending files and attachment issues
Hydrate playable media after disk receive, relay file-announce to sibling
devices via account_sync, bind DM attachments to pre-allocated message ids,
and improve gallery retry/cancel UX with bounded parallel auto-downloads.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 13:05:23 +02:00

31 lines
900 B
TypeScript

import { planDmMessageSend } from './dm-message-send.rules';
function makeFile(name: string): File {
return new File(['x'], name, { type: 'image/png' });
}
describe('planDmMessageSend', () => {
it('binds attachments to the same pre-allocated message id', () => {
const generateId = () => 'dm-msg-1';
const plan = planDmMessageSend({
generateId,
content: 'hello',
pendingFiles: [makeFile('a.png'), makeFile('b.png')]
});
expect(plan.action.id).toBe('dm-msg-1');
expect(plan.attachmentBinding?.messageId).toBe('dm-msg-1');
expect(plan.attachmentBinding?.files).toHaveLength(2);
});
it('returns no attachment binding when there are no pending files', () => {
const plan = planDmMessageSend({
generateId: () => 'dm-msg-2',
content: 'text only',
pendingFiles: []
});
expect(plan.attachmentBinding).toBeNull();
});
});