Fase 1a: fix jobId (BullMQ rechaza ':' en custom job id)

El dry-run contra prod destapo 'Error: Custom Id cannot contain :': el jobId era
canal:notificationId. Cambiado a canal_notificationId. Test que lo fija.
This commit is contained in:
vjrj 2026-07-13 08:40:38 +02:00
parent 6163deecf3
commit 4f8d866226
2 changed files with 24 additions and 2 deletions

21
test/queue.test.ts Normal file
View file

@ -0,0 +1,21 @@
import { describe, expect, it } from 'vitest';
import { jobId, QUEUE_NAMES } from '../src/queue.js';
describe('jobId', () => {
it('is deterministic per (channel, notificationId) for dedupe', () => {
const a = jobId({ channel: 'fcm', notificationId: 'abc' });
const b = jobId({ channel: 'fcm', notificationId: 'abc' });
expect(a).toBe(b);
});
it('never contains ":" (BullMQ rejects custom ids with a colon)', () => {
expect(jobId({ channel: 'fcm', notificationId: '6a540e689f1e1fd0f9a98788' })).not.toContain(':');
expect(jobId({ channel: 'email', notificationId: 'x' })).not.toContain(':');
});
it('distinguishes channels for the same notification', () => {
expect(jobId({ channel: 'fcm', notificationId: 'x' })).not.toBe(jobId({ channel: 'email', notificationId: 'x' }));
});
it('queue names are colon-free too', () => {
expect(QUEUE_NAMES.fcm).not.toContain(':');
expect(QUEUE_NAMES.email).not.toContain(':');
});
});