Skip to content

Commit 25fb7c4

Browse files
wehosHongzhi Wenclaude
authored
fix(test): 同步 compact 轮盘半径与历史命中区契约到当前源码 (#1616)
* fix(test): 同步 compact 轮盘半径与历史命中区契约到当前源码 test_react_chat_window_static.py 两处断言落后于源码,导致 clean checkout 上预先失败: - 轮盘 slot transform 的 translateX(91.92px) 已在 #1599 抽成 var(--compact-tool-wheel-orbit-radius),#1605 又把值回调到 80px。 断言改为匹配变量形式,旋转角度不变。 - 历史消息/操作栏的 data-compact-hit-region-id 已在 #1604 用 historyInteractive 三元门控(关闭态不再占命中区),断言同步加门控; history:preview 仍为静态字面量,保持不变。 源码均为有意改动,仅测试漏更新,与本次 compact surface drag 无关。 uv run pytest tests/unit/test_react_chat_window_static.py -> 25 passed Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: 补强 compact 轮盘半径与历史命中区契约断言 回应 Codex review 的两条 P2: - orbit 半径变量化后丢失了对数值的保护:补 --compact-tool-wheel-orbit-radius: 80px 在 fan_block 的直接断言, 防止变量值回退(如 45.96px)而测试仍通过。 - 命中区真正的门是 data-compact-hit-region 属性(collector 用 querySelectorAll('[data-compact-hit-region="true"]') 选元素,id 缺失时 合成),仅断言 id 门控不够:补断言 messages / controls 块的 data-compact-hit-region 与 -kind 也被 historyInteractive 门控。 uv run pytest tests/unit/test_react_chat_window_static.py -> 25 passed Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Hongzhi Wen <cartabio.coder1@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a1d1ce9 commit 25fb7c4

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

tests/unit/test_react_chat_window_static.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ def test_compact_tool_fan_uses_shell_local_anchor_not_fixed_viewport_position():
307307

308308
assert "position: absolute;" in fan_block
309309
assert "--compact-tool-wheel-hover-radius: 116px;" in fan_block
310+
assert "--compact-tool-wheel-orbit-radius: 80px;" in fan_block
310311
assert "--compact-tool-fan-focus-x: var(--compact-tool-wheel-hover-radius);" in fan_block
311312
assert "--compact-tool-fan-focus-y: var(--compact-tool-wheel-hover-radius);" in fan_block
312313
assert "--compact-tool-wheel-center-x: var(--compact-tool-wheel-hover-radius);" in fan_block
@@ -353,10 +354,10 @@ def test_compact_tool_fan_uses_shell_local_anchor_not_fixed_viewport_position():
353354
assert '.compact-input-tool-item[data-compact-tool-wheel-slot="hidden"]' in styles
354355
assert '.compact-input-tool-item[data-compact-tool-wheel-slot="hidden-forward"]' in styles
355356
assert '.compact-input-tool-item[data-compact-tool-wheel-slot="hidden-backward"]' in styles
356-
assert "rotate(107.35deg) translateX(91.92px) rotate(-107.35deg)" in styles
357-
assert "rotate(-17.35deg) translateX(91.92px) rotate(17.35deg)" in styles
358-
assert "rotate(-48.51deg) translateX(91.92px) rotate(48.51deg)" in styles
359-
assert "rotate(138.51deg) translateX(91.92px) rotate(-138.51deg)" in styles
357+
assert "rotate(107.35deg) translateX(var(--compact-tool-wheel-orbit-radius)) rotate(-107.35deg)" in styles
358+
assert "rotate(-17.35deg) translateX(var(--compact-tool-wheel-orbit-radius)) rotate(17.35deg)" in styles
359+
assert "rotate(-48.51deg) translateX(var(--compact-tool-wheel-orbit-radius)) rotate(48.51deg)" in styles
360+
assert "rotate(138.51deg) translateX(var(--compact-tool-wheel-orbit-radius)) rotate(-138.51deg)" in styles
360361
assert "translateX(83.82px)" not in wheel_block
361362
assert "translateX(89.74px)" not in wheel_block
362363
assert "translateX(92.06px)" not in wheel_block
@@ -776,6 +777,14 @@ def test_compact_history_hit_contract_keeps_transparent_wrappers_out_of_hit_regi
776777
'className="compact-export-history-scroll-content"',
777778
1,
778779
)[0]
780+
message_hit_block = panel_source.split('className="compact-export-history-bubble"', 1)[1].split(
781+
'compact-export-history-check',
782+
1,
783+
)[0]
784+
controls_hit_block = panel_source.split('className="compact-export-history-controls"', 1)[1].split(
785+
'compact-export-history-controls-content',
786+
1,
787+
)[0]
779788

780789
assert "pointer-events: none;" in anchor_block
781790
assert "pointer-events: none;" in panel_block
@@ -789,8 +798,12 @@ def test_compact_history_hit_contract_keeps_transparent_wrappers_out_of_hit_regi
789798
assert "function getCompactHistoryScrollbarRect(element, parentRect)" in script
790799
assert "id: 'history:scrollbar'" in script
791800
assert "data-compact-hit-region" not in scroll_jsx_block
792-
assert 'data-compact-hit-region-id={`history:message:${message.id}`}' in panel_source
793-
assert 'data-compact-hit-region-id="history:controls"' in panel_source
801+
assert 'data-compact-hit-region-id={historyInteractive ? `history:message:${message.id}` : undefined}' in panel_source
802+
assert "data-compact-hit-region={historyInteractive ? 'true' : undefined}" in message_hit_block
803+
assert "data-compact-hit-region-kind={historyInteractive ? 'message' : undefined}" in message_hit_block
804+
assert "data-compact-hit-region-id={historyInteractive ? 'history:controls' : undefined}" in panel_source
805+
assert "data-compact-hit-region={historyInteractive ? 'true' : undefined}" in controls_hit_block
806+
assert "data-compact-hit-region-kind={historyInteractive ? 'controls' : undefined}" in controls_hit_block
794807
assert 'data-compact-hit-region-id="history:preview"' in panel_source
795808

796809

0 commit comments

Comments
 (0)