Merge pull request 'feat: Add realtime Gitea event stream widget' (#33) from timmy/31-add-realtime-gitea-event-stream-widget into main
This commit is contained in:
commit
a87e9d2db4
|
|
@ -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>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"}}]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user