refactor: modularize notification job creation and enforce plan-based channel availability in policy resolver

This commit is contained in:
2026-07-27 22:51:33 -03:00
parent dc020d94d2
commit 68d98e8b40
6 changed files with 333 additions and 58 deletions
@@ -421,6 +421,8 @@ describe("cancellation notification jobs", () => {
};
(AppointmentsList as any).jobService = {
createJob: jest.fn().mockResolvedValue([]),
createMandatoryCreationJob: jest.fn().mockResolvedValue([]),
createReminderJobs: jest.fn().mockResolvedValue([]),
};
(CompaniesManager.companies.findOne as jest.Mock).mockResolvedValue({
@@ -563,6 +565,8 @@ describe("creation notification jobs", () => {
};
(AppointmentsList as any).jobService = {
createJob: jest.fn().mockResolvedValue([]),
createMandatoryCreationJob: jest.fn().mockResolvedValue([]),
createReminderJobs: jest.fn().mockResolvedValue([]),
};
(CompaniesManager.companies.findOne as jest.Mock).mockResolvedValue({
@@ -649,7 +653,7 @@ describe("creation notification jobs", () => {
reminderWapMessage: "WAP REMINDER Ada Lovelace",
});
expect((AppointmentsList as any).jobService.createJob).toHaveBeenCalledWith(
expect((AppointmentsList as any).jobService.createMandatoryCreationJob).toHaveBeenCalledWith(
expect.objectContaining({
type: "creation",
payload: expect.objectContaining({
@@ -659,6 +663,11 @@ describe("creation notification jobs", () => {
systemSubject: "Turno reservado en clases llavallol",
systemMessage: "EMAIL ALTA Ada Lovelace Historia clases llavallol 22/07/2026 08:00hs.",
}),
})
);
expect((AppointmentsList as any).jobService.createReminderJobs).toHaveBeenCalledWith(
expect.objectContaining({
type: "reminder",
reminderPayload: expect.objectContaining({
email: "ada@example.com",
phoneNumber: "5491112345678",