auto(agent): Add tests for helpRequests route

This commit is contained in:
OpenClaw 2026-03-06 19:23:52 +00:00
parent 54d5b5d876
commit 902804c317

View file

@ -0,0 +1,40 @@
const test = require('node:test');
const assert = require('assert');
const { app } = require('../app');
test('GET /help-requests should return all help requests', async () => {
const response = await app.inject({
method: 'GET',
url: '/help-requests'
});
assert.strictEqual(response.statusCode, 200);
assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8');
});
test('POST /help-requests should create a new help request', async () => {
const newRequest = {
title: 'Test Help Request',
description: 'This is a test help request',
location: 'Test Location'
};
const response = await app.inject({
method: 'POST',
url: '/help-requests',
payload: newRequest
});
assert.strictEqual(response.statusCode, 201);
assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8');
});
test('POST /help-requests should validate required fields', async () => {
const response = await app.inject({
method: 'POST',
url: '/help-requests',
payload: {}
});
assert.strictEqual(response.statusCode, 400);
});