feat: Add application-level settings for CSS color management
Some checks failed
Run Tests / test (push) Failing after 1m51s
Some checks failed
Run Tests / test (push) Failing after 1m51s
- Introduced a new table `application_setting` to store configurable application options. - Implemented functions to manage CSS color settings, including loading, updating, and reading environment overrides. - Added a new settings view to render and manage theme colors. - Updated UI to include a settings page with theme color management and environment overrides display. - Enhanced CSS styles for the settings page and sidebar navigation. - Created unit and end-to-end tests for the new settings functionality and CSS management.
This commit is contained in:
@@ -4,6 +4,7 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from models.scenario import Scenario
|
||||
from services import settings as settings_service
|
||||
|
||||
|
||||
def test_dashboard_route_provides_summary(
|
||||
@@ -129,3 +130,36 @@ def test_additional_ui_routes_render_templates(
|
||||
|
||||
context = cast(Dict[str, Any], getattr(response, "context", {}))
|
||||
assert context
|
||||
|
||||
|
||||
def test_settings_route_provides_css_context(
|
||||
api_client: TestClient,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
env_var = settings_service.css_key_to_env_var("--color-accent")
|
||||
monkeypatch.setenv(env_var, "#abcdef")
|
||||
|
||||
response = api_client.get("/ui/settings")
|
||||
assert response.status_code == 200
|
||||
|
||||
template = getattr(response, "template", None)
|
||||
assert template is not None
|
||||
assert template.name == "settings.html"
|
||||
|
||||
context = cast(Dict[str, Any], getattr(response, "context", {}))
|
||||
assert "css_variables" in context
|
||||
assert "css_defaults" in context
|
||||
assert "css_env_overrides" in context
|
||||
assert "css_env_override_rows" in context
|
||||
assert "css_env_override_meta" in context
|
||||
|
||||
assert context["css_variables"]["--color-accent"] == "#abcdef"
|
||||
assert context["css_defaults"]["--color-accent"] == settings_service.CSS_COLOR_DEFAULTS["--color-accent"]
|
||||
assert context["css_env_overrides"]["--color-accent"] == "#abcdef"
|
||||
|
||||
override_rows = context["css_env_override_rows"]
|
||||
assert any(row["env_var"] == env_var for row in override_rows)
|
||||
|
||||
meta = context["css_env_override_meta"]["--color-accent"]
|
||||
assert meta["value"] == "#abcdef"
|
||||
assert meta["env_var"] == env_var
|
||||
|
||||
Reference in New Issue
Block a user