# FILE: _St/WS8771/test_ws8771_edit_folder_open_prompt_v319.py | ROLE: 수동 편집복사 완료 후 폴더 열기 확인창 회귀
from pathlib import Path

SOURCE = (Path(__file__).resolve().parent / "ws8771_main.py").read_text(encoding="utf-8")


def test_edit_copy_open_prompt_is_main_thread_and_optional() -> None:
    assert 'messagebox.askyesno("편집폴더", "폴더를 열까요?", parent=self.root)' in SOURCE
    assert 'result["open_prompt_shown"] = False' in SOURCE
    assert 'result["opened_folder"] = False' in SOURCE
    assert 'if open_now:' in SOURCE
    assert 'self.handle_open_local_path(' in SOURCE
    assert '"ig_open_folder"' in SOURCE
    assert 'if act == "ig_copy_to_edit_folder":\n                timeout_sec = 660.0' in SOURCE


def test_cancel_keeps_target_folder_for_side_button() -> None:
    block = SOURCE[SOURCE.index('def handle_ig_copy_to_edit_folder'):SOURCE.index('def handle_ig_report_rebuild_all')]
    assert 'return result' in block
    assert 'result.get("target_folder")' in block
    assert 'result["opened_folder"] = bool(open_result and open_result.get("ok"))' in block
