Prioritize conversation replies
This commit is contained in:
1 parent
f55ae7ddf8
commit
9b86cee9be
13 files changed
+535
-39
No files matched your search
@@ -105,6 +105,25 @@ describe('RateLimiter', () => {
|
||||
expect(order).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('runs a queued high-priority reply before queued outreach', async () => {
|
||||
const order: string[] = [];
|
||||
let release!: () => void;
|
||||
const blocker = new Promise<void>((resolve) => { release = resolve; });
|
||||
const active = limiter.throttle(async () => {
|
||||
order.push('active');
|
||||
await blocker;
|
||||
return 'active';
|
||||
});
|
||||
await vi.waitFor(() => expect(order).toEqual(['active']));
|
||||
|
||||
const outreach = limiter.throttle(async () => { order.push('outreach'); return 'outreach'; });
|
||||
const reply = limiter.throttle(async () => { order.push('reply'); return 'reply'; }, () => true, undefined, 100);
|
||||
release();
|
||||
await Promise.all([active, outreach, reply]);
|
||||
|
||||
expect(order).toEqual(['active', 'reply', 'outreach']);
|
||||
});
|
||||
|
||||
describe('getStats', () => {
|
||||
it('returns initial stats', () => {
|
||||
const stats = limiter.getStats();
|
||||
|
||||
Reference in new issue
Block a user