aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tui.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-27 22:40:58 -0400
committerhistoria <historiavg@proton.me>2026-08-27 22:40:58 -0400
commiteb465fb2a972b6b07c4b427f940b186745ce6d90 (patch)
tree416e0a706da7ede4f273458a2e243ac22393d606 /app/tests/test_tui.py
parent4c3ba1b68107208fe32c223588576a7bdca19a12 (diff)
downloadtts-audiobook-generator-eb465fb2a972b6b07c4b427f940b186745ce6d90.tar.gz
fix: can't check checkboxes in tts model page
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 e12da76..e765e60 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -1147,6 +1147,34 @@ class CheckboxTreeTests(TuiTestCase):
picked = tui.checkbox_tree(screen, "Pick models", self.FAMILIES)
self.assertEqual(picked, [(0, "pkg-a")])
+ def test_space_toggles_option_row(self):
+ # Enter on the family checks pkg-a and expands; Down twice lands
+ # on the pkg-b option row; Space checks it; confirm returns both.
+ screen = FakeScreen(keys=[10, FakeCurses.KEY_DOWN,
+ FakeCurses.KEY_DOWN, ord(" "), 9, 10])
+ picked = tui.checkbox_tree(screen, "Pick models", self.FAMILIES)
+ self.assertEqual(picked, [(0, "pkg-a"), (0, "pkg-b")])
+
+ def test_enter_toggles_option_row(self):
+ # Enter on the family checks pkg-a and expands; Down lands on the
+ # pkg-a option row; Enter there unchecks it; Down to pkg-b, Space
+ # checks it. Confirm returns only pkg-b.
+ screen = FakeScreen(keys=[10, FakeCurses.KEY_DOWN, 10,
+ FakeCurses.KEY_DOWN, ord(" "), 9, 10])
+ picked = tui.checkbox_tree(screen, "Pick models", self.FAMILIES)
+ self.assertEqual(picked, [(0, "pkg-b")])
+
+ def test_unhandled_key_on_row_is_ignored(self):
+ # A key that is neither motion nor toggle (here "x") must not
+ # toggle anything or crash on either row kind; Esc then aborts.
+ marker = object()
+ screen = FakeScreen(keys=[ord("x"), FakeCurses.KEY_DOWN, ord("x"),
+ 27])
+ self.assertIs(
+ tui.checkbox_tree(screen, "Pick models", self.FAMILIES,
+ back_value=marker),
+ marker)
+
def test_prechecked_selection_confirmed(self):
# checked= seeds the tree (modify flow): Tab then Confirm accepts
# the pre-checked options without any extra key presses.