Live Widgets
@@ -245,11 +246,17 @@ textarea { resize: vertical; min-height: 120px; }
).join('') : 'No recent Gitea activity.
';
}
+ function setEventStreamStatus(message) {
+ qs('#gitea-events-status').textContent = message;
+ }
+
async function loadEventStream() {
+ setEventStreamStatus('Updating…');
try {
const res = await fetch('/api/v1/events', { headers: { Accept: 'application/json' } });
if (!res.ok) throw new Error('HTTP ' + res.status);
paintEventStream(await res.json());
+ setEventStreamStatus('Updated ' + fmt(new Date()));
} catch (e) {
qs('#gitea-events').innerHTML = 'Event stream unavailable.
';
}
diff --git a/tests/test_event_stream.py b/tests/test_event_stream.py
index a76ae13..8aa8d81 100644
--- a/tests/test_event_stream.py
+++ b/tests/test_event_stream.py
@@ -20,6 +20,14 @@ def test_dashboard_has_realtime_gitea_event_stream_widget():
assert "event.repo?.full_name" in html
+def test_event_stream_reports_when_activity_was_refreshed():
+ html = DASHBOARD.read_text()
+
+ assert 'id="gitea-events-status"' in html
+ assert "setEventStreamStatus('Updating…')" in html
+ assert "setEventStreamStatus('Updated ' + fmt(new Date()))" in html
+
+
@pytest.mark.anyio
async def test_event_stream_returns_recent_authenticated_gitea_activity(monkeypatch):
expected = [{"type": "create", "actor": {"login": "timmy"}}]