Skip to content

Commit d0be57c

Browse files
committed
test(tui): force footer width regression across a display-width boundary
The wide/combining-char footer test used broad terminal widths, so the wide command never approached the width boundary and a len()-based guard could still have passed. Derive the width from the fixture so the left region must truncate: a len()-based renderer would under-truncate and overflow the row, while display-width accounting keeps every row within bounds and emits the capability-safe ellipsis (now asserted).
1 parent 0501693 commit d0be57c

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

tests/ui_and_conv/test_footer_view_model.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,27 @@ def test_footer_rows_respect_display_width_with_wide_and_combining_chars(
184184
"""
185185
monkeypatch.setenv("NO_COLOR", "1")
186186
session = _session()
187-
wide_command = "全角指令" + "é" * 3
188-
for width in (40, 80, 120):
189-
model = _model(width, command=wide_command, ascii_only=False)
190-
assert select_footer_content(model) is not None
191-
legacy = session._render_legacy_bottom_toolbar(model)
192-
card = session._render_card_bottom_toolbar(model)
193-
for rendered in (legacy, card):
194-
rows = _text(rendered).splitlines()
195-
assert all(_display_width(row) <= width for row in rows)
196-
assert "Update available"[: max(0, width - 1)] in rows[-1]
187+
# A run of CJK glyphs (each two columns, one code point) plus a zero-width
188+
# combining mark: display width far exceeds the code-point count.
189+
wide_command = "全角指令文字幅測試漢字表示幅検証" + "é"
190+
# Derive a terminal narrower than the command's display width so the left
191+
# region must truncate. A len()-based guard would treat the command as fitting
192+
# and under-truncate, overflowing the row; only display-width accounting keeps
193+
# the row within bounds and emits the capability-safe ellipsis.
194+
width = _display_width(wide_command) - 6
195+
model = _model(width, command=wide_command, ascii_only=False)
196+
selected = select_footer_content(model)
197+
assert selected is not None and selected.kind == "command"
198+
legacy = session._render_legacy_bottom_toolbar(model)
199+
card = session._render_card_bottom_toolbar(model)
200+
for rendered in (legacy, card):
201+
text = _text(rendered)
202+
rows = text.splitlines()
203+
assert all(_display_width(row) <= width for row in rows)
204+
# Truncation must have fired at this boundary (regression guard: a
205+
# len()-based renderer would not have needed to truncate here).
206+
assert "…" in text
207+
assert "Update available"[: max(0, width - 1)] in rows[-1]
197208

198209

199210
def test_left_and_right_toasts_both_render(monkeypatch: pytest.MonkeyPatch) -> None:

0 commit comments

Comments
 (0)