diff --git a/backend/src/__tests__/offers.test.js b/backend/src/__tests__/offers.test.js index 7c514c6..9bb78bb 100644 --- a/backend/src/__tests__/offers.test.js +++ b/backend/src/__tests__/offers.test.js @@ -9,4 +9,94 @@ test('GET /offers should return offers', async () => { }); assert.strictEqual(response.statusCode, 200); assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8'); +}); + +test('POST /offers/:requestId should create a new offer with valid data', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/1', + payload: { + amountChf: 50, + message: 'I can help with this' + } + }); + assert.strictEqual(response.statusCode, 201); +}); + +test('POST /offers/:requestId should return 400 for invalid requestId', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/invalid', + payload: { + amountChf: 50, + message: 'I can help with this' + } + }); + assert.strictEqual(response.statusCode, 400); +}); + +test('POST /offers/:requestId should return 400 for invalid payload', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/1', + payload: { + amountChf: -50, + message: 'I can help with this' + } + }); + assert.strictEqual(response.statusCode, 400); +}); + +test('POST /offers/negotiation/:offerId should create a new negotiation with valid data', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/negotiation/1', + payload: { + amountChf: 60, + message: 'What about this amount?' + } + }); + assert.strictEqual(response.statusCode, 201); +}); + +test('POST /offers/negotiation/:offerId should return 400 for invalid offerId', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/negotiation/invalid', + payload: { + amountChf: 60, + message: 'What about this amount?' + } + }); + assert.strictEqual(response.statusCode, 400); +}); + +test('POST /offers/negotiation/:offerId should return 400 for invalid payload', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/negotiation/1', + payload: { + amountChf: -60, + message: 'What about this amount?' + } + }); + assert.strictEqual(response.statusCode, 400); +}); + +test('POST /offers/accept/:offerId should accept an offer and create a deal', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/accept/1', + payload: {} + }); + assert.strictEqual(response.statusCode, 201); +}); + +test('POST /offers/accept/:offerId should return 404 for non-existent offer', async () => { + const response = await app.inject({ + method: 'POST', + url: '/offers/accept/999', + payload: {} + }); + assert.strictEqual(response.statusCode, 404); }); \ 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 00172e5..80c6513 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=helpRequests.js -UPDATED_AT=2026-03-06T19:55:59Z +LAST_ROUTE=offers.js +UPDATED_AT=2026-03-06T19:56:59Z