feat: report Gitea event stream freshness
All checks were successful
CI / lint (pull_request) Successful in 9s
CI / build-frontend (pull_request) Successful in 6s

This commit is contained in:
timmy 2026-08-05 09:03:20 +00:00
parent 1e17771840
commit 5a3f0128c4
2 changed files with 15 additions and 0 deletions

View File

@ -102,6 +102,7 @@ textarea { resize: vertical; min-height: 120px; }
<details class="panel" data-panel-key="gitea-events" open>
<summary><h2>Gitea event stream</h2></summary>
<div id="gitea-events" class="muted" aria-live="polite">Loading…</div>
<div id="gitea-events-status" class="small" aria-live="polite">Waiting for activity…</div>
</details>
<details class="panel" data-panel-key="widgets" open>
<summary><h2>Live Widgets</h2></summary>
@ -245,11 +246,17 @@ textarea { resize: vertical; min-height: 120px; }
).join('') : '<div class="muted">No recent Gitea activity.</div>';
}
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 = '<div class="muted">Event stream unavailable.</div>';
}

View File

@ -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"}}]