Skip to content

test(mailer): add missing coverage — Buffer attachment in Resend provider + empty filename #3396

@PierreBrisorgueil

Description

@PierreBrisorgueil

Missing test cases

1. Resend provider — Buffer content not tested

File: lib/helpers/mailer/provider.resend.unit.tests.js

The existing test covers string content converted to base64. Buffer content is not tested:

test('should encode Buffer attachment to base64', async () => {
  const buffer = Buffer.from('binary data');
  await provider.send({ ..., attachments: [{ filename: 'data.bin', content: buffer }] });
  expect(mockResend.emails.send).toHaveBeenCalledWith(
    expect.objectContaining({
      attachments: [{ filename: 'data.bin', content: Buffer.from(buffer).toString('base64') }],
    })
  );
});

2. Mailer index — empty filename not explicitly tested

File: lib/helpers/mailer/tests/mailer.unit.tests.js

validateAttachments correctly rejects filename: '' (via !att.filename) but this case is not explicitly tested:

test('should throw when attachment filename is empty string', async () => {
  await expect(sendMail({ ..., attachments: [{ filename: '', content: 'data' }] }))
    .rejects.toThrow('Attachment filename must be a non-empty string');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Severity1: confusingBug qualificationTestsAdding missing tests or correcting existing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions