chore: auto release commit (2026-09-15 01:20:35)
Some checks failed
技能自动化发布 / release (push) Failing after 7s
Some checks failed
技能自动化发布 / release (push) Failing after 7s
This commit is contained in:
@@ -1279,6 +1279,8 @@ class _FakePage:
|
||||
|
||||
- .url: 字符串
|
||||
- 支持外部修改 .url 模拟用户登录跳转
|
||||
- v1.1.24:新增 .locator() 返回 _FakeLocatorNoOp,让
|
||||
_wait_for_login_inputs_filled 的 selector 探测不抛 AttributeError
|
||||
"""
|
||||
|
||||
def __init__(self, initial_url: str = "about:blank") -> None:
|
||||
@@ -1287,6 +1289,10 @@ class _FakePage:
|
||||
self.reload_calls: int = 0
|
||||
self.click_calls: int = 0
|
||||
|
||||
def locator(self, selector: str): # noqa: ARG002
|
||||
"""v1.1.24 扩展:测试 _wait_for_login_inputs_filled 用,返回空 locator。"""
|
||||
return _FakeLocator(count=0)
|
||||
|
||||
|
||||
def test_wait_for_url_stable_immediate_match() -> tuple[bool, str]:
|
||||
"""_wait_for_url_stable: URL 已含目标 + 稳定 → 立即返回 True。"""
|
||||
@@ -1413,6 +1419,12 @@ class _FakeLocatorRouter:
|
||||
self._selectors = selectors
|
||||
self._page = page
|
||||
|
||||
def __call__(self, sel: str):
|
||||
"""page.locator(sel) 形式调用。"""
|
||||
if sel in self._selectors:
|
||||
return self._selectors[sel]
|
||||
return _FakeLocator(count=0)
|
||||
|
||||
def __getattr__(self, sel: str):
|
||||
# loc.page 已存在则按 selector 路由
|
||||
if sel in self._selectors:
|
||||
@@ -1540,6 +1552,51 @@ def test_try_auto_sign_in_selector_timeout_returns_false() -> tuple[bool, str]:
|
||||
return True, "无登录 input 超时返回 False OK"
|
||||
|
||||
|
||||
def test_wait_for_login_inputs_filled_no_auto_click_v1_24() -> tuple[bool, str]:
|
||||
"""v1.1.24:`_wait_for_login_inputs_filled` **不再自动点登录按钮**——
|
||||
用户输入完成(input 有值)后等 URL 跳离登录页,**按钮交给用户自己点**。
|
||||
"""
|
||||
import threading
|
||||
import time as _time
|
||||
|
||||
from service import platform_collector as pc
|
||||
|
||||
# 缩短轮询周期:HUMAN_POLL_INTERVAL 默认 5s,太长测试慢
|
||||
orig_poll = pc.HUMAN_POLL_INTERVAL
|
||||
orig_prompt = pc.HUMAN_PROMPT_INTERVAL
|
||||
pc.HUMAN_POLL_INTERVAL = 0.2
|
||||
pc.HUMAN_PROMPT_INTERVAL = 0.2
|
||||
try:
|
||||
page = _FakePage(
|
||||
"https://sandbox.jc2009.com/industries/campus/smartcampus/login",
|
||||
)
|
||||
|
||||
# 0.6s 后 URL 跳到 /app/(模拟用户点登录按钮后跳转)
|
||||
def fake_user_jump():
|
||||
_time.sleep(0.6)
|
||||
page.url = "https://sandbox.jc2009.com/industries/campus/smartcampus/app/home"
|
||||
|
||||
threading.Thread(target=fake_user_jump, daemon=True).start()
|
||||
|
||||
result = pc._wait_for_login_inputs_filled(page, wait_sec=5)
|
||||
if not result:
|
||||
return False, "URL 已跳到 /app/ 应返回 True"
|
||||
|
||||
if page.goto_calls:
|
||||
return False, f"等待期间不应 goto: {page.goto_calls}"
|
||||
if page.reload_calls:
|
||||
return False, f"等待期间不应 reload: {page.reload_calls}"
|
||||
if page.click_calls:
|
||||
return False, (
|
||||
f"v1.1.24 修复:等用户输入期间**不应自动点登录**按钮,"
|
||||
f"但 click_calls={page.click_calls}"
|
||||
)
|
||||
return True, "v1.1.24 等用户跳离登录页(不抢按钮)OK"
|
||||
finally:
|
||||
pc.HUMAN_POLL_INTERVAL = orig_poll
|
||||
pc.HUMAN_PROMPT_INTERVAL = orig_prompt
|
||||
|
||||
|
||||
# ---------- v1.1.18: show-config / logs-list ----------
|
||||
|
||||
|
||||
@@ -1813,6 +1870,11 @@ def main() -> int:
|
||||
_run("login_flow/wait_url_stable_transition", test_wait_for_url_stable_transition)
|
||||
_run("login_flow/wait_url_stable_timeout", test_wait_for_url_stable_timeout)
|
||||
_run("login_flow/wait_manual_login_no_goto", test_wait_for_manual_login_no_goto)
|
||||
_run("login_flow/auto_sign_in_spa_chinese_button", test_try_auto_sign_in_spa_login_chinese_button)
|
||||
_run("login_flow/auto_sign_in_root_english_button", test_try_auto_sign_in_root_sign_in_english_button)
|
||||
_run("login_flow/auto_sign_in_no_input_returns_false", test_try_auto_sign_in_no_input_returns_false)
|
||||
_run("login_flow/auto_sign_in_selector_timeout_returns_false", test_try_auto_sign_in_selector_timeout_returns_false)
|
||||
_run("login_flow/wait_login_inputs_filled_no_auto_click_v1_24", test_wait_for_login_inputs_filled_no_auto_click_v1_24)
|
||||
_run("show_config/masks_tokens", test_show_config_masks_tokens)
|
||||
_run("show_config/skips_empty", test_show_config_skips_empty)
|
||||
_run("show_config/skips_comments", test_show_config_skips_comments)
|
||||
|
||||
Reference in New Issue
Block a user