fix: 挂件面板位置联动——bottom-left溢出屏幕/top模式向上溢出(线上实测x=-183.78根因:面板硬编码right:0未随position翻转)
容器挂pos-<position>类+CSS联动规则,无效position归一化;静态测试锁定。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -78,3 +78,24 @@ def test_gdpr_privacy_notice_present():
|
||||
assert 'target="_blank" rel="noopener"' in wjs
|
||||
chat = _read("chat.html")
|
||||
assert "privacy policy" in chat and "privacy-policy/" in chat
|
||||
|
||||
|
||||
def test_position_class_panel_alignment():
|
||||
"""位置联动(2026-09-30 线上bug): 面板对齐必须随 data-position 翻转。
|
||||
根因: .chat-panel 硬编码 right:0(为 bottom-right 设计), positionStyles
|
||||
只应用到按钮容器——bottom-left 时 400px 面板右缘贴 196px 容器右缘,
|
||||
向左溢出屏幕 184px(线上实测 x=-183.78); top-* 模式面板 bottom:80px
|
||||
同理向上溢出。修法: 容器挂 pos-<position> class + CSS 联动规则。"""
|
||||
src = _read("widget.js")
|
||||
# 1) 无效 position 归一化(防 "pos-垃圾" class 与查表错位)
|
||||
assert "if (!positionStyles[position])" in src, "position 需归一化为合法值"
|
||||
# 2) 容器挂载位置 class
|
||||
assert '"widget-container pos-" + position' in src, "container 需挂 pos-<position> class"
|
||||
# 3) CSS 联动规则: 左侧模式面板左对齐, 顶部模式面板从顶部向下弹
|
||||
assert ".widget-container.pos-bottom-left .chat-panel { left:0; right:auto; }" in src
|
||||
assert ".widget-container.pos-top-right .chat-panel { top:0; bottom:auto; }" in src
|
||||
assert ".widget-container.pos-top-left .chat-panel { left:0; right:auto; top:0; bottom:auto; }" in src
|
||||
# 4) pos 规则须在 mobile-host 规则之后注入(同特异性靠顺序决胜, 不得被 bottom:84px 覆盖打断)
|
||||
mobile_rule = ".widget-container.mobile-host .chat-panel { bottom:84px; }"
|
||||
pos_rule = ".widget-container.pos-bottom-left .chat-panel"
|
||||
assert src.index(mobile_rule) < src.index(pos_rule), "pos 规则须在 mobile 规则之后"
|
||||
|
||||
Reference in New Issue
Block a user