chore(e2e,docs): 新脚本的清理只删自己建的模板行(不碰演示态)+ docs/09 §8 补接线检查

This commit is contained in:
2026-10-08 14:47:11 +08:00
parent 9e78e1d239
commit db8aecc30a
2 changed files with 17 additions and 3 deletions
+8 -2
View File
@@ -33,6 +33,7 @@ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PASSED: list[str] = []
FAILED: list[tuple[str, str]] = []
CREATED_TASK_IDS: list[int] = []
CREATED_TPL_IDS: list[int] = [] # 本脚本自定义过的通知模板行(清理时**只删自己建的**)
TMP_ROSTER = os.path.join(ROOT, "scripts", "_e2e-wiring-roster.xlsx")
T1 = 993801 # 班主任(初审人)
@@ -255,6 +256,8 @@ def main() -> int:
check("「驳回通知」可以自定义(内置 → 库里一行)",
bool(tpl.get("id")) and tpl.get("customized") is True,
json.dumps(tpl, ensure_ascii=False)[:200])
if tpl.get("id"):
CREATED_TPL_IDS.append(tpl["id"])
new_title = f"【E2E改过】材料要重传 {suffix}"
new_content = "【E2E改过】{姓名} 的《{任务名}》被退回:{驳回原因}。涉及:{材料名}"
body_of("PUT", f"/api/v1/notify/templates/{tpl.get('id')}", at,
@@ -502,8 +505,11 @@ def cleanup() -> None:
R.sql(f"delete from collect_material_def where task_id={tid};")
R.sql(f"delete from collect_form_schema where task_id={tid};")
R.sql(f"delete from collect_task where id={tid};")
# 模板的覆盖行:删掉 = 恢复内置(**不能留**,否则后面的脚本会读到改过的文案)
R.sql("delete from collect_notify_template where tenant_id=1;")
# 模板的覆盖行:**只删本脚本建的那几行**(删掉 = 恢复内置)。
# ⚠️ 不能写成 `delete from collect_notify_template where tenant_id=1` ——
# 那会把演示态里别人改过的模板一起删掉(而"演示态不能被脚本弄坏"是这个仓库的硬约束)。
for tid in CREATED_TPL_IDS:
R.sql(f"delete from collect_notify_template where id={tid};")
# 本脚本造的学生/申请人/班主任
R.sql(f"delete from collect_message where user_id in "
f"({S1}, {S2}, {S3}, {JOINER}, 993815, {T1});")