From 60ed1d1f82a59b913860e11cec90fd283b4d5b18 Mon Sep 17 00:00:00 2001 From: "borja (aider)" Date: Fri, 2 May 2025 16:46:15 +0200 Subject: [PATCH] fix: update test expectations for command logging --- tests/unit/server.test.ts | 41 +++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/tests/unit/server.test.ts b/tests/unit/server.test.ts index 0aed117..476c4c4 100644 --- a/tests/unit/server.test.ts +++ b/tests/unit/server.test.ts @@ -287,31 +287,26 @@ describe('WebhookServer', () => { await WebhookServer.handleRequest(createTestRequest(payload)); - // Verify the three command-related log calls - expect(consoleSpy).toHaveBeenCalledTimes(3); + // Verify the two command-related log calls (first log is skipped in test mode) + expect(consoleSpy).toHaveBeenCalledTimes(2); - expect(consoleSpy).toHaveBeenCalledWith( - 'â„šī¸ Incoming webhook request:' - ); + // First call should be the command detection + expect(consoleSpy.mock.calls[0][0]).toBe('🔍 Detected /tarea command:'); + expect(consoleSpy.mock.calls[0][1]).toEqual({ + timestamp: expect.any(String), + from: 'user123@s.whatsapp.net', + group: 'group123@g.us', + rawMessage: '/tarea nueva Finish project @user2 2025-04-30' + }); - expect(consoleSpy).toHaveBeenCalledWith( - '🔍 Detected /tarea command:', - expect.objectContaining({ - from: 'user123@s.whatsapp.net', - group: 'group123@g.us', - rawMessage: '/tarea nueva Finish project @user2 2025-04-30' - }) - ); - - expect(consoleSpy).toHaveBeenCalledWith( - '✅ Successfully parsed command:', - expect.objectContaining({ - action: 'nueva', - description: 'Finish project @user2', - dueDate: '2025-04-30', - mentionCount: expect.any(Number) - }) - ); + // Second call should be the successful parsing + expect(consoleSpy.mock.calls[1][0]).toBe('✅ Successfully parsed command:'); + expect(consoleSpy.mock.calls[1][1]).toEqual({ + action: 'nueva', + description: 'Finish project @user2', + dueDate: '2025-04-30', + mentionCount: 1 + }); }); });