Skip to content

Commit c5972ef

Browse files
committed
feat: add health check endpoints with tests
- Backend health endpoint already exists with comprehensive checks - Add test suite validating health endpoint structure - Create frontend health check at /api/health - Returns status, service name, and timestamp - Used by GitHub Actions for deployment validation
1 parent 722a363 commit c5972ef

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

tests/test_health_endpoint.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Tests for health check endpoint."""
2+
import pytest
3+
from fastapi.testclient import TestClient
4+
from codeframe.ui.server import app
5+
6+
7+
@pytest.fixture
8+
def client():
9+
"""Create test client."""
10+
return TestClient(app)
11+
12+
13+
def test_health_endpoint_exists(client):
14+
"""Test that /health endpoint exists."""
15+
response = client.get("/health")
16+
assert response.status_code == 200
17+
18+
19+
def test_health_endpoint_returns_json(client):
20+
"""Test that /health returns JSON."""
21+
response = client.get("/health")
22+
assert response.headers["content-type"] == "application/json"
23+
24+
25+
def test_health_endpoint_structure(client):
26+
"""Test that /health returns expected structure."""
27+
response = client.get("/health")
28+
data = response.json()
29+
30+
# Test required fields
31+
assert "status" in data
32+
assert data["status"] == "healthy"
33+
assert "service" in data
34+
assert data["service"] == "CodeFRAME Status Server"
35+
36+
# Test deployment info fields
37+
assert "version" in data
38+
assert "commit" in data
39+
assert "deployed_at" in data
40+
assert "database" in data

web-ui/src/app/api/health/route.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { NextResponse } from 'next/server'
2+
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: 'healthy',
6+
service: 'codeframe-frontend',
7+
timestamp: new Date().toISOString()
8+
})
9+
}

0 commit comments

Comments
 (0)