From cc8230061a1d1564c3f8206f34cd1504d08e319f Mon Sep 17 00:00:00 2001 From: Oleksii Kurinnyi Date: Mon, 25 May 2026 12:33:28 +0000 Subject: [PATCH 1/2] test: add /healthz endpoint test coverage Added comprehensive test coverage for the /healthz health check endpoint: - Content-Type header verification (text/plain) - HTTP method validation (POST and PUT return 404) - Response body structure already covered by existing test All existing tests continue to pass (112 total tests). Co-Authored-By: Claude Sonnet 4.5 Signed-off-by: Oleksii Kurinnyi --- tests/server.test.ts | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/server.test.ts b/tests/server.test.ts index 9670c8c..109e6e2 100644 --- a/tests/server.test.ts +++ b/tests/server.test.ts @@ -25,6 +25,61 @@ describe('startHttpServer', () => { } }); + it('returns Content-Type text/plain on GET /healthz', async () => { + vi.doMock('../src/tools.js', () => ({ + createMcpServer: () => ({ connect: vi.fn() }), + })); + + const { startHttpServer } = await import('../src/server.js'); + const httpServer = await startHttpServer(0); + const port = (httpServer.address() as any).port; + + try { + const res = await fetch(`http://localhost:${port}/healthz`); + expect(res.headers.get('content-type')).toBe('text/plain'); + } finally { + httpServer.close(); + } + }); + + it('returns 404 for POST /healthz', async () => { + vi.doMock('../src/tools.js', () => ({ + createMcpServer: () => ({ connect: vi.fn() }), + })); + + const { startHttpServer } = await import('../src/server.js'); + const httpServer = await startHttpServer(0); + const port = (httpServer.address() as any).port; + + try { + const res = await fetch(`http://localhost:${port}/healthz`, { + method: 'POST', + }); + expect(res.status).toBe(404); + } finally { + httpServer.close(); + } + }); + + it('returns 404 for PUT /healthz', async () => { + vi.doMock('../src/tools.js', () => ({ + createMcpServer: () => ({ connect: vi.fn() }), + })); + + const { startHttpServer } = await import('../src/server.js'); + const httpServer = await startHttpServer(0); + const port = (httpServer.address() as any).port; + + try { + const res = await fetch(`http://localhost:${port}/healthz`, { + method: 'PUT', + }); + expect(res.status).toBe(404); + } finally { + httpServer.close(); + } + }); + it('returns 404 for unknown paths', async () => { vi.doMock('../src/tools.js', () => ({ createMcpServer: () => ({ connect: vi.fn() }), From c0f903123c998ba1c24d4d3ee64a25f08903b0ab Mon Sep 17 00:00:00 2001 From: Oleksii Kurinnyi Date: Thu, 9 Jul 2026 23:50:24 +0300 Subject: [PATCH 2/2] fix: add status code assertion to healthz content-type test Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Oleksii Kurinnyi --- tests/server.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/server.test.ts b/tests/server.test.ts index 109e6e2..da2be97 100644 --- a/tests/server.test.ts +++ b/tests/server.test.ts @@ -36,6 +36,7 @@ describe('startHttpServer', () => { try { const res = await fetch(`http://localhost:${port}/healthz`); + expect(res.status).toBe(200); expect(res.headers.get('content-type')).toBe('text/plain'); } finally { httpServer.close();