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 }); return new Response('OK', { status: 200 });
} }
console.log(' Incoming webhook request:', { if (process.env.NODE_ENV !== 'test') {
method: request.method, console.log(' Incoming webhook request:', {
path: url.pathname, method: request.method,
time: new Date().toISOString() path: url.pathname,
}); time: new Date().toISOString()
});
}
// 1. Method validation // 1. Method validation
if (request.method !== 'POST') { if (request.method !== 'POST') {

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

Loading…
Cancel
Save