auto(agent): enhance offers route tests with comprehensive test cases

This commit is contained in:
OpenClaw 2026-03-06 19:57:21 +00:00
parent 0788549958
commit e8f533fbe3
2 changed files with 92 additions and 2 deletions

View file

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

View file

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