Improve messaging and dashboard reliability
This commit is contained in:
1 parent
345ec99348
commit
5a5a30a1d4
20 files changed
+406
-56
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { RecipientDeduplicator } from '../src/services/recipient-deduplicator.js';
|
||||
|
||||
describe('RecipientDeduplicator', () => {
|
||||
it('reserves a recipient once across username casing variants', () => {
|
||||
const history = { hasSentTo: vi.fn(() => false) };
|
||||
const deduplicator = new RecipientDeduplicator(history);
|
||||
|
||||
expect(deduplicator.tryReserve('Some_User')).toBe(true);
|
||||
expect(deduplicator.hasSentTo('some_user')).toBe(true);
|
||||
expect(deduplicator.tryReserve('SOME_USER')).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects recipients found in persisted cross-account history', () => {
|
||||
const history = { hasSentTo: vi.fn((recipient: string) => recipient === 'contacted') };
|
||||
const deduplicator = new RecipientDeduplicator(history);
|
||||
|
||||
expect(deduplicator.tryReserve('contacted')).toBe(false);
|
||||
expect(deduplicator.tryReserve('new-user')).toBe(true);
|
||||
});
|
||||
|
||||
it('allows another account to retry after a failed send releases its reservation', () => {
|
||||
const deduplicator = new RecipientDeduplicator({ hasSentTo: () => false });
|
||||
|
||||
expect(deduplicator.tryReserve('retry-user')).toBe(true);
|
||||
deduplicator.release('RETRY-USER');
|
||||
expect(deduplicator.tryReserve('retry-user')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user