Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(mcp): pin the default rate limit window
Yudhi Armyndharis320436613e38
diff --git a/src/modules/mcp/mcp-rate-limit.spec.ts b/src/modules/mcp/mcp-rate-limit.spec.tsindex e791e0ada..59de00d6d 100644--- a/src/modules/mcp/mcp-rate-limit.spec.ts+++ b/src/modules/mcp/mcp-rate-limit.spec.ts@@ -118,11 +118,20 @@ describe('KeyRateLimiter', () => {expect(() => rl.check('k')).not.toThrow();});- it('defaults to 60 calls per key per minute on the real clock', () => {- const rl = new KeyRateLimiter();- for (let i = 0; i < 60; i++) rl.check('k');- expect(() => rl.check('k')).toThrow(/rate limit/i);- expect(() => rl.check('other')).not.toThrow();+ it('defaults to 60 calls per key per 60 s window on the default clock', () => {+ jest.useFakeTimers();+ try {+ const rl = new KeyRateLimiter();+ for (let i = 0; i < 60; i++) rl.check('k');+ expect(() => rl.check('k')).toThrow(/rate limit/i);+ expect(() => rl.check('other')).not.toThrow();+ jest.advanceTimersByTime(59_999);+ expect(() => rl.check('k')).toThrow(/rate limit/i);+ jest.advanceTimersByTime(1);+ expect(() => rl.check('k')).not.toThrow();+ } finally {+ jest.useRealTimers();+ }});it('buckets per key', () => {