from pathlib import Path ROOT=Path(__file__).resolve().parents[1] def test_version(): assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.6.15" def test_frontend_preflight_exists_before_progress(): js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") assert "function frontendMissingDatePreflight" in js assert "function renderFrontendClarification" in js send=js.index("async function send(){") pre=js.index("const localPreflight=frontendMissingDatePreflight(t);",send) busy=js.index("busy=true",send) assert pre < busy def test_named_region_bbox_locked_in_frontend(): js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") assert '{name:"西北太平洋"' in js assert 'bbox:[120,180,0,60]' in js assert "区域和经纬度范围已经确定,不需要再次提供坐标" in js assert "输出格式不是必填项;未指定时默认使用 NetCDF" in js def test_date_only_followup_rebuilds_full_request(): js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") assert "PENDING_OCEAN_CLARIFICATION" in js assert "frontendDateOnly(t)" in js assert 'effectivePrompt=PENDING_OCEAN_CLARIFICATION.original+",日期为"+t' in js def test_backend_receives_effective_prompt(): js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") assert "prompt:promptWithDisplayPreferences(effectivePrompt)" in js