Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(config): pin the payload retention and inline media defaults
Yudhi Armyndharis11f99734cf74
diff --git a/src/config/configuration.spec.ts b/src/config/configuration.spec.tsindex 283e70d66..e58b01f4b 100644--- a/src/config/configuration.spec.ts+++ b/src/config/configuration.spec.ts@@ -364,6 +364,50 @@ describe('configuration — webhook shutdown drain is fail-safe', () => {});});+describe('configuration: webhook failure payload retention', () => {+ const orig = process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS;+ afterEach(() => {+ if (orig === undefined) delete process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS;+ else process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS = orig;+ });++ // 0 keeps no message body on a failure row, so a changed default would start persisting every+ // failed delivery's event data on every deployment that never opted in.+ it('keeps no payload by default and honors an hours override', () => {+ delete process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS;+ expect(configuration().webhook.failurePayloadRetentionHours).toBe(0);+ process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS = '24';+ expect(configuration().webhook.failurePayloadRetentionHours).toBe(24);+ });++ it('falls back to keeping nothing on a value it cannot read', () => {+ for (const bad of ['', '24h', '-1', '1.5']) {+ process.env.WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS = bad;+ expect(configuration().webhook.failurePayloadRetentionHours).toBe(0);+ }+ });+});++describe('configuration: chat media inline mode', () => {+ const orig = process.env.MESSAGE_INLINE_MEDIA;+ afterEach(() => {+ if (orig === undefined) delete process.env.MESSAGE_INLINE_MEDIA;+ else process.env.MESSAGE_INLINE_MEDIA = orig;+ });++ // Archive mode replaces the stored inline copy, so only the exact word turns it on.+ it('stays inline unless the value is exactly archive', () => {+ delete process.env.MESSAGE_INLINE_MEDIA;+ expect(configuration().chatMedia.inlineMode).toBe('inline');+ for (const other of ['inline', 'Archive', 'ARCHIVE', ' archive', 'archive ', 'true']) {+ process.env.MESSAGE_INLINE_MEDIA = other;+ expect(configuration().chatMedia.inlineMode).toBe('inline');+ }+ process.env.MESSAGE_INLINE_MEDIA = 'archive';+ expect(configuration().chatMedia.inlineMode).toBe('archive');+ });+});+describe('resolveNonNegativeIntEnv', () => {it('treats blank/whitespace as unset and falls back (never the 0 opt-out sentinel)', () => {// Number('') is 0, which would otherwise pass a finite && >= 0 guard and silently land on