Show blocklist import error badge in navigation
When the most recent scheduled import completed with errors, surface the failure in the persistent app shell: - A warning MessageBar appears at top of main content area - An amber badge is rendered on the Blocklists sidebar nav item Backend: add last_run_errors: bool | None to ScheduleInfo model and populate it in get_schedule_info() from the latest import_log row. Frontend: extend ScheduleInfo type, add useBlocklistStatus polling hook, wire both indicators into MainLayout. Tests: 3 new service tests + 1 new router test (433 total, all pass).
This commit is contained in:
@@ -379,6 +379,31 @@ class TestGetSchedule:
|
||||
assert "next_run_at" in body
|
||||
assert "last_run_at" in body
|
||||
|
||||
async def test_schedule_response_includes_last_run_errors(
|
||||
self, bl_client: AsyncClient
|
||||
) -> None:
|
||||
"""GET /api/blocklists/schedule includes last_run_errors field."""
|
||||
info_with_errors = ScheduleInfo(
|
||||
config=ScheduleConfig(
|
||||
frequency=ScheduleFrequency.daily,
|
||||
interval_hours=24,
|
||||
hour=3,
|
||||
minute=0,
|
||||
day_of_week=0,
|
||||
),
|
||||
next_run_at=None,
|
||||
last_run_at="2026-03-01T03:00:00+00:00",
|
||||
last_run_errors=True,
|
||||
)
|
||||
with patch(
|
||||
"app.routers.blocklist.blocklist_service.get_schedule_info",
|
||||
new=AsyncMock(return_value=info_with_errors),
|
||||
):
|
||||
resp = await bl_client.get("/api/blocklists/schedule")
|
||||
body = resp.json()
|
||||
assert "last_run_errors" in body
|
||||
assert body["last_run_errors"] is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# PUT /api/blocklists/schedule
|
||||
|
||||
Reference in New Issue
Block a user