feat: add live replays and PostgreSQL maintenance tools
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
- Stream compact live replay updates across local and clustered dashboards. - Render responsive snake bodies as SVG paths with aligned custom icons. - Add cache-busted assets, replay fallback routes, and live-follow playback. - Support PostgreSQL benchmark sampling and idempotent SQLite migration. - Add dry-run cleanup for old low-quality PostgreSQL replay payloads. - Reward safe perimeter lanes and bump Prism to version 1.5.0. - Add backend, migration, dashboard, and perimeter regression coverage.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from server.Server import Server
|
||||
|
||||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
class TestDashboardStaticAssets(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
self.server = Server(
|
||||
data_path=REPO_ROOT,
|
||||
snake_type='PrismBattleSnake',
|
||||
storage_type='memory',
|
||||
metrics_backend='memory',
|
||||
gameplay_db_enabled=False,
|
||||
)
|
||||
|
||||
def _static_url(self):
|
||||
return self.server.app.jinja_env.globals['static_url']
|
||||
|
||||
async def test_static_url_carries_file_mtime(self):
|
||||
asset = 'js/GameBoard.js'
|
||||
expected_version = int(os.path.getmtime(
|
||||
os.path.join(self.server.app.static_folder, asset)
|
||||
))
|
||||
|
||||
async with self.server.app.test_request_context('/dashboard'):
|
||||
url = self._static_url()(asset)
|
||||
|
||||
self.assertEqual(url, f'/files/{asset}?v={expected_version}')
|
||||
|
||||
async def test_static_url_tolerates_missing_asset(self):
|
||||
async with self.server.app.test_request_context('/dashboard'):
|
||||
url = self._static_url()('js/DoesNotExist.js')
|
||||
|
||||
self.assertEqual(url, '/files/js/DoesNotExist.js?v=0')
|
||||
|
||||
async def test_dashboard_page_versions_every_static_asset(self):
|
||||
client = self.server.app.test_client()
|
||||
response = await client.get('/dashboard')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
body = await response.get_data(as_text=True)
|
||||
|
||||
references = re.findall(r'(?:href|src)="(/files/[^"]+)"', body)
|
||||
self.assertTrue(references, 'dashboard page referenced no static assets')
|
||||
for reference in references:
|
||||
self.assertRegex(reference, r'\?v=\d+$', f'unversioned static asset: {reference}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user