feat: 完成T-501c Shopee更新安全开关
新增 shopee_update 配置段,默认关闭真实提交和封面更新,限制测试商品ID、单次最大更新条数,并支持成功后关闭本轮自动新开编辑页。 Tab⑤ 设置页新增 Shopee 更新安全表单;Tab③ 开始更新前先读取安全配置并阻断未授权真实提交、超量、非测试商品和未允许的封面更新。 ApplyWorker 将 close_success_tab 传入 editor.apply_task;editor 仅在提交成功且页面为本轮自动新开时关闭 tab,失败和复用页面保留。 同步架构、API、路由、任务看板、当前状态与 progress 文档;补充 GUI 与 editor 单测覆盖安全设置保存、共享配置读取、安全拦截和 tab 关闭策略。
This commit is contained in:
@@ -244,6 +244,55 @@ class EditorLoginTests(unittest.TestCase):
|
||||
self.assertTrue(cdp.closed)
|
||||
close_tab.assert_not_called()
|
||||
|
||||
def test_apply_task_closes_auto_created_product_tab_after_success_when_enabled(self):
|
||||
cdp = FakeProductCDP("ws-new")
|
||||
cdp.target_id = "target-new"
|
||||
cdp.created_by_app = True
|
||||
cdp.cdp_host = "127.0.0.1:9222"
|
||||
|
||||
with mock.patch("app.editor.open_product", return_value=cdp), mock.patch(
|
||||
"app.editor.change_title",
|
||||
return_value={"ok": True, "reason": None},
|
||||
) as change_title, mock.patch("app.editor.replace_cover") as replace_cover, mock.patch(
|
||||
"app.editor.click_update",
|
||||
return_value={"clicked": True, "reason": None},
|
||||
), mock.patch("app.editor.close_tab", return_value=True) as close_tab:
|
||||
result = editor.apply_task(
|
||||
{"debug_port": 9222},
|
||||
{"item_id": "51100639510", "new_title": "新标题"},
|
||||
close_success_tab=True,
|
||||
)
|
||||
|
||||
self.assertTrue(result["committed"])
|
||||
change_title.assert_called_once_with(cdp, "新标题")
|
||||
replace_cover.assert_not_called()
|
||||
self.assertTrue(cdp.closed)
|
||||
close_tab.assert_called_once_with("target-new", host="127.0.0.1:9222")
|
||||
|
||||
def test_apply_task_keeps_product_tab_after_failed_update(self):
|
||||
cdp = FakeProductCDP("ws-new")
|
||||
cdp.target_id = "target-new"
|
||||
cdp.created_by_app = True
|
||||
cdp.cdp_host = "127.0.0.1:9222"
|
||||
|
||||
with mock.patch("app.editor.open_product", return_value=cdp), mock.patch(
|
||||
"app.editor.change_title",
|
||||
return_value={"ok": True, "reason": None},
|
||||
), mock.patch(
|
||||
"app.editor.click_update",
|
||||
return_value={"clicked": False, "reason": "UPDATE_DISABLED"},
|
||||
), mock.patch("app.editor.close_tab") as close_tab:
|
||||
result = editor.apply_task(
|
||||
{"debug_port": 9222},
|
||||
{"item_id": "51100639510", "new_title": "新标题"},
|
||||
close_success_tab=True,
|
||||
)
|
||||
|
||||
self.assertFalse(result["committed"])
|
||||
self.assertEqual("UPDATE_DISABLED", result["error"])
|
||||
self.assertTrue(cdp.closed)
|
||||
close_tab.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user