feat(shipping-notice): 库存缺口料号兜底自动放行并新增料号可用量列
- 匹配器按料号二次汇总 part_available_qty 随行级匹配事实持久化(新列,迁移 0a575f3a) - 缺口行料号总库存满足需求时系统自动放行,复用人工放行同一落库/审计/门禁链路,证据按预约优先→料号兜底自动带出 - 前端库存匹配表原「可用数量」列改为「预约数量」,其后新增「可用数量」(料号总库存)列 - DSV 连接器防误点「忘记密码」链接并参数化料号报表取数,库存 worker 按料号查询配套 - 收料就绪与来源状态联动调整;casdoor 未识别认证错误日志保留原始异常堆栈 - 同步门禁/投影/持久化测试、调拨卡片文案四语言与文档
This commit is contained in:
1 parent
4e97553f42
commit
386f93108c
62 files changed
+4000
-219
No files matched your search
@@ -448,3 +448,167 @@ def test_fill_multi_value_js_uses_entry_text_not_bare_text():
|
||||
# 禁止在 checkbox 循环里出现未绑定的 `text`(旧脚本 ReferenceError)。
|
||||
assert "desiredValues.includes(text" not in source
|
||||
assert "normalize(text)" not in source or "entryText" in source
|
||||
|
||||
|
||||
class _RecordingFrame:
|
||||
"""脚本化 frame:evaluate 返回预置结果或抛预置异常,并记录收到的 label。"""
|
||||
|
||||
def __init__(self, result=None, error: Exception | None = None):
|
||||
self._result = result
|
||||
self._error = error
|
||||
self.calls: list[str] = []
|
||||
|
||||
def evaluate(self, script: str, label: str):
|
||||
self.calls.append(label)
|
||||
if self._error is not None:
|
||||
raise self._error
|
||||
return self._result
|
||||
|
||||
|
||||
class _RecordingPage:
|
||||
def __init__(self, frames):
|
||||
self.frames = frames
|
||||
|
||||
|
||||
_STRUCTURAL_CONTROLS = {
|
||||
"text": "#ReportViewerMain_ctl08_ctl15_txtValue",
|
||||
"toggle": "#ReportViewerMain_ctl08_ctl15_ctl01",
|
||||
"dropdown": "#ReportViewerMain_ctl08_ctl15_divDropDown",
|
||||
}
|
||||
|
||||
|
||||
def test_structural_resolver_hit_returns_controls_and_trims_label():
|
||||
"""命中 frame 返回三件套;label 先 trim 再传入页面脚本。"""
|
||||
module = _load_module()
|
||||
early = _RecordingFrame(result=None)
|
||||
hit = _RecordingFrame(result=dict(_STRUCTURAL_CONTROLS))
|
||||
page = _RecordingPage([early, hit])
|
||||
|
||||
got = module.resolve_parameter_controls_structural(page, " Owner ")
|
||||
|
||||
assert got == _STRUCTURAL_CONTROLS
|
||||
assert hit.calls == ["Owner"]
|
||||
|
||||
|
||||
def test_structural_resolver_all_frames_miss_or_error_returns_none():
|
||||
"""全部 frame 未命中或探测异常(跨域/销毁帧):返回 None 交调用方回退。"""
|
||||
module = _load_module()
|
||||
page = _RecordingPage([
|
||||
_RecordingFrame(result=None),
|
||||
_RecordingFrame(error=RuntimeError("execution context destroyed")),
|
||||
_RecordingFrame(result=None),
|
||||
])
|
||||
assert module.resolve_parameter_controls_structural(page, "Owner") is None
|
||||
|
||||
|
||||
def test_structural_resolver_empty_label_short_circuits():
|
||||
"""空标签短路:不打扰任何 frame。"""
|
||||
module = _load_module()
|
||||
frame = _RecordingFrame(result=dict(_STRUCTURAL_CONTROLS))
|
||||
page = _RecordingPage([frame])
|
||||
assert module.resolve_parameter_controls_structural(page, " ") is None
|
||||
assert frame.calls == []
|
||||
|
||||
|
||||
def test_structural_resolver_none_page_returns_none():
|
||||
"""无页面上下文(纯函数调用):直接返回 None。"""
|
||||
module = _load_module()
|
||||
assert module.resolve_parameter_controls_structural(None, "Owner") is None
|
||||
|
||||
|
||||
def test_fill_multi_select_template_miss_falls_back_to_structural(monkeypatch):
|
||||
"""接线:报表模板未命中 Owner 时,落到结构性解析并把三件套传入 multi_value 填充。
|
||||
|
||||
[断言意图] 2026-10-08 事故回归:Owner@Receipt Detail@AWSRTM 未登记 ctl15 模板时,
|
||||
不得静默失败弃填(导致全货主巨报表渲染超时),必须结构性解析后正常填充。
|
||||
"""
|
||||
module = _load_module()
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
def _fake_fill(page, label, values, *, timeout_ms, config_override, select_all):
|
||||
captured.update(config_override)
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(module, "resolve_parameter_controls", lambda *a, **k: {})
|
||||
probe = _RecordingFrame(result=dict(_STRUCTURAL_CONTROLS))
|
||||
page = _RecordingPage([probe])
|
||||
monkeypatch.setattr(module, "_fill_multi_value_parameter", _fake_fill)
|
||||
|
||||
ok = module.fill_dsv_multi_select_parameter(
|
||||
page, "Owner", ["CRTM-0000000100"], select_all=False,
|
||||
browser_timeout_ms=lambda: 3_000,
|
||||
report_name="Receipt Detail", program_label="AWSRTM",
|
||||
)
|
||||
|
||||
assert ok is True
|
||||
assert captured == {"control": "multi_value", **_STRUCTURAL_CONTROLS}
|
||||
assert probe.calls == ["Owner"]
|
||||
|
||||
|
||||
def test_fill_multi_select_structural_preferred_registry_is_fallback(monkeypatch):
|
||||
"""优先级:结构性解析优先(ctl 编号随渲染漂移,注册表 ctl 条目只作回退)。
|
||||
|
||||
[断言意图] 结构性命中时使用结构性三件套、注册表回退不被消费;
|
||||
结构性未命中时才回退注册表控件。
|
||||
"""
|
||||
module = _load_module()
|
||||
registry_controls = {
|
||||
"text": "#ReportViewerMain_ctl08_ctl29_txtValue",
|
||||
"toggle": "#ReportViewerMain_ctl08_ctl29_ctl01",
|
||||
"dropdown": "#ReportViewerMain_ctl08_ctl29_divDropDown",
|
||||
}
|
||||
resolve_calls: list[tuple] = []
|
||||
monkeypatch.setattr(
|
||||
module, "resolve_parameter_controls",
|
||||
lambda *a, **k: (resolve_calls.append(a), dict(registry_controls))[1],
|
||||
)
|
||||
probe = _RecordingFrame(result=dict(_STRUCTURAL_CONTROLS))
|
||||
page = _RecordingPage([probe])
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
def _fake_fill(page, label, values, *, timeout_ms, config_override, select_all):
|
||||
captured.update(config_override)
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(module, "_fill_multi_value_parameter", _fake_fill)
|
||||
|
||||
ok = module.fill_dsv_multi_select_parameter(
|
||||
page, "Warehouse", ["RTM"], select_all=False,
|
||||
browser_timeout_ms=lambda: 3_000,
|
||||
report_name="Receipt Detail", program_label="AWSRTM",
|
||||
)
|
||||
|
||||
assert ok is True
|
||||
assert captured.get("text") == _STRUCTURAL_CONTROLS["text"] # 结构性解析优先生效
|
||||
assert resolve_calls == [] # 结构性命中:注册表回退未被消费
|
||||
|
||||
# 结构性未命中 → 回退注册表控件
|
||||
probed = _RecordingFrame(result=None)
|
||||
page = _RecordingPage([probed])
|
||||
captured.clear()
|
||||
ok = module.fill_dsv_multi_select_parameter(
|
||||
page, "Warehouse", ["RTM"], select_all=False,
|
||||
browser_timeout_ms=lambda: 3_000,
|
||||
report_name="Receipt Detail", program_label="AWSRTM",
|
||||
)
|
||||
assert ok is True
|
||||
assert captured.get("text") == registry_controls["text"] # 回退到注册表
|
||||
assert probed.calls == ["Warehouse"]
|
||||
|
||||
|
||||
def test_multi_value_already_set_set_equality_not_substring():
|
||||
"""2026-10-08 Owner@AWSRTM 事故根因回归:SSRS 多选框默认全选,txtValue 恒为全量 CSV,
|
||||
目标值必为该 CSV 的子串——必须用集合相等判定,子串包含会恒误判"已设置"并跳过下拉勾选。"""
|
||||
module = _load_module()
|
||||
all_owners_csv = ",".join(f"CRTM-0000000{n:03d}" for n in range(5, 449))
|
||||
|
||||
# [断言意图] 目标值是全选 CSV 的"子串"但非"全集"——不得判已设置(旧 bug 行为)。
|
||||
assert module._multi_value_already_set(all_owners_csv, ["CRTM-0000000100"]) is False
|
||||
# 完全相等的选中集合才允许跳过。
|
||||
assert module._multi_value_already_set("CRTM-0000000100", ["CRTM-0000000100"]) is True
|
||||
assert module._multi_value_already_set("CRTM-0000000100, CRTM-0000000101",
|
||||
["CRTM-0000000101", "CRTM-0000000100"]) is True
|
||||
# 边界:空当前值/空目标不判已设置;大小写与空白不敏感。
|
||||
assert module._multi_value_already_set("", ["CRTM-0000000100"]) is False
|
||||
assert module._multi_value_already_set(all_owners_csv, []) is False
|
||||
assert module._multi_value_already_set(" crtm-0000000100 ", ["CRTM-0000000100"]) is True
|
||||
Reference in new issue
Block a user