Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): hold a bulk text send over 4096 characters
Yudhi Armyndharise2d7f90610e2
diff --git a/dashboard/src/pages/MessageTester.test.ts b/dashboard/src/pages/MessageTester.test.tsindex 37113fbdc..eaccb2cd4 100644--- a/dashboard/src/pages/MessageTester.test.ts+++ b/dashboard/src/pages/MessageTester.test.ts@@ -480,6 +480,17 @@ test('a bulk send with a picked image carries it in every item', async () => {}});+test('a bulk text over 4096 characters with no attachment keeps Send disabled and says why', async () => {+ stubGateway();+ const container = await renderBulkAsWriter();+ type(container, '#mt-11', '15550000001');+ type(container, '#mt-12', 'x'.repeat(4096));+ await rtl.waitFor(() => assert.equal(sendButton().disabled, false));+ type(container, '#mt-12', 'x'.repeat(4097));+ assert.equal(sendButton().disabled, true);+ rtl.screen.getByText('Limited to 4096 characters (4097 now).');+});+test('a bulk send that resolves after the page is left starts no progress polling', async () => {let release: (response: Response) => void = () => {};let bulkPosted = false;diff --git a/dashboard/src/pages/MessageTester.tsx b/dashboard/src/pages/MessageTester.tsxindex ac27893fe..3f6278ca0 100644--- a/dashboard/src/pages/MessageTester.tsx+++ b/dashboard/src/pages/MessageTester.tsx@@ -349,6 +349,8 @@ export function MessageTester() {const bulkAudioWithText = bulkAttachment?.kind === 'audio' && content.trim().length > 0;const bulkCaptionTooLong =bulkAttachment !== null && bulkAttachment.kind !== 'audio' && captionLength(content) > BULK_CAPTION_MAX_LENGTH;+ // Without an attachment every item is a text message, under the same bound as a single text send.+ const bulkTextTooLong = bulkAttachment === null && captionLength(content) > MESSAGE_TEXT_MAX_LENGTH;// The text field goes out as the caption on image and video and as the filename on a document.const mediaContentMax =@@ -396,6 +398,7 @@ export function MessageTester() {!mediaUrlInvalid &&!bulkAudioWithText &&!bulkCaptionTooLong &&+ !bulkTextTooLong &&bulkRecipientList.length > 0 &&bulkRecipientList.length <= BULK_MAX_RECIPIENTS &&(delayMs === undefined || (!Number.isNaN(delayMs) && delayMs >= 1000 && delayMs <= 60000));@@ -1108,7 +1111,9 @@ export function MessageTester() {max: BULK_CAPTION_MAX_LENGTH,count: captionLength(content),})- : ''}+ : bulkTextTooLong+ ? t('common.fieldTooLong', { max: MESSAGE_TEXT_MAX_LENGTH, count: captionLength(content) })+ : ''}</span></div>{mediaSourceFields}