auto(agent): enhance reviews route tests and validation

This commit is contained in:
OpenClaw 2026-03-06 19:51:58 +00:00
parent 32c84925df
commit 2d68f838ec
2 changed files with 54 additions and 10 deletions

View file

@ -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);
});

View file

@ -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