From 375315672ae96661cca007dbdc5d015ea9c4b40c Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 6 Mar 2026 20:40:34 +0000 Subject: [PATCH] auto(agent): enhance contacts test coverage with zod validation tests --- backend/src/__tests__/contacts.test.js | 22 ++++++++++++++++++++++ docs/runtime/pick_next_task_state.env | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/backend/src/__tests__/contacts.test.js b/backend/src/__tests__/contacts.test.js index e8a39fb..cd9e126 100644 --- a/backend/src/__tests__/contacts.test.js +++ b/backend/src/__tests__/contacts.test.js @@ -106,4 +106,26 @@ test('POST /contacts/respond should handle valid response data', async () => { // This test will fail if the route is not properly implemented or if there's no valid request in test context assert.strictEqual(response.statusCode, 404); // Expected since we don't have a real request in test context +}); + +// Test for contacts request endpoint with proper validation +test('POST /contacts/request should validate dealId and targetUserId (zod)', async () => { + const response = await app.inject({ + method: 'POST', + url: '/contacts/request', + payload: { dealId: 'not-a-number', targetUserId: 2 } + }); + + assert.strictEqual(response.statusCode, 400); +}); + +// Test for contacts respond endpoint with proper validation +test('POST /contacts/respond should validate requestId and accept (zod)', async () => { + const response = await app.inject({ + method: 'POST', + url: '/contacts/respond', + payload: { requestId: 'not-a-number', accept: true } + }); + + assert.strictEqual(response.statusCode, 400); }); \ No newline at end of file diff --git a/docs/runtime/pick_next_task_state.env b/docs/runtime/pick_next_task_state.env index 5589d83..11fdc12 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=auth.js -UPDATED_AT=2026-03-06T20:39:06Z +LAST_ROUTE=contacts.js +UPDATED_AT=2026-03-06T20:40:06Z