Improve dashboard diagnostics and update UI

This commit is contained in:
Your Name committed 2026-06-28 21:26:48 +08:00
1 parent a870e0cbf9
commit c0cb274728
6 files changed
+332 -24

No files matched your search

+48
View File
@@ -32,6 +32,54 @@ def test_build_diagnostic_log_archive_tails_logs_only(tmp_path, monkeypatch):
assert zf.read("logs/unified.log") == b"a" * 10
def test_build_diagnostic_log_archive_includes_runtime_context_and_recent_images(tmp_path, monkeypatch):
from douyin.core import path_config
from douyin.diagnostics import log_upload
logs_dir = tmp_path / "logs"
logs_dir.mkdir()
pic_dir = tmp_path / "pic"
pic_dir.mkdir()
state_dir = tmp_path / "state"
state_dir.mkdir()
cfg_path = tmp_path / "config.json"
(logs_dir / "screenshot_calls.jsonl").write_text("call\n", encoding="utf-8")
(pic_dir / "screenshot.png").write_bytes(b"\x89PNG\r\n\x1a\n" + b"x" * 2048)
(pic_dir / "screenshot.png.tmp").write_bytes(b"broken screenshot output")
(pic_dir / "latest.png").write_bytes(b"\x89PNG\r\n\x1a\n" + b"y" * 2048)
(state_dir / "room_pos_map.json").write_text('{"1": "room"}', encoding="utf-8")
cfg_path.write_text(
json.dumps(
{
"device_id": "dev-1",
"license": {"card_key": "DG-SHOULD-NOT-LEAK"},
"api_token": "secret",
},
ensure_ascii=False,
),
encoding="utf-8",
)
monkeypatch.setattr(path_config, "get_logs_dir", lambda: str(logs_dir))
monkeypatch.setattr(path_config, "get_pic_dir", lambda: str(pic_dir))
monkeypatch.setattr(path_config, "get_state_dir", lambda: str(state_dir))
monkeypatch.setattr(path_config, "get_config_path", lambda: str(cfg_path))
archive = log_upload.build_diagnostic_log_archive(output_dir=tmp_path, max_archive_bytes=1024 * 1024)
with zipfile.ZipFile(archive) as zf:
names = set(zf.namelist())
assert "logs/screenshot_calls.jsonl" in names
assert "pic/screenshot.png" in names
assert "pic/screenshot.png.tmp" in names
assert "pic/latest.png" in names
assert "state/room_pos_map.json" in names
assert "config/config.redacted.json" in names
assert "diagnostics/environment.json" in names
redacted = json.loads(zf.read("config/config.redacted.json").decode("utf-8"))
assert redacted["license"]["card_key"] == "<redacted>"
assert redacted["api_token"] == "<redacted>"
def test_license_server_log_upload_overwrites_same_card(tmp_path):
from fastapi.testclient import TestClient