fix: Address second code review findings (test isolation, frontend type safety)
This commit is contained in:
@@ -5,7 +5,9 @@ from ea_chatbot.api.main import app
|
||||
from ea_chatbot.history.models import User
|
||||
from ea_chatbot.api.utils import create_access_token
|
||||
|
||||
client = TestClient(app)
|
||||
@pytest.fixture
|
||||
def client():
|
||||
return TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def test_user():
|
||||
@@ -20,7 +22,7 @@ def test_user():
|
||||
def auth_token():
|
||||
return create_access_token(data={"sub": "user-123"})
|
||||
|
||||
def test_get_me_includes_theme(test_user, auth_token):
|
||||
def test_get_me_includes_theme(client, test_user, auth_token):
|
||||
"""Test that /auth/me returns the theme_preference."""
|
||||
with patch("ea_chatbot.api.dependencies.history_manager") as mock_hm:
|
||||
mock_hm.get_user_by_id.return_value = test_user
|
||||
@@ -33,7 +35,7 @@ def test_get_me_includes_theme(test_user, auth_token):
|
||||
assert "theme_preference" in data
|
||||
assert data["theme_preference"] == "light"
|
||||
|
||||
def test_update_theme_success(test_user, auth_token):
|
||||
def test_update_theme_success(client, test_user, auth_token):
|
||||
"""Test successful theme update via PATCH /auth/theme."""
|
||||
updated_user = User(
|
||||
id="user-123",
|
||||
@@ -62,7 +64,7 @@ def test_update_theme_success(test_user, auth_token):
|
||||
assert data["theme_preference"] == "dark"
|
||||
mock_hm_router.update_user_theme.assert_called_once_with("user-123", "dark")
|
||||
|
||||
def test_update_theme_unauthorized():
|
||||
def test_update_theme_unauthorized(client):
|
||||
"""Test that theme update requires authentication."""
|
||||
response = client.patch(
|
||||
"/api/v1/auth/theme",
|
||||
|
||||
Reference in New Issue
Block a user