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:
parent
4baed0b10c
commit
ff73d60e07
@ -22,6 +22,13 @@ beforeAll(async () => {
|
|||||||
telemetryEnabled: config.TELEMETRY_ENABLED,
|
telemetryEnabled: config.TELEMETRY_ENABLED,
|
||||||
featureFlagsEnabled: config.FEATURE_FLAGS_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();
|
await app.ready();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -66,4 +73,15 @@ describe('diagnostics routes', () => {
|
|||||||
expect(typeof body.telemetryEnabled).toBe('boolean');
|
expect(typeof body.telemetryEnabled).toBe('boolean');
|
||||||
expect(typeof body.featureFlagsEnabled).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/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user