feat: add MailService.cashboxExport and email template

This commit is contained in:
Bastian Wagner
2026-08-04 07:44:12 +02:00
parent 42e2bbc4ff
commit 196898b993
4 changed files with 65 additions and 0 deletions

View File

@@ -58,4 +58,28 @@ describe('MailService', () => {
const call = sendMail.mock.calls[0][0];
expect(call.context.firstName).toBeUndefined();
});
it('sends the cashbox export mail with the PDF attachment', async () => {
const attachment = Buffer.from('%PDF-1.4 fake');
await service.cashboxExport(
{
to: 'vorstand@example.com, kassier@example.com',
data: { teamName: 'Team A', from: '2026-08-01', to: '2026-08-31' },
},
attachment,
'kassenbuch_team-a_2026-08-01_2026-08-31.pdf',
);
expect(sendMail).toHaveBeenCalledTimes(1);
const call = sendMail.mock.calls[0][0];
expect(call.to).toBe('vorstand@example.com, kassier@example.com');
expect(call.template).toBe('cashbox-export');
expect(call.context.teamName).toBe('Team A');
expect(call.context.from).toBe('2026-08-01');
expect(call.context.to).toBe('2026-08-31');
expect(call.attachments).toEqual([
{ filename: 'kassenbuch_team-a_2026-08-01_2026-08-31.pdf', content: attachment },
]);
});
});