tcef-notifications/test/queue.test.ts
vjrj 4f8d866226 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.
2026-07-13 08:40:38 +02:00

21 lines
969 B
TypeScript

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(':');
});
});