auto(agent): enhance helpRequests tests with PUT and DELETE scenarios
This commit is contained in:
parent
10e3527f67
commit
0788549958
2 changed files with 63 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ test('POST /help-requests should create a new help request', async () => {
|
||||||
const newRequest = {
|
const newRequest = {
|
||||||
title: 'Test Help Request',
|
title: 'Test Help Request',
|
||||||
description: 'This is a test help request',
|
description: 'This is a test help request',
|
||||||
location: 'Test Location'
|
valueChf: 50.0
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await app.inject({
|
const response = await app.inject({
|
||||||
|
|
@ -37,4 +37,64 @@ test('POST /help-requests should validate required fields', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.strictEqual(response.statusCode, 400);
|
assert.strictEqual(response.statusCode, 400);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('PUT /help-requests/:id should update a help request', async () => {
|
||||||
|
const newRequest = {
|
||||||
|
title: 'Test Help Request',
|
||||||
|
description: 'This is a test help request',
|
||||||
|
valueChf: 50.0
|
||||||
|
};
|
||||||
|
|
||||||
|
// First create a request
|
||||||
|
const createResponse = await app.inject({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/help-requests',
|
||||||
|
payload: newRequest
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(createResponse.statusCode, 201);
|
||||||
|
|
||||||
|
const requestId = createResponse.json().id;
|
||||||
|
|
||||||
|
// Then update it
|
||||||
|
const updateResponse = await app.inject({
|
||||||
|
method: 'PUT',
|
||||||
|
url: `/help-requests/${requestId}`,
|
||||||
|
payload: {
|
||||||
|
title: 'Updated Title',
|
||||||
|
description: 'Updated Description',
|
||||||
|
valueChf: 75.0,
|
||||||
|
status: 'in_progress'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(updateResponse.statusCode, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('DELETE /help-requests/:id should delete a help request', async () => {
|
||||||
|
const newRequest = {
|
||||||
|
title: 'Test Help Request',
|
||||||
|
description: 'This is a test help request',
|
||||||
|
valueChf: 50.0
|
||||||
|
};
|
||||||
|
|
||||||
|
// First create a request
|
||||||
|
const createResponse = await app.inject({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/help-requests',
|
||||||
|
payload: newRequest
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(createResponse.statusCode, 201);
|
||||||
|
|
||||||
|
const requestId = createResponse.json().id;
|
||||||
|
|
||||||
|
// Then delete it
|
||||||
|
const deleteResponse = await app.inject({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: `/help-requests/${requestId}`
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(deleteResponse.statusCode, 200);
|
||||||
});
|
});
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
LAST_ROUTE=contacts.js
|
LAST_ROUTE=helpRequests.js
|
||||||
UPDATED_AT=2026-03-06T19:54:59Z
|
UPDATED_AT=2026-03-06T19:55:59Z
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue