feat: add nutrition_history_viz widget and enhance configuration handling
Deploy Development / deploy (push) Successful in 50s
Build Test / pytest-backend (push) Failing after 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 18s

- Introduced the `nutrition_history_viz` widget to the dashboard, allowing users to visualize nutrition history data.
- Updated widget configuration to include `nutrition_history_viz` in the allowed widgets and added validation for its configuration.
- Enhanced the widget catalog with details for the new `nutrition_history_viz` entry.
- Implemented default values and validation logic for the widget's configuration, ensuring proper handling of user inputs.
- Added tests to ensure proper validation of the `nutrition_history_viz` widget configuration.
- Bumped application version to reflect the addition of the new widget.
This commit is contained in:
Lars committed 2026-04-22 10:03:23 +02:00
1 parent 20f195aca1
commit db5557e4aa
12 files changed
+993 -509

No files matched your search

@@ -44,6 +44,37 @@ def test_body_history_viz_unknown_key():
validate_widget_entry_config("body_history_viz", {"evil": True})
def test_nutrition_history_viz_empty_expands_defaults():
d = validate_widget_entry_config("nutrition_history_viz", {})
assert d["chart_days"] == 30
assert d["show_kpis"] is True
assert d["show_kcal_vs_weight"] is True
assert d["kpi_detail"] == "compact"
assert d["show_calorie_balance_chart"] is False
assert d["show_energy_protein_charts"] is False
def test_nutrition_history_viz_chart_days_and_merge():
d = validate_widget_entry_config("nutrition_history_viz", {"chart_days": 45})
assert d["chart_days"] == 45
assert d["show_goals_strip"] is False
with pytest.raises(ValueError):
validate_widget_entry_config("nutrition_history_viz", {"chart_days": 5})
def test_nutrition_history_viz_requires_visible_block():
with pytest.raises(ValueError):
validate_widget_entry_config(
"nutrition_history_viz",
{"show_kpis": False, "show_kcal_vs_weight": False, "show_macro_daily_bars": False, "show_macro_distribution_pair": False},
)
def test_nutrition_history_viz_unknown_key():
with pytest.raises(ValueError):
validate_widget_entry_config("nutrition_history_viz", {"evil": True})
def test_welcome_config_rejected_unknown_key():
with pytest.raises(ValueError):
validate_widget_entry_config("welcome", {"x": 1})