diff --git a/backend/src/__tests__/reviews.test.js b/backend/src/__tests__/reviews.test.js index 2345c59..7da8747 100644 --- a/backend/src/__tests__/reviews.test.js +++ b/backend/src/__tests__/reviews.test.js @@ -14,14 +14,15 @@ test('GET /reviews should return all reviews', async () => { test('POST /reviews should create a new review', async () => { const newReview = { - title: 'Great product', - content: 'I really enjoyed using this.', - rating: 5 + dealId: 1, + revieweeId: 2, + rating: 5, + comment: 'Great product' }; const response = await app.inject({ method: 'POST', - url: '/reviews', + url: '/reviews/1', payload: newReview }); @@ -31,16 +32,59 @@ test('POST /reviews should create a new review', async () => { test('POST /reviews should return 400 for invalid review data', async () => { const invalidReview = { - title: '', - content: 'Some content', - rating: 6 + dealId: 1, + revieweeId: 2, + rating: 6, + comment: 'Some content' }; const response = await app.inject({ method: 'POST', - url: '/reviews', + url: '/reviews/1', payload: invalidReview }); assert.strictEqual(response.statusCode, 400); +}); + +test('POST /reviews should return 404 for non-existent deal', async () => { + const newReview = { + dealId: 999, + revieweeId: 2, + rating: 5, + comment: 'Great product' + }; + + const response = await app.inject({ + method: 'POST', + url: '/reviews/999', + payload: newReview + }); + + assert.strictEqual(response.statusCode, 404); +}); + +test('POST /reviews should return 409 for already reviewed deal', async () => { + const newReview = { + dealId: 1, + revieweeId: 2, + rating: 5, + comment: 'Great product' + }; + + // First submission + await app.inject({ + method: 'POST', + url: '/reviews/1', + payload: newReview + }); + + // Second submission - should fail + const response = await app.inject({ + method: 'POST', + url: '/reviews/1', + payload: newReview + }); + + assert.strictEqual(response.statusCode, 409); }); \ 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 a59153a..e987593 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=profile.js -UPDATED_AT=2026-03-06T19:50:34Z +LAST_ROUTE=reviews.js +UPDATED_AT=2026-03-06T19:51:18Z