Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(message): validate send DTOs with the production pipe options
Yudhi Armyndharis76c49cd60ef6
diff --git a/src/modules/message/dto/send-message.dto.spec.ts b/src/modules/message/dto/send-message.dto.spec.tsindex 141ade98d..7e78d1c86 100644--- a/src/modules/message/dto/send-message.dto.spec.ts+++ b/src/modules/message/dto/send-message.dto.spec.ts@@ -15,10 +15,13 @@ import {SEND_POLL_BODY_EXAMPLES,} from './send-message.dto';import { SendLocationDto, SendContactDto, SendPollDto } from './message-actions.dto';+import { GLOBAL_VALIDATION_OPTIONS } from '../../../config/app-validation';-// Mirror the global ValidationPipe (main.ts): whitelist + forbidNonWhitelisted strip/reject unknown props.+// Read the production pipe's own options rather than restating them, so these cases cannot assert a+// contract the running app does not apply (a restated copy left out implicit conversion). Validated+// directly instead of through pipe.transform so the cases can name the property that failed.const validateDto = (cls: new () => object, obj: unknown) =>- validate(plainToInstance(cls, obj), { whitelist: true, forbidNonWhitelisted: true });+ validate(plainToInstance(cls, obj, GLOBAL_VALIDATION_OPTIONS.transformOptions), GLOBAL_VALIDATION_OPTIONS);describe('SendTextMessageDto mentions', () => {it('accepts an optional array of mention WIDs', async () => {