stackchain-dashboard/tests/test_shared_context_snapshot.py
timmy ea7bd15721
All checks were successful
CI / lint (pull_request) Successful in 9s
CI / build-frontend (pull_request) Successful in 5s
feat: retain live snapshots while revalidating (#139)
2026-08-06 21:32:58 +00:00

38 lines
1.2 KiB
Python

import pytest
from src.views import dashboard
@pytest.mark.anyio
async def test_one_context_snapshot_updates_every_context_backed_panel():
html = await dashboard()
assert '<script src="static/context-poller.js"></script>' in html
assert "createContextPoller({" in html
assert "renderContextSnapshot(data)" in html
assert "renderRepoMix(qs('#repo-mix'), data)" in html
assert "setInterval(tickWidgets, 2000)" not in html
assert "updateRepoMix(qs('#repo-mix'), fetch)" not in html
assert "setInterval(load, 8000)" not in html
assert "document.addEventListener('visibilitychange'" in html
@pytest.mark.anyio
async def test_one_live_snapshot_updates_work_and_activity_on_one_timer():
html = await dashboard()
assert "fetch('api/v1/live'" in html
assert "renderLiveSnapshot(snapshot)" in html
assert "renderContextSnapshot(snapshot.context)" in html
assert "paintEventStream(snapshot.events)" in html
assert "loadEventStream" not in html
assert "5000" not in html
@pytest.mark.anyio
async def test_dashboard_announces_when_recent_snapshot_is_revalidating():
html = await dashboard()
assert "snapshot.freshness?.revalidating" in html
assert "Refreshing · showing recent snapshot" in html