aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tui.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-25 14:37:16 -0400
committerhistoria <historiavg@proton.me>2026-08-25 14:37:16 -0400
commit061406b608c5a77b33259506648e0166367b2b9f (patch)
treec18633630d160016af285389a629da53a3a4161c /app/tests/test_tui.py
parent0badc06550ed2e46c7c4b9f83db755737ffc0412 (diff)
downloadtts-audiobook-generator-061406b608c5a77b33259506648e0166367b2b9f.tar.gz
feat: simpler menu for start/stop backend servers
Diffstat (limited to 'app/tests/test_tui.py')
-rw-r--r--app/tests/test_tui.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py
index 5b5cb3c..030b668 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -50,6 +50,7 @@ class FakeCurses:
ACS_LRCORNER = "lr"
ACS_VLINE = "v"
ACS_HLINE = "h"
+ ACS_RARROW = "ra"
class error(Exception):
pass
@@ -254,6 +255,33 @@ class MenuTests(TuiTestCase):
if drawn == "Build audio.cpp server")
self.assertEqual(label_attr, tui._THEME["body"])
+ def test_selected_row_has_arrow_in_the_margin(self):
+ # The highlighted option gets an ACS_RARROW in the blank margin
+ # left of its text; unselected rows draw none.
+ screen = FakeScreen(keys=[10])
+ tui.menu(screen, "Pick", self.OPTIONS)
+ x0, _ = self.dialog_box(screen)
+ arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 1
+ arrows = [(y, x) for y, x, ch, _ in screen.chars
+ if ch == FakeCurses.ACS_RARROW]
+ y_first = next(y for y, _, text, _ in screen.strings
+ if text == "first option")
+ self.assertEqual(arrows, [(y_first, arrow_x)])
+
+ def test_arrow_follows_the_cursor(self):
+ # Down moves the arrow onto the second option on the redraw.
+ screen = FakeScreen(keys=[FakeCurses.KEY_DOWN, 10])
+ tui.menu(screen, "Pick", self.OPTIONS)
+ x0, _ = self.dialog_box(screen)
+ arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 1
+ arrows = [y for y, x, ch, _ in screen.chars
+ if ch == FakeCurses.ACS_RARROW and x == arrow_x]
+ y_first = next(y for y, _, text, _ in screen.strings
+ if text == "first option")
+ y_second = next(y for y, _, text, _ in screen.strings
+ if text == "second option")
+ self.assertEqual(arrows, [y_first, y_second])
+
class MenuTableTests(TuiTestCase):
"""The optional status table: aligned columns and colored statuses."""