fix(backlog): 修评审 3 HIGH — resume chain_key 真值 / 模板空白校验 / 续写链 resume E2E
1. resume_chain 回报真 chain_key:从 awaiting job.result 读回(run 时 _chain_result 持久化),不再按 job.kind 推断(kind 恒为通用常量 "chain",从不在 SUPPORTED_CHAINS → 总错回退 draft_volume)。continue_volume 的 resume 回执现报真值。 2. 模板 title/body 拒纯空白:StringConstraints(strip_whitespace, min_length=1), " " strip 后为空 → 422。 3. 续写链 resume 路径 E2E:continue_volume 第 1 章冲突 → interrupt → awaiting → resume 带裁决 → done,断言 resume 回执 / job result chain_key="continue_volume" (回归守卫 #1)。 测试:+resume continue_volume 单测(chain_key 真值)+2 模板空白 422 单测 +1 续写链 resume E2E。重生成 TS 客户端(仅 description 文案变化)。
This commit is contained in:
@@ -365,6 +365,31 @@ async def test_resume_chain_awaiting_returns_202(
|
||||
assert len(_noop_run_chain_job) == 1
|
||||
|
||||
|
||||
async def test_resume_continue_volume_reports_true_chain_key(
|
||||
_noop_run_chain_job: list[dict[str, Any]],
|
||||
) -> None:
|
||||
"""回归守卫 #1:resume continue_volume run → 回执 chain_key="continue_volume"(读自
|
||||
job.result,run 时由 _chain_result 持久化),而非旧 bug 按 job.kind 推断的 "draft_volume"。
|
||||
且转发给 run_chain_job 的 chain_key 也是真值(续写模式不被错降为 draft_volume)。"""
|
||||
project_repo = FakeProjectRepo()
|
||||
job_repo = FakeJobRepo()
|
||||
pid = await _seed_project(project_repo)
|
||||
job = await job_repo.create(pid, "chain") # kind 恒为通用常量 "chain"
|
||||
# run 时 interrupt 把真 chain_key 持久进 result(continue_volume)。
|
||||
await job_repo.set_awaiting(job.id, {"awaiting_chapter": 1, "chain_key": "continue_volume"})
|
||||
app = _app(project_repo, job_repo)
|
||||
|
||||
async with _client(app) as client:
|
||||
resp = await client.post(
|
||||
f"/projects/{pid}/chains/runs/{job.id}/resume",
|
||||
json={"decisions": [{"conflict_index": 0, "verdict": "ignore"}]},
|
||||
)
|
||||
|
||||
assert resp.status_code == 202
|
||||
assert resp.json()["chain_key"] == "continue_volume"
|
||||
assert _noop_run_chain_job[0]["kwargs"]["chain_key"] == "continue_volume"
|
||||
|
||||
|
||||
async def test_resume_chain_non_awaiting_returns_409(
|
||||
_noop_run_chain_job: list[dict[str, Any]],
|
||||
) -> None:
|
||||
|
||||
@@ -105,6 +105,23 @@ async def test_create_template_empty_body_returns_422() -> None:
|
||||
assert resp.status_code == 422
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_template_whitespace_only_title_returns_422() -> None:
|
||||
# strip 后为空 → min_length=1 不满足 → 422(防纯空白标题,审评 #2)。
|
||||
client, _repo, _session = _make_client()
|
||||
async with client:
|
||||
resp = await client.post("/templates", json={"title": " ", "body": "b"})
|
||||
assert resp.status_code == 422
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_template_whitespace_only_body_returns_422() -> None:
|
||||
client, _repo, _session = _make_client()
|
||||
async with client:
|
||||
resp = await client.post("/templates", json={"title": "a", "body": " "})
|
||||
assert resp.status_code == 422
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_template_returns_204_and_commits() -> None:
|
||||
client, repo, session = _make_client()
|
||||
|
||||
Reference in New Issue
Block a user