from __future__ import annotations from pathlib import Path def test_dashboard_current_screenshot_uses_runtime_screenshot(tmp_path, monkeypatch): from gui.dashboard_app import data as dashboard_data project_root = tmp_path pic_dir = project_root / "pic" logs_dir = project_root / "logs" state_dir = project_root / "douyin" / "core" / "state" config_dir = project_root / "config" for path in (pic_dir, logs_dir, state_dir, config_dir): path.mkdir(parents=True, exist_ok=True) runtime_screenshot = pic_dir / "screenshot.png" runtime_screenshot.write_bytes(b"runtime") (pic_dir / "debug_captures").mkdir() (pic_dir / "debug_captures" / "latest.png").write_bytes(b"debug") (pic_dir / "lottery_prize_captures").mkdir() (pic_dir / "lottery_prize_captures" / "win.png").write_bytes(b"win") monkeypatch.setattr(dashboard_data.path_config, "get_project_root", lambda: str(project_root)) monkeypatch.setattr(dashboard_data.path_config, "get_config_path", lambda: str(config_dir / "config.json")) monkeypatch.setattr(dashboard_data.path_config, "get_reservations_path", lambda: str(state_dir / "reservations.json")) monkeypatch.setattr(dashboard_data.path_config, "get_high_value_rooms_path", lambda: str(project_root / "state" / "high_value_rooms.json")) monkeypatch.setattr(dashboard_data.path_config, "get_pic_dir", lambda: str(pic_dir)) monkeypatch.setattr(dashboard_data.path_config, "get_screenshot_path", lambda: str(runtime_screenshot)) monkeypatch.setattr(dashboard_data.path_config, "get_log_file_path", lambda: str(logs_dir / "unified.log")) monkeypatch.setattr(dashboard_data.path_config, "get_simple_log_path", lambda: str(logs_dir / "simple.log")) monkeypatch.setattr(dashboard_data.path_config, "get_actions_log_path", lambda: str(logs_dir / "actions.log")) loaded = dashboard_data.load_dashboard_data() assert loaded.current_screenshot_path == runtime_screenshot assert loaded.screenshot_path == runtime_screenshot assert all(Path(p).name != "latest.png" for p in loaded.win_images)