auto(agent): enhance reviews route tests with comprehensive edge cases
This commit is contained in:
parent
fb436cb3d6
commit
d895375e82
2 changed files with 70 additions and 2 deletions
|
|
@ -87,4 +87,72 @@ test('POST /reviews should return 409 for already reviewed deal', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.strictEqual(response.statusCode, 409);
|
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);
|
||||||
});
|
});
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
LAST_ROUTE=profile.js
|
LAST_ROUTE=reviews.js
|
||||||
UPDATED_AT=2026-03-06T20:36:17Z
|
UPDATED_AT=2026-03-06T20:37:06Z
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue