auto(agent): enhance reviews route tests with comprehensive edge cases

This commit is contained in:
OpenClaw 2026-03-06 20:37:32 +00:00
parent fb436cb3d6
commit d895375e82
2 changed files with 70 additions and 2 deletions

View file

@ -87,4 +87,72 @@ test('POST /reviews should return 409 for already reviewed deal', async () => {
});
assert.strictEqual(response.statusCode, 409);
});
test('POST /reviews should return 400 for invalid dealId', async () => {
const newReview = {
dealId: 'invalid',
revieweeId: 2,
rating: 5,
comment: 'Great product'
};
const response = await app.inject({
method: 'POST',
url: '/reviews/invalid',
payload: newReview
});
assert.strictEqual(response.statusCode, 400);
});
test('POST /reviews should return 400 for invalid revieweeId', async () => {
const newReview = {
dealId: 1,
revieweeId: -1,
rating: 5,
comment: 'Great product'
};
const response = await app.inject({
method: 'POST',
url: '/reviews/1',
payload: newReview
});
assert.strictEqual(response.statusCode, 400);
});
test('POST /reviews should return 400 for invalid rating', async () => {
const newReview = {
dealId: 1,
revieweeId: 2,
rating: 0,
comment: 'Great product'
};
const response = await app.inject({
method: 'POST',
url: '/reviews/1',
payload: newReview
});
assert.strictEqual(response.statusCode, 400);
});
test('POST /reviews should return 400 for invalid comment length', async () => {
const newReview = {
dealId: 1,
revieweeId: 2,
rating: 5,
comment: 'a'.repeat(2001)
};
const response = await app.inject({
method: 'POST',
url: '/reviews/1',
payload: newReview
});
assert.strictEqual(response.statusCode, 400);
});

View file

@ -1,2 +1,2 @@
LAST_ROUTE=profile.js
UPDATED_AT=2026-03-06T20:36:17Z
LAST_ROUTE=reviews.js
UPDATED_AT=2026-03-06T20:37:06Z