feat: expand module workflows, dynamic config, notifications and console API
This commit is contained in:
@@ -173,8 +173,8 @@ def _forbidden_scrape(*_args, **_kwargs):
|
||||
("module_name", "manager_name", "login_name"),
|
||||
[
|
||||
("ProductReplenishment", "JstManager", "login"),
|
||||
("PurchaseConfirmation", "ERPLoginManager", "login_with_playwright"),
|
||||
("PurchaseOrderUpdate", "ERPLoginManager", "login_with_playwright"),
|
||||
("PurchaseConfirmation", "ERPLoginManager", "login_with_browser"),
|
||||
("PurchaseOrderUpdate", "ERPLoginManager", "login_with_browser"),
|
||||
],
|
||||
)
|
||||
def test_supply_acceptance_without_credentials_never_starts_browser_login(
|
||||
@@ -194,7 +194,7 @@ def test_supply_acceptance_without_credentials_never_starts_browser_login(
|
||||
manager = manager_type(str(_config_file(tmp_path)), cdp_port=None)
|
||||
monkeypatch.setattr(
|
||||
module,
|
||||
"sync_playwright",
|
||||
"ScraplingBrowser",
|
||||
_forbidden("acceptance mode must not start an embedded browser"),
|
||||
)
|
||||
|
||||
@@ -220,15 +220,10 @@ def test_supply_missing_credentials_do_not_navigate_or_fill_login(
|
||||
page = SimpleNamespace(context=SimpleNamespace(cookies=lambda: []))
|
||||
navigation_flags: list[bool] = []
|
||||
|
||||
class PlaywrightStarter:
|
||||
def start(self):
|
||||
return object()
|
||||
|
||||
def prepare(_url, *, navigate=True):
|
||||
navigation_flags.append(navigate)
|
||||
return page
|
||||
|
||||
monkeypatch.setattr(module, "sync_playwright", PlaywrightStarter)
|
||||
monkeypatch.setattr(manager, "_prepare_login_page", prepare)
|
||||
monkeypatch.setattr(
|
||||
manager,
|
||||
@@ -236,7 +231,7 @@ def test_supply_missing_credentials_do_not_navigate_or_fill_login(
|
||||
_forbidden("acceptance mode must not fill login credentials"),
|
||||
)
|
||||
|
||||
assert manager.login_with_playwright() is False
|
||||
assert manager.login_with_browser() is False
|
||||
assert manager._acceptance_cookie_skipped is True
|
||||
assert navigation_flags == [True]
|
||||
|
||||
@@ -276,17 +271,12 @@ def test_purchase_confirmation_uses_credential_fallback_but_skips_captcha(
|
||||
def locator(self, selector):
|
||||
return Locator(selector)
|
||||
|
||||
class PlaywrightStarter:
|
||||
def start(self):
|
||||
return object()
|
||||
|
||||
page = Page()
|
||||
|
||||
def prepare(_url, *, navigate=True):
|
||||
navigation_flags.append(navigate)
|
||||
return page
|
||||
|
||||
monkeypatch.setattr(module, "sync_playwright", PlaywrightStarter)
|
||||
monkeypatch.setattr(manager, "_prepare_login_page", prepare)
|
||||
monkeypatch.setattr(
|
||||
manager,
|
||||
@@ -296,7 +286,7 @@ def test_purchase_confirmation_uses_credential_fallback_but_skips_captcha(
|
||||
monkeypatch.setattr(manager, "_dismiss_post_login_dialogs", lambda *_a, **_k: None)
|
||||
monkeypatch.setattr(module.time, "sleep", lambda _seconds: None)
|
||||
|
||||
assert manager.login_with_playwright() is False
|
||||
assert manager.login_with_browser() is False
|
||||
assert manager._acceptance_cookie_skipped is True
|
||||
assert navigation_flags == [True]
|
||||
assert filled == ["username", "password"]
|
||||
@@ -434,7 +424,7 @@ def test_purchase_confirmation_main_exits_with_cookie_skip_code(
|
||||
def __init__(self, _config_path, cdp_port=None):
|
||||
pass
|
||||
|
||||
def login_with_playwright(self):
|
||||
def login_with_browser(self):
|
||||
return False
|
||||
|
||||
def close_browser(self):
|
||||
@@ -477,7 +467,7 @@ def test_purchase_order_update_main_exits_with_cookie_skip_code(
|
||||
def __init__(self, _config_path, cdp_port=None):
|
||||
pass
|
||||
|
||||
def login_with_playwright(self):
|
||||
def login_with_browser(self):
|
||||
return False
|
||||
|
||||
def close_browser(self):
|
||||
|
||||
Reference in New Issue
Block a user