revert: restore the original pre-redesign web console

Revert 688aad3, 39ac03a, c84dc36, and ff6a828 in reverse chronological order. Restore the exact tracked tree from 99aff42 while preserving history.

Validation: 29 authentication and base-path tests passed offline. All 23 prior UI browser tests ran in system Edge: 22 passed initially; the fake-login test passed on an unchanged isolated retry. Live game HTTP was blocked throughout browser validation.
This commit is contained in:
AttilaNet
2026-11-11 10:08:02 +08:00
parent 688aad37c1
commit e26d37e9c5
46 changed files with 748 additions and 4554 deletions
+3 -40
View File
@@ -4,7 +4,6 @@ import asyncio
import base64
from copy import deepcopy
from datetime import datetime, timedelta, timezone
from html.parser import HTMLParser
import json
import os
from pathlib import Path
@@ -23,29 +22,6 @@ from ranch_web.app import create_app
from ranch_web.config import WebConfig
class FrontendAssets(HTMLParser):
"""Read the built entry so tests also exercise hashed asset URLs."""
def __init__(self, content):
super().__init__()
self.scripts, self.stylesheets, self.preloads = [], [], []
self.feed(content)
def handle_starttag(self, tag, attrs):
attrs = dict(attrs)
if tag == "script" and attrs.get("src"):
self.scripts.append((attrs["src"], attrs.get("type")))
if tag == "link" and attrs.get("href"):
if attrs.get("rel") == "stylesheet":
self.stylesheets.append(attrs["href"])
elif attrs.get("rel") == "modulepreload":
self.preloads.append(attrs["href"])
@property
def urls(self):
return [url for url, _ in self.scripts] + self.stylesheets + self.preloads
class FakeUpdates:
def __init__(self):
self.calls = []
@@ -537,28 +513,15 @@ class ApiTests(unittest.TestCase):
for url in ("/static/.env", "/static/config.py", "/static/../app.py", "/static/%2e%2e/requirements.txt"):
with self.subTest(url=url):
self.assertEqual(self.client.get(url).status_code, 404)
entry = self.client.get("/")
assets = FrontendAssets(entry.text)
self.assertTrue(assets.scripts, "The console entry must reference its built JavaScript")
self.assertTrue(assets.stylesheets, "The console must load its stylesheet under CSP")
self.assertTrue(all(kind == "module" for _, kind in assets.scripts))
for url in assets.urls:
self.assertTrue(url.startswith("/static/"), url)
for url in ("/", "/static/index.html", *assets.urls):
for url in ("/", "/static/index.html", "/static/app.js"):
response = self.client.get(url)
self.assertEqual(response.status_code, 200, url)
if url not in assets.stylesheets:
self.assertEqual(response.headers["cache-control"], "no-store")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["cache-control"], "no-store")
self.assertEqual(response.headers["x-content-type-options"], "nosniff")
self.assertIn("frame-ancestors 'none'", response.headers["content-security-policy"])
if url in [script for script, _ in assets.scripts] or url in assets.preloads:
self.assertIn("javascript", response.headers["content-type"], url)
elif url in assets.stylesheets:
self.assertIn("text/css", response.headers["content-type"], url)
for url in ("/", "/static/index.html"):
response = self.client.get(url)
self.assertIn("text/html", response.headers["content-type"])
self.assertEqual(FrontendAssets(response.text).urls, assets.urls)
response = self.client.get("/login", follow_redirects=False)
self.assertEqual(response.status_code, 303)
self.assertEqual(response.headers["location"], "/")