From ff73d60e07c4832584dedd935872892ca66d278c Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Fri, 20 Mar 2026 21:06:57 -0700 Subject: [PATCH] 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 --- backend/src/diagnostics.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/src/diagnostics.test.ts b/backend/src/diagnostics.test.ts index ffc0a7c..5429813 100644 --- a/backend/src/diagnostics.test.ts +++ b/backend/src/diagnostics.test.ts @@ -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/); + }); });