fix: 修正规格摘要误判颜色标题 (#277)

This commit is contained in:
chengma
2026-08-18 17:56:21 +08:00
parent 5e27d4cd75
commit 1902935d58
2 changed files with 58 additions and 8 deletions
+44
View File
@@ -263,6 +263,50 @@ class StaticColorSelectionTest(unittest.TestCase):
self.assertTrue(selected)
self.assertEqual(device.clicks, [(194, 1389)])
def test_summary_is_ignored_and_counted_color_heading_is_used(self):
simplified = "紫色诱惑"
traditional = "紫色誘惑"
panel_xml = f'''<hierarchy>
<node bounds="[0,0][1080,2376]">
<node text="请选择:颜色" bounds="[396,827][1053,889]" />
<node text="选择款式后查看优惠" bounds="[639,1083][1044,1136]" />
<node text="尺码" bounds="[36,1202][126,1255]" />
<node text="颜色 (4)" bounds="[36,1416][198,1469]" />
<node bounds="[36,1495][1044,1695]">
<node text="{simplified}" clickable="true"
bounds="[36,1495][249,1580]" />
<node text="其他颜色" clickable="true"
bounds="[270,1495][483,1580]" />
</node>
</node>
</hierarchy>'''
device = StaticColorDevice(panel_xml, selected_text=simplified)
selected = select_color(
device,
panel_xml,
traditional,
action_delay=0.001,
)
self.assertTrue(selected)
self.assertEqual(device.clicks, [(142, 1537)])
self.assertEqual(device.swipes, [])
def test_chinese_parentheses_count_is_a_color_heading(self):
panel_xml = self.panel_xml.replace("颜色分类", "颜色(4)")
device = StaticColorDevice(panel_xml)
selected = select_color(
device,
panel_xml,
"测试黑色",
action_delay=0.001,
)
self.assertTrue(selected)
self.assertEqual(device.clicks, [(194, 1389)])
def test_non_scrollable_row_ignores_same_row_style_option_as_heading(self):
simplified = "纯欲莹白【透.视蕾丝衣.免脱款】"
traditional = "純欲瑩白【透.視蕾絲衣.免脫款】"