From f32c74b8dfea2913ef5d302619ee3914bc9912cd Mon Sep 17 00:00:00 2001 From: beery Date: Tue, 12 May 2026 09:09:57 +0300 Subject: [PATCH] test: ensure hourly filter respects selected date range bounds --- dashboard.py | 2 +- tests/test_dashboard.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index ebf8d5f..a6621a4 100644 --- a/dashboard.py +++ b/dashboard.py @@ -742,7 +742,7 @@ def get_dashboard_data(db_path=DB_PATH): // Hourly aggregation (filtered by model + range, then bucketed by UTC hour) const hourlySrc = (rawData.hourly_by_model || []).filter(r => - selectedModels.has(r.model) && (!cutoff || r.day >= cutoff) + selectedModels.has(r.model) && (!start || r.day >= start) && (!end || r.day <= end) ); const hourlyAgg = aggregateHourly(hourlySrc, hourlyTZ); diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 76287d1..c937d7d 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -228,6 +228,14 @@ def test_hourly_peak_hour_constants(self): self.assertIn('PEAK_HOURS_UTC', HTML_TEMPLATE) self.assertIn('[12, 13, 14, 15, 16, 17]', HTML_TEMPLATE) + def test_hourly_filter_uses_selected_range_bounds(self): + """Hourly dashboard rows use the same selected date bounds as daily rows.""" + self.assertNotIn("cutoff", HTML_TEMPLATE) + self.assertGreaterEqual( + HTML_TEMPLATE.count("(!start || r.day >= start) && (!end || r.day <= end)"), + 2, + ) + class TestPricingParity(unittest.TestCase): """Verify CLI and dashboard pricing tables stay in sync."""