"""Revise action keeps the generic user-guided candidate rewrite path.""" from __future__ import annotations from typing import Any from builder_flow_helpers import create_builder_session, event, finish_education, start_education from test_api import active_component def _revise(client: Any, session_id: str, body: dict[str, Any], payload: dict[str, Any]) -> Any: return event(client, session_id, body, "revise", payload) def test_revise_regenerates_proposal_with_user_guidance(client: Any) -> None: session_id, body = create_builder_session(client) card = start_education(client, session_id, body) proposal = finish_education(client, session_id, card, "\u5b8c\u6210\u6570\u636e\u5e93\u8bfe\u7a0b\u9879\u76ee\u3002GPA: 4.3/5.0\u3002") response = _revise(client, session_id, proposal, {"instruction": "\u8bf7\u628a\u7b2c\u4e00\u53e5\u8868\u8fbe\u5f97\u66f4\u7b80\u6d01\u3002"}) assert response.status_code == 200, response.text reply = response.json() assert active_component(reply)["data"]["component"] == "experience_confirm_card" assert "\u91cd\u65b0" in reply["turn"]["content"] assert active_component(reply)["data"]["ai_proposal"]["optimized_description"] def test_revise_without_instruction_rejected(client: Any) -> None: session_id, body = create_builder_session(client) card = start_education(client, session_id, body) proposal = finish_education(client, session_id, card, "\u5b8c\u6210\u6570\u636e\u5e93\u8bfe\u7a0b\u9879\u76ee\u3002GPA: 4.3/5.0\u3002") response = _revise(client, session_id, proposal, {}) assert response.status_code == 422, response.text def test_revise_without_pending_proposal_rejected(client: Any) -> None: session_id, body = create_builder_session(client) response = _revise(client, session_id, body, {"instruction": "\u91cd\u65b0\u4f18\u5316"}) assert response.status_code in (404, 409, 422), response.text