feat(in-transit-transfer): 落地证据流重解析并纳入货代与排程配套改动
外部单号进入异动档自然键,圈档按 T-2 成熟封顶,当前归档可单独重解析。同批带上 Crane 禁整页刷新、ODM 白名单降级、排程抽屉与执行记录日期窗,以及 YAML 库存源下线。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
911afa0f73
commit
4c2a7e2a23
145 files changed
+11695
-4214
No files matched your search
@@ -217,6 +217,26 @@ def test_resolve_parameter_controls_receipt_detail_awsrtm_warehouse_multi_value(
|
||||
assert module.resolve_parameter_controls("Receipt Detail", "Warehouse")["control"] == "select"
|
||||
|
||||
|
||||
def test_resolve_parameter_controls_shipment_order_detail_owner_and_warehouse():
|
||||
"""出站 Shipment Order Detail 的 Owner/Warehouse 应按实机 DOM 使用 multi_value,而不是库存默认 select。"""
|
||||
module = _load_module()
|
||||
owner = module.resolve_parameter_controls("Shipment Order Detail", "Owner")
|
||||
warehouse = module.resolve_parameter_controls("Shipment Order Detail", "Warehouse")
|
||||
# 关键断言:2026-10-19 AWS/Bison/AWSBI 实机——Owner ctl15、Warehouse ctl31,均为 txtValue 下拉。
|
||||
assert owner == {
|
||||
"control": "multi_value",
|
||||
"text": "#ReportViewerMain_ctl08_ctl15_txtValue",
|
||||
"toggle": "#ReportViewerMain_ctl08_ctl15_ctl01",
|
||||
"dropdown": "#ReportViewerMain_ctl08_ctl15_divDropDown",
|
||||
}
|
||||
assert warehouse == {
|
||||
"control": "multi_value",
|
||||
"text": "#ReportViewerMain_ctl08_ctl31_txtValue",
|
||||
"toggle": "#ReportViewerMain_ctl08_ctl31_ctl01",
|
||||
"dropdown": "#ReportViewerMain_ctl08_ctl31_divDropDown",
|
||||
}
|
||||
|
||||
|
||||
def test_resolve_parameter_controls_unknown_report_empty():
|
||||
"""未登记报表名应返回空配置,由调用方回退参数名默认值(保持旧行为)。"""
|
||||
module = _load_module()
|
||||
@@ -326,10 +346,12 @@ def test_fill_dsv_filter_if_needed_jda_report_uses_template_multi_value():
|
||||
report_name="On Hand Inventory by Location",
|
||||
)
|
||||
|
||||
assert payloads, "应进入多选框下拉填充路径而不是无痕失败"
|
||||
# payloads 会混入结构性解析传入的 label 字符串("Warehouse"),只断言 dict 载荷。
|
||||
dict_payloads = [p for p in payloads if isinstance(p, dict)]
|
||||
assert dict_payloads, "应进入多选框下拉填充路径而不是无痕失败"
|
||||
assert any(
|
||||
payload.get("dropdownSelector") == "#ReportViewerMain_ctl08_ctl17_divDropDown"
|
||||
for payload in payloads
|
||||
for payload in dict_payloads
|
||||
), f"应命中 JDA ctl17 multi_value dropdown,实际 payloads={payloads!r}"
|
||||
|
||||
|
||||
@@ -431,10 +453,12 @@ def test_fill_dsv_filter_if_needed_receipt_awsrtm_uses_ctl29_multi_value():
|
||||
program_label="AWSRTM",
|
||||
)
|
||||
|
||||
assert payloads, "应进入 AWSRTM multi_value 填充路径"
|
||||
# payloads 会混入结构性解析传入的 label 字符串,只断言 dict 载荷。
|
||||
dict_payloads = [p for p in payloads if isinstance(p, dict)]
|
||||
assert dict_payloads, "应进入 AWSRTM multi_value 填充路径"
|
||||
assert any(
|
||||
payload.get("dropdownSelector") == "#ReportViewerMain_ctl08_ctl29_divDropDown"
|
||||
for payload in payloads
|
||||
for payload in dict_payloads
|
||||
), f"应命中 ctl29 multi_value dropdown,实际 payloads={payloads!r}"
|
||||
|
||||
|
||||
@@ -471,14 +495,20 @@ class _RecordingPage:
|
||||
|
||||
|
||||
_STRUCTURAL_CONTROLS = {
|
||||
"control": "multi_value",
|
||||
"text": "#ReportViewerMain_ctl08_ctl15_txtValue",
|
||||
"toggle": "#ReportViewerMain_ctl08_ctl15_ctl01",
|
||||
"dropdown": "#ReportViewerMain_ctl08_ctl15_divDropDown",
|
||||
}
|
||||
|
||||
_STRUCTURAL_SELECT = {
|
||||
"control": "select",
|
||||
"selector": "#ReportViewerMain_ctl08_ctl19_ddValue",
|
||||
}
|
||||
|
||||
|
||||
def test_structural_resolver_hit_returns_controls_and_trims_label():
|
||||
"""命中 frame 返回三件套;label 先 trim 再传入页面脚本。"""
|
||||
"""命中 frame 返回 multi_value 三件套(含 control);label 先 trim 再传入页面脚本。"""
|
||||
module = _load_module()
|
||||
early = _RecordingFrame(result=None)
|
||||
hit = _RecordingFrame(result=dict(_STRUCTURAL_CONTROLS))
|
||||
@@ -490,6 +520,22 @@ def test_structural_resolver_hit_returns_controls_and_trims_label():
|
||||
assert hit.calls == ["Owner"]
|
||||
|
||||
|
||||
def test_structural_resolver_select_via_label_for_returns_ddvalue():
|
||||
"""Cincinnati CVG611 形态:label[for]=ctl19_ddValue 时返回 select,禁止再当 multi_value。
|
||||
|
||||
[断言意图] 2026-10-20 事故回归——Warehouse 是原生 select,不得落到 ctl17_txtValue
|
||||
(已漂移为 Project ID)文本兜底。
|
||||
"""
|
||||
module = _load_module()
|
||||
hit = _RecordingFrame(result=dict(_STRUCTURAL_SELECT))
|
||||
page = _RecordingPage([hit])
|
||||
|
||||
got = module.resolve_parameter_controls_structural(page, "Warehouse")
|
||||
|
||||
assert got == _STRUCTURAL_SELECT
|
||||
assert hit.calls == ["Warehouse"]
|
||||
|
||||
|
||||
def test_structural_resolver_all_frames_miss_or_error_returns_none():
|
||||
"""全部 frame 未命中或探测异常(跨域/销毁帧):返回 None 交调用方回退。"""
|
||||
module = _load_module()
|
||||
@@ -596,6 +642,98 @@ def test_fill_multi_select_structural_preferred_registry_is_fallback(monkeypatch
|
||||
assert probed.calls == ["Warehouse"]
|
||||
|
||||
|
||||
def test_fill_warehouse_uses_structural_select_not_stale_txtvalue(monkeypatch, capsys):
|
||||
"""Warehouse 结构性命中 select 时走 ddValue,禁止 JDA 模板 ctl17_txtValue 文本兜底。
|
||||
|
||||
[断言意图] 复现 2026-10-20 Cincinnati:模板仍写 multi_value@ctl17,但页面 Warehouse
|
||||
是 ctl19_ddValue;不得把 BYAWSCV611 写进漂移后的 Project ID。
|
||||
"""
|
||||
module = _load_module()
|
||||
page = _RecordingPage([_RecordingFrame(result=dict(_STRUCTURAL_SELECT))])
|
||||
selected: dict[str, str] = {}
|
||||
|
||||
class _FakeText:
|
||||
first = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.first = self
|
||||
|
||||
def is_visible(self, timeout: int | None = None) -> bool:
|
||||
return False
|
||||
|
||||
page.get_by_text = lambda text, exact=False: _FakeText() # type: ignore[attr-defined]
|
||||
|
||||
def _fake_select(page_obj, label, value, selector, *, timeout_ms):
|
||||
selected["selector"] = selector
|
||||
selected["value"] = value
|
||||
return True
|
||||
|
||||
def _fake_multi(*_a, **_k):
|
||||
raise AssertionError("select 形态不得走 multi_value")
|
||||
|
||||
monkeypatch.setattr(module, "_fill_select_parameter", _fake_select)
|
||||
monkeypatch.setattr(module, "_fill_multi_value_parameter", _fake_multi)
|
||||
|
||||
ok = module.fill_dsv_filter_if_needed(
|
||||
page,
|
||||
"FREIGHT_RPA_WORKER_DSV_WAREHOUSE_SELECTOR",
|
||||
"Warehouse",
|
||||
"BYAWSCV611",
|
||||
env=lambda name, default="": default,
|
||||
browser_timeout_ms=lambda: 3_000,
|
||||
report_name="On Hand Inventory By Location",
|
||||
program_label="CVG611",
|
||||
)
|
||||
|
||||
assert ok is True
|
||||
assert selected == {
|
||||
"selector": "#ReportViewerMain_ctl08_ctl19_ddValue",
|
||||
"value": "BYAWSCV611",
|
||||
}
|
||||
captured = capsys.readouterr()
|
||||
assert "ctl17_txtValue" not in captured.out + captured.err
|
||||
|
||||
|
||||
def test_fill_warehouse_refuses_stale_txtvalue_when_structural_miss(monkeypatch, capsys):
|
||||
"""结构性未命中且模板 multi_value 失败时:Warehouse 拒绝 txtValue 文本兜底并返回 False。"""
|
||||
module = _load_module()
|
||||
page = _RecordingPage([_RecordingFrame(result=None)])
|
||||
|
||||
class _FakeText:
|
||||
first = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.first = self
|
||||
|
||||
def is_visible(self, timeout: int | None = None) -> bool:
|
||||
return False
|
||||
|
||||
page.get_by_text = lambda text, exact=False: _FakeText() # type: ignore[attr-defined]
|
||||
monkeypatch.setattr(module, "_fill_multi_value_parameter", lambda *_a, **_k: False)
|
||||
monkeypatch.setattr(module, "_probe_report_parameter_controls", lambda *_a, **_k: {"controls": []})
|
||||
filled_via_script: list[str] = []
|
||||
monkeypatch.setattr(
|
||||
module,
|
||||
"_fill_input_via_script",
|
||||
lambda root, selector, text: filled_via_script.append(selector) or True,
|
||||
)
|
||||
|
||||
ok = module.fill_dsv_filter_if_needed(
|
||||
page,
|
||||
"FREIGHT_RPA_WORKER_DSV_WAREHOUSE_SELECTOR",
|
||||
"Warehouse",
|
||||
"BYAWSCV611",
|
||||
env=lambda name, default="": default,
|
||||
browser_timeout_ms=lambda: 3_000,
|
||||
report_name="On Hand Inventory By Location",
|
||||
)
|
||||
|
||||
assert ok is False
|
||||
assert filled_via_script == []
|
||||
captured = capsys.readouterr()
|
||||
assert "refusing stale txtValue fallback" in captured.err
|
||||
|
||||
|
||||
def test_multi_value_already_set_set_equality_not_substring():
|
||||
"""2026-10-08 Owner@AWSRTM 事故根因回归:SSRS 多选框默认全选,txtValue 恒为全量 CSV,
|
||||
目标值必为该 CSV 的子串——必须用集合相等判定,子串包含会恒误判"已设置"并跳过下拉勾选。"""
|
||||
|
||||
Reference in new issue
Block a user