fix(qa): 实施 4 组设计型 QA 项——规则删除/codex 角色/大纲卷过滤/文风回炉锚点
#5 规则 DELETE + id:暴露 RuleView.id(PK);新增 DELETE /projects/{id}/rules/{rule_id} (项目/规则不存在→404,成功→204,按 (id,project_id) 限定);rule_repo 加 list_for_project/delete;RulesPage 每条加删除(乐观删+回滚+toast)。assemble 侧 RuleView(缓存前缀)不动,列表另立 RuleListItemView。 #7 codex 角色 relations:写侧本已持久化、读端点 _existing_characters 硬编码 []。 加 _relations_from_jsonb 解析 {name,kind,note},CodexPage 渲染关系 chip。 #8 角色入库幂等:SqlCharacterWriteRepo.create 改 (project_id,name) app 层 upsert—— 重复入库改更新而非插入;不加 UNIQUE/迁移(线上已有重复行会让约束迁移失败)。 #1 大纲卷过滤:GET /outline 支持可选 ?volume(无参=全部,向后兼容);OutlineEditor 加「查看:全部/卷N」筛选,与生成目标卷解耦。 H3/#9 文风回炉锚点:StyleDriftSegment 加 text(逐字命中段),style.md 指示审稿输出; 前端按内容锚点定位回炉目标(idx 仅排序),命中失败 → 提示「无法定位该段」而非 静默 no-op。style golden fixture 已重生成。 契约变更已 pnpm gen:api(RuleView.id / DELETE rules / outline ?volume)。无迁移 (alembic 无漂移)。门禁绿:ruff/mypy(210)/alembic/pytest 760 · 前端 tsc/lint/vitest 329。
This commit is contained in:
@@ -239,6 +239,31 @@ async def test_get_outline_returns_persisted_chapters_in_order_with_unpacked_bea
|
||||
assert body["chapters"][1]["beats"] == ["冲突升级"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_outline_with_volume_filters_to_that_volume() -> None:
|
||||
# ?volume=N 只返回该卷章节;无该参数返回全部(向后兼容)。
|
||||
project_repo = FakeProjectRepo()
|
||||
pid = await _seed_project(project_repo)
|
||||
read_repo = FakeOutlineReadRepo()
|
||||
read_repo.add_chapter(pid, volume=1, chapter_no=1, beats=["卷一·开篇"])
|
||||
read_repo.add_chapter(pid, volume=1, chapter_no=2, beats=["卷一·冲突"])
|
||||
read_repo.add_chapter(pid, volume=2, chapter_no=3, beats=["卷二·新篇"])
|
||||
client = _make_read_client(project_repo=project_repo, outline_read_repo=read_repo)
|
||||
|
||||
async with client:
|
||||
all_resp = await client.get(f"/projects/{pid}/outline")
|
||||
vol2_resp = await client.get(f"/projects/{pid}/outline?volume=2")
|
||||
|
||||
# 不带 volume → 全部三章。
|
||||
assert all_resp.status_code == 200
|
||||
assert [c["no"] for c in all_resp.json()["chapters"]] == [1, 2, 3]
|
||||
# ?volume=2 → 仅卷二的第 3 章。
|
||||
assert vol2_resp.status_code == 200
|
||||
vol2_chapters = vol2_resp.json()["chapters"]
|
||||
assert [c["no"] for c in vol2_chapters] == [3]
|
||||
assert all(c["volume"] == 2 for c in vol2_chapters)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_outline_returns_empty_list_when_no_outline() -> None:
|
||||
project_repo = FakeProjectRepo()
|
||||
|
||||
Reference in New Issue
Block a user