fix: avoid focusing chrome during collection
This commit is contained in:
@@ -442,6 +442,7 @@ class EditorLoginTests(unittest.TestCase):
|
||||
self.assertEqual("127.0.0.1:9222", cdp.cdp_host)
|
||||
find_product_tab.assert_called_once_with("51100639510", host="127.0.0.1:9222")
|
||||
create_tab_info.assert_not_called()
|
||||
self.assertIn(("Page.bringToFront", {}), fake.sent)
|
||||
self.assertIn(
|
||||
(
|
||||
"Page.navigate",
|
||||
@@ -469,7 +470,52 @@ class EditorLoginTests(unittest.TestCase):
|
||||
self.assertEqual("target-new", cdp.target_id)
|
||||
self.assertTrue(cdp.created_by_app)
|
||||
self.assertEqual("127.0.0.1:9223", cdp.cdp_host)
|
||||
create_tab_info.assert_called_once()
|
||||
create_tab_info.assert_called_once_with(
|
||||
(
|
||||
"https://seller.shopee.tw/portal/product/51100639511"
|
||||
"?pageEntry=product_list&ignore-html-cache=1"
|
||||
),
|
||||
host="127.0.0.1:9223",
|
||||
background=False,
|
||||
)
|
||||
|
||||
def test_open_product_can_skip_bring_to_front_for_collection(self):
|
||||
fake = FakeProductCDP("ws-new")
|
||||
with mock.patch("app.editor.find_product_tab", return_value=None), mock.patch(
|
||||
"app.editor.create_tab_info",
|
||||
return_value={"id": "target-new", "webSocketDebuggerUrl": "ws-new"},
|
||||
) as create_tab_info, mock.patch(
|
||||
"app.editor.CDP",
|
||||
return_value=fake,
|
||||
), mock.patch("app.editor._ensure_page_domains"), mock.patch("app.editor._wait_ready"):
|
||||
cdp = editor.open_product(
|
||||
{"debug_port": 9223},
|
||||
"51100639511",
|
||||
bring_to_front=False,
|
||||
)
|
||||
|
||||
self.assertIs(fake, cdp)
|
||||
self.assertNotIn(("Page.bringToFront", {}), fake.sent)
|
||||
self.assertIn(
|
||||
(
|
||||
"Page.navigate",
|
||||
{
|
||||
"url": (
|
||||
"https://seller.shopee.tw/portal/product/51100639511"
|
||||
"?pageEntry=product_list&ignore-html-cache=1"
|
||||
)
|
||||
},
|
||||
),
|
||||
fake.sent,
|
||||
)
|
||||
create_tab_info.assert_called_once_with(
|
||||
(
|
||||
"https://seller.shopee.tw/portal/product/51100639511"
|
||||
"?pageEntry=product_list&ignore-html-cache=1"
|
||||
),
|
||||
host="127.0.0.1:9223",
|
||||
background=True,
|
||||
)
|
||||
|
||||
def test_open_product_installs_toast_observer(self):
|
||||
fake = FakeProductCDP("ws-new", ready=True)
|
||||
@@ -560,7 +606,7 @@ class EditorLoginTests(unittest.TestCase):
|
||||
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(
|
||||
with mock.patch("app.editor.open_product", return_value=cdp) as open_product, mock.patch(
|
||||
"app.editor.read_title",
|
||||
return_value="旧标题",
|
||||
), mock.patch(
|
||||
@@ -576,6 +622,12 @@ class EditorLoginTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual("旧标题", result["old_title"])
|
||||
open_product.assert_called_once_with(
|
||||
{"debug_port": 9222},
|
||||
"51100639510",
|
||||
on_step=None,
|
||||
bring_to_front=False,
|
||||
)
|
||||
self.assertTrue(cdp.closed)
|
||||
close_tab.assert_called_once_with("target-new", host="127.0.0.1:9222")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user