Log .ics build failures; add salesforce.client unit tests
Review follow-up: - tickets.confirmation-email.ts: a failed .ics generation was swallowed silently; log a warning (the email still goes out without the attachment) - test/common/salesforce.client.test.ts: direct coverage for the shared client's token cache and retry-once-on-401 (previously exercised only indirectly through the newsletter sync test) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,14 @@ jest.mock('../../src/middleware/logger', () => ({
|
||||
import * as EventsService from '../../src/models/calendar/events/events.service';
|
||||
import * as IcalService from '../../src/models/calendar/events/icalgenerator.service';
|
||||
import {MailService} from '../../src/common/common.mail';
|
||||
import logger from '../../src/middleware/logger';
|
||||
import {NachklangTicketsDB} from '../../src/models/tickets/Tickets.db';
|
||||
import {recordConfirmationEmailResult, sendRedemptionConfirmation} from '../../src/models/tickets/tickets.confirmation-email';
|
||||
|
||||
const mockGetEvent = EventsService.getEventById as jest.Mock;
|
||||
const mockToIcal = IcalService.convertToIcal as jest.Mock;
|
||||
const mockSendMail = MailService.sendMail as jest.Mock;
|
||||
const mockLogger = logger as unknown as {info: jest.Mock; warn: jest.Mock; error: jest.Mock};
|
||||
const mockGetConnection = NachklangTicketsDB.getConnection as jest.Mock;
|
||||
|
||||
const EVENT = {
|
||||
@@ -68,13 +70,14 @@ describe('sendRedemptionConfirmation', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('still sends (without an attachment) when the .ics build fails', async () => {
|
||||
it('still sends (without an attachment) and warns when the .ics build fails', async () => {
|
||||
mockToIcal.mockRejectedValue(new Error('ical boom'));
|
||||
|
||||
await sendRedemptionConfirmation(RECIPIENT);
|
||||
|
||||
const options = mockSendMail.mock.calls[0][3];
|
||||
expect(options.attachments).toBeUndefined();
|
||||
expect(mockLogger.warn).toHaveBeenCalledWith(expect.stringContaining('without .ics attachment'));
|
||||
});
|
||||
|
||||
it('returns false and does not send when the event no longer exists', async () => {
|
||||
|
||||
Reference in New Issue
Block a user