feat(backend): add GET /health test to diagnostics suite

- Validates standard health response shape: status, service, version, timestamp
- Ensures consistent health endpoint contract across ecosystem
This commit is contained in:
saravanakumardb1 2026-03-20 21:06:56 -07:00
parent 62f94be845
commit fd4d35b308

View File

@ -22,6 +22,13 @@ beforeAll(async () => {
telemetryEnabled: config.TELEMETRY_ENABLED,
featureFlagsEnabled: config.FEATURE_FLAGS_ENABLED,
}));
app.get('/health', async (req) => ({
status: 'ok',
service: config.SERVICE_NAME,
version: '0.1.0',
timestamp: new Date().toISOString(),
requestId: req.id,
}));
await app.ready();
});
@ -66,4 +73,15 @@ describe('diagnostics routes', () => {
expect(typeof body.telemetryEnabled).toBe('boolean');
expect(typeof body.featureFlagsEnabled).toBe('boolean');
});
it('GET /health returns standard health response', async () => {
const res = await app.inject({ method: 'GET', url: '/health' });
expect(res.statusCode).toBe(200);
const body = res.json();
expect(body.status).toBe('ok');
expect(body).toHaveProperty('service');
expect(body).toHaveProperty('version');
expect(body).toHaveProperty('timestamp');
expect(body.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T/);
});
});