Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

style: fix prettier and eslint failures on click-button checks

Gabriel Moraesa5bc4706128c
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index e2299e7da..ce0b357a3 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -1253,7 +1253,10 @@
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
- transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
+ transition:
+ background 0.15s ease,
+ border-color 0.15s ease,
+ opacity 0.15s ease;
}
.chats-page .message-prompt-button:hover:not(:disabled) {
diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.ts
index dfb10cf57..7e32b0368 100644
--- a/src/engine/adapters/whatsapp-web-js.adapter.ts
+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts
@@ -730,12 +730,9 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEngin
return this.messaging.votePoll(chatId, pollMessageId, options);
}
- clickButton(
- _chatId: string,
- _messageId: string,
- _buttonId: string,
- _text?: string,
- ): Promise<MessageResult> {
+ // whatsapp-web.js has no interactive button-reply send path (see docs/29 clickButton).
+ // eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
+ async clickButton(_chatId: string, _messageId: string, _buttonId: string, _text?: string): Promise<MessageResult> {
throw new EngineNotSupportedError('clickButton');
}
diff --git a/src/modules/contact/contact.service.spec.ts b/src/modules/contact/contact.service.spec.ts
index 2954c71dc..1f2523391 100644
--- a/src/modules/contact/contact.service.spec.ts
+++ b/src/modules/contact/contact.service.spec.ts
@@ -132,13 +132,13 @@ describe('ContactService', () => {
* rather than be refused. It is neutralized on the way there: whatsapp-web.js knows no `@hosted`
* domain, so forwarding the suffix verbatim would fail inside the page instead of blocking anyone.
*/
- it('accepts a Meta-hosted id and hands the engine the neutral dialect', () => {
- const blockContact = jest.fn();
- const unblockContact = jest.fn();
+ it('accepts a Meta-hosted id and hands the engine the neutral dialect', async () => {
+ const blockContact = jest.fn().mockResolvedValue(undefined);
+ const unblockContact = jest.fn().mockResolvedValue(undefined);
const svc = makeService({ blockContact, unblockContact });
- svc.blockContact('s1', '628123456789@hosted');
- svc.unblockContact('s1', '[email protected]');
+ await svc.blockContact('s1', '628123456789@hosted');
+ await svc.unblockContact('s1', '[email protected]');
expect(blockContact).toHaveBeenCalledWith('[email protected]');
expect(unblockContact).toHaveBeenCalledWith('12345678901234567890@lid');
@@ -150,11 +150,11 @@ describe('ContactService', () => {
* which starts with `jidNormalizedUser` and turns `@c.us` straight back into `@s.whatsapp.net`.
* whatsapp-web.js, which has no such dialect, gets the form it actually understands.
*/
- it('hands the engine the neutral dialect for a raw-protocol id', () => {
- const blockContact = jest.fn();
+ it('hands the engine the neutral dialect for a raw-protocol id', async () => {
+ const blockContact = jest.fn().mockResolvedValue(undefined);
const svc = makeService({ blockContact });
- svc.blockContact('s1', '[email protected]');
+ await svc.blockContact('s1', '[email protected]');
expect(blockContact).toHaveBeenCalledWith('[email protected]');
});
diff --git a/src/modules/message/message-send.service.spec.ts b/src/modules/message/message-send.service.spec.ts
index 0c79fd9cd..fcdc8c3d8 100644
--- a/src/modules/message/message-send.service.spec.ts
+++ b/src/modules/message/message-send.service.spec.ts
@@ -1015,25 +1015,26 @@ describe('MessageSendService', () => {
body: 'yes',
type: 'text',
status: MessageStatus.PENDING,
- metadata: expect.objectContaining({
+ metadata: {
button: { id: 'yes', text: undefined },
quotedMessage: { id: 'PROMPT-1', body: '' },
- }),
+ },
}),
);
expect(repository.save).toHaveBeenLastCalledWith(
expect.objectContaining({
body: 'Sim',
status: MessageStatus.SENT,
- metadata: expect.objectContaining({
+ metadata: {
+ quotedMessage: { id: 'PROMPT-1', body: '' },
button: { id: 'yes', text: 'Sim' },
- }),
+ },
}),
);
});
it('routes an engine refusal through failSend so the pending row is marked failed', async () => {
- (mockEngine.clickButton as jest.Mock).mockRejectedValueOnce(
+ mockEngine.clickButton.mockRejectedValueOnce(
new BadRequestException('message PROMPT-1 is not a WhatsApp Business button/list prompt that can be clicked'),
);