fix: 兼容非滚动规格确认面板 (#275)

This commit is contained in:
chengma
2026-08-18 17:31:49 +08:00
parent cb7719c21b
commit 7b6e59c58d
2 changed files with 87 additions and 14 deletions
+54
View File
@@ -46,6 +46,42 @@ def style_package_spec_xml() -> str:
</hierarchy>"""
def root_level_non_scrollable_confirmation_xml() -> str:
"""模拟顶部提示不可见、证据节点都挂在全屏根容器的确认页。"""
return """<hierarchy>
<node package="com.xunmeng.pinduoduo" visible-to-user="true"
bounds="[0,0][1080,2376]">
<node package="com.xunmeng.pinduoduo"
text="已选:女小码 测试白色" bounds="[396,708][1053,822]"/>
<node package="com.xunmeng.pinduoduo"
class="android.widget.EditText" text="1"
bounds="[462,876][540,954]"/>
<node package="com.xunmeng.pinduoduo" content-desc="减少数量"
clickable="true" bounds="[396,876][462,954]"/>
<node package="com.xunmeng.pinduoduo" content-desc="增加数量"
clickable="true" bounds="[540,876][606,954]"/>
<node package="com.xunmeng.pinduoduo" text="尺码"
bounds="[36,1153][126,1206]"/>
<node package="com.xunmeng.pinduoduo"
text="女小码【建议-体重75-100斤】" clickable="true"
selected="true" bounds="[36,1232][649,1317]"/>
<node package="com.xunmeng.pinduoduo"
text="女大码【建议-体重101-120斤】" clickable="true"
bounds="[36,1347][695,1432]"/>
<node package="com.xunmeng.pinduoduo" text="颜色"
bounds="[36,1482][126,1535]"/>
<node package="com.xunmeng.pinduoduo" text="测试白色"
clickable="true" selected="true" bounds="[36,1561][730,1646]"/>
<node package="com.xunmeng.pinduoduo" clickable="true"
bounds="[0,2181][1080,2328]">
<node package="com.xunmeng.pinduoduo" text="提交订单 ¥28.10"
bounds="[375,2225][885,2284]"/>
</node>
</node>
</hierarchy>"""
@dataclass(frozen=True)
class FakeTask:
goods_url: str
@@ -863,6 +899,24 @@ class PddCollectParserTest(unittest.TestCase):
[item.name for item in result.dimensions],
)
def test_parse_root_level_confirmation_with_size_before_color(self):
xml_data = root_level_non_scrollable_confirmation_xml()
result = parse_spec_panel(xml_data)
self.assertTrue(_is_spec_panel_open(xml_data))
self.assertEqual(
[(item.key, item.name) for item in result.dimensions],
[("size", "尺码"), ("color", "颜色")],
)
self.assertEqual(
[value.text for value in result.dimensions[0].values],
[
"女小码【建议-体重75-100斤】",
"女大码【建议-体重101-120斤】",
],
)
def test_collects_static_sizes_from_non_scrollable_submit_hint_panel(self):
device = FakeCollectDevice(self.home_xml, self.submit_hint_spec_xml)
device.opened_url = (