Show next scheduled sync time on every page
Exposes the scheduler's next_tick in the topbar via a safe Jinja helper (falls back to nothing if the scheduler isn't running yet), and converts the server-rendered UTC timestamp to the visitor's local time client-side so it reads correctly regardless of timezone. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
36
tests/web/test_next_sync_display.py
Normal file
36
tests/web/test_next_sync_display.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
class _FakeScheduler:
|
||||
def __init__(self, next_tick=None) -> None:
|
||||
self.last_tick = None
|
||||
self.next_tick = next_tick
|
||||
|
||||
|
||||
def test_login_page_shows_next_sync_time(app, client: TestClient) -> None:
|
||||
next_tick = datetime(2026, 8, 16, 14, 32, tzinfo=timezone.utc)
|
||||
app.state.scheduler = _FakeScheduler(next_tick=next_tick)
|
||||
|
||||
response = client.get("/login")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'data-utc="2026-08-16T14:32:00+00:00"' in response.text
|
||||
|
||||
|
||||
def test_dashboard_shows_next_sync_time(app, authenticated_client) -> None:
|
||||
next_tick = datetime(2026, 8, 16, 15, 0, tzinfo=timezone.utc)
|
||||
app.state.scheduler = _FakeScheduler(next_tick=next_tick)
|
||||
|
||||
response = authenticated_client.get("/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'data-utc="2026-08-16T15:00:00+00:00"' in response.text
|
||||
|
||||
|
||||
def test_login_page_renders_without_scheduler(client: TestClient) -> None:
|
||||
response = client.get("/login")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "data-utc" not in response.text
|
||||
Reference in New Issue
Block a user