improve email error handling
This commit is contained in:
1 parent
41c7cfbdaa
commit
4a66cf6e11
9 files changed
+183
-33
No files matched your search
@@ -311,6 +311,23 @@ describe("NotificationsService", () => {
|
||||
const result = await service.testAllNotifications(["notif-1"]);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("counts a provider that throws as a failed test and still tests the others", async () => {
|
||||
const { service, notificationsRepository, emailProvider, slackProvider, logger } = createService();
|
||||
emailProvider.sendTestAlert.mockRejectedValue(new Error("Email is not configured. Set the system email host in settings."));
|
||||
(notificationsRepository.findNotificationsByIds as jest.Mock).mockResolvedValue([
|
||||
makeNotification({ type: "email" }),
|
||||
makeNotification({ type: "slack" }),
|
||||
]);
|
||||
|
||||
const result = await service.testAllNotifications(["notif-1", "notif-2"]);
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(slackProvider.sendTestAlert).toHaveBeenCalled();
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ message: "Test notification failed: Email is not configured. Set the system email host in settings." })
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// ── CRUD operations ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user