feat(apply): open product page on left double click
This commit is contained in:
@@ -24,6 +24,7 @@ from app.gui.workers import (
|
||||
ProductSuiteAiWriteWorker,
|
||||
ProductSuiteGenerateWorker,
|
||||
ProductSuiteHistoryExportWorker,
|
||||
ProductTabOpenWorker,
|
||||
CollectWorker,
|
||||
)
|
||||
|
||||
@@ -120,6 +121,46 @@ class WorkerTests(unittest.TestCase):
|
||||
self.assertEqual([(-1, "模拟失败")], failed)
|
||||
self.assertEqual([{"ok": False, "error": "模拟失败"}], finished)
|
||||
|
||||
def test_product_tab_open_worker_focuses_product_without_task_write(self):
|
||||
account = SimpleNamespace(
|
||||
alias="alias-a", account_name="主店", debug_port=9222
|
||||
)
|
||||
with mock.patch(
|
||||
"app.gui.workers.db.get_account_by_alias", return_value=account
|
||||
) as get_account, mock.patch(
|
||||
"app.gui.workers.chrome.is_running", return_value=True
|
||||
) as is_running, mock.patch(
|
||||
"app.gui.workers.editor.open_or_focus_product_tab",
|
||||
return_value={"created": False, "target_id": "target-existing"},
|
||||
) as open_tab, mock.patch("app.gui.workers.db.set_generated") as set_generated:
|
||||
result = ProductTabOpenWorker(
|
||||
"alias-a", "51100639510", db_path="test.db"
|
||||
).execute()
|
||||
|
||||
self.assertTrue(result["ok"])
|
||||
self.assertFalse(result["created"])
|
||||
self.assertEqual("主店", result["account_name"])
|
||||
get_account.assert_called_once_with("alias-a", path="test.db")
|
||||
is_running.assert_called_once_with(9222)
|
||||
open_tab.assert_called_once_with(account, "51100639510")
|
||||
set_generated.assert_not_called()
|
||||
|
||||
def test_product_tab_open_worker_reports_missing_chrome_without_starting_it(self):
|
||||
account = SimpleNamespace(
|
||||
alias="alias-a", account_name="主店", debug_port=9222
|
||||
)
|
||||
with mock.patch(
|
||||
"app.gui.workers.db.get_account_by_alias", return_value=account
|
||||
), mock.patch(
|
||||
"app.gui.workers.chrome.is_running", return_value=False
|
||||
), mock.patch("app.gui.workers.editor.open_or_focus_product_tab") as open_tab:
|
||||
result = ProductTabOpenWorker("alias-a", "51100639510").execute()
|
||||
|
||||
self.assertFalse(result["ok"])
|
||||
self.assertEqual("CHROME_NOT_RUNNING", result["reason"])
|
||||
self.assertIn("④账号管理", result["message"])
|
||||
open_tab.assert_not_called()
|
||||
|
||||
def test_collect_worker_scope_skips_non_normal_without_overwriting_old_content(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
db_path = os.path.join(temp_dir, "cmshopee.db")
|
||||
|
||||
Reference in New Issue
Block a user