T-578 更新失败关闭新建商品页

This commit is contained in:
chengma
2026-07-09 21:08:42 +08:00
parent 7c606e860e
commit 65a01c35e8
5 changed files with 137 additions and 14 deletions
+19 -2
View File
@@ -3,7 +3,7 @@ id: T-578
title: ③更新失败时关闭本次新开的商品编辑页(app 建的 tab),只保留成功页由⑤开关决定
phase: 7
deps: [T-402, T-404b, T-501c, T-571]
status: TODO
status: DONE
created: 2026-07-09
---
@@ -70,4 +70,21 @@ created: 2026-07-09
## 执行记录
(做完在这里写:改了什么文件、跑了什么验证命令及结果、遇到的阻塞、关键决策。)
- 2026-07-09:已完成。
- 文档预提交:
- 先按评审建议更新任务定义并单独提交 `7c606e8 T-578 更新任务定义`:补依赖、明确只关闭程序自动新建页、实现时传完整 `committed`、同步 `docs/api.md`、细化验收分支。
- 代码:
- `app/editor.py`:`apply_task()` finally 改为 `_close_applied_product(cdp, committed=committed, close_success_tab=close_success_tab)`;`_close_applied_product()` 内部统一判断 tab 生命周期。
- 更新失败(`committed=False`,含标题失败、封面失败、更新按钮/确认失败、异常分支)且 `created_by_app=True` 时关闭浏览器 target;复用用户已有 tab 时只断开 CDP。
- 成功路径保持原语义:`close_success_tab=False` 时保留;`close_success_tab=True` 且 app 新建页时先等 2 秒再关闭。失败关闭不等待 2 秒。
- `tests/test_editor_login.py`:补/改成功默认保留、失败关闭、复用失败不关、封面失败关闭、异常关闭等单测。
- 文档:
- `docs/04-architecture.md`:更新 `close_success_tab`、③真实更新、CDP tab 生命周期表述。
- `docs/api.md`:同步 `apply_task()` 和 ③更新流程接口说明,移除“失败保留现场”的旧口径。
- 验证:
- `py -3.10 -m unittest tests.test_editor_login`:通过,45 tests。
- `py -3.10 -m unittest tests.test_editor_login tests.test_gui`:通过,184 tests。
- `python -m ruff check app tests main.py`:通过。
- `py -3.10 -m compileall app main.py`:通过。
- `py -3.10 -m unittest discover -s tests`:通过,316 tests。
- `git diff --check`:通过,无输出。