From 078854995805245fa80de39280d5676c4b78d26f Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 6 Mar 2026 19:56:20 +0000 Subject: [PATCH] auto(agent): enhance helpRequests tests with PUT and DELETE scenarios --- backend/src/__tests__/helpRequests.test.js | 62 +++++++++++++++++++++- docs/runtime/pick_next_task_state.env | 4 +- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/backend/src/__tests__/helpRequests.test.js b/backend/src/__tests__/helpRequests.test.js index 783962d..599071c 100644 --- a/backend/src/__tests__/helpRequests.test.js +++ b/backend/src/__tests__/helpRequests.test.js @@ -16,7 +16,7 @@ test('POST /help-requests should create a new help request', async () => { const newRequest = { title: 'Test Help Request', description: 'This is a test help request', - location: 'Test Location' + valueChf: 50.0 }; const response = await app.inject({ @@ -37,4 +37,64 @@ test('POST /help-requests should validate required fields', async () => { }); assert.strictEqual(response.statusCode, 400); +}); + +test('PUT /help-requests/:id should update a help request', async () => { + const newRequest = { + title: 'Test Help Request', + description: 'This is a test help request', + valueChf: 50.0 + }; + + // First create a request + const createResponse = await app.inject({ + method: 'POST', + url: '/help-requests', + payload: newRequest + }); + + assert.strictEqual(createResponse.statusCode, 201); + + const requestId = createResponse.json().id; + + // Then update it + const updateResponse = await app.inject({ + method: 'PUT', + url: `/help-requests/${requestId}`, + payload: { + title: 'Updated Title', + description: 'Updated Description', + valueChf: 75.0, + status: 'in_progress' + } + }); + + assert.strictEqual(updateResponse.statusCode, 200); +}); + +test('DELETE /help-requests/:id should delete a help request', async () => { + const newRequest = { + title: 'Test Help Request', + description: 'This is a test help request', + valueChf: 50.0 + }; + + // First create a request + const createResponse = await app.inject({ + method: 'POST', + url: '/help-requests', + payload: newRequest + }); + + assert.strictEqual(createResponse.statusCode, 201); + + const requestId = createResponse.json().id; + + // Then delete it + const deleteResponse = await app.inject({ + method: 'DELETE', + url: `/help-requests/${requestId}` + }); + + assert.strictEqual(deleteResponse.statusCode, 200); }); \ 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 9424a92..00172e5 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=contacts.js -UPDATED_AT=2026-03-06T19:54:59Z +LAST_ROUTE=helpRequests.js +UPDATED_AT=2026-03-06T19:55:59Z