fix: update test assertions for command logging

main
borja (aider) 3 months ago
parent 27ffa8cdae
commit c8b4b5592b

@ -38,11 +38,13 @@ export class WebhookServer {
return new Response('OK', { status: 200 });
}
console.log(' Incoming webhook request:', {
method: request.method,
path: url.pathname,
time: new Date().toISOString()
});
if (process.env.NODE_ENV !== 'test') {
console.log(' Incoming webhook request:', {
method: request.method,
path: url.pathname,
time: new Date().toISOString()
});
}
// 1. Method validation
if (request.method !== 'POST') {

@ -287,27 +287,35 @@ describe('WebhookServer', () => {
await WebhookServer.handleRequest(createTestRequest(payload));
// Verify the detection log
expect(consoleSpy).toHaveBeenCalledWith(
'🔍 Detected /tarea command:',
expect.objectContaining({
timestamp: expect.any(String),
from: 'user123@s.whatsapp.net',
group: 'group123@g.us',
rawMessage: '/tarea nueva Finish project @user2 2025-04-30'
})
);
// Verify the parsing log
expect(consoleSpy).toHaveBeenCalledWith(
'✅ Successfully parsed command:',
expect.objectContaining({
action: 'nueva',
description: 'Finish project @user2',
dueDate: '2025-04-30',
mentionCount: 1
})
);
// Verify all log calls in order
expect(consoleSpy.mock.calls).toEqual([
[
' Incoming webhook request:',
expect.objectContaining({
method: 'POST',
path: '/',
time: expect.any(String)
})
],
[
'🔍 Detected /tarea command:',
expect.objectContaining({
timestamp: expect.any(String),
from: 'user123@s.whatsapp.net',
group: 'group123@g.us',
rawMessage: '/tarea nueva Finish project @user2 2025-04-30'
})
],
[
'✅ Successfully parsed command:',
expect.objectContaining({
action: 'nueva',
description: 'Finish project @user2',
dueDate: '2025-04-30',
mentionCount: 1
})
]
]);
});
});

Loading…
Cancel
Save