diff options
| author | historia <historiavg@proton.me> | 2026-08-24 18:57:09 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-24 18:57:09 -0400 |
| commit | 0522e73b68291af62e43c387ab8f9b8ffa2cab47 (patch) | |
| tree | 1800168c1ed5de7540624265945faba8251a7cab /app/tests/test_tui.py | |
| parent | d950fc8e64ee508334e608f6045d687d73a464be (diff) | |
| download | tts-audiobook-generator-0522e73b68291af62e43c387ab8f9b8ffa2cab47.tar.gz | |
feat: configure [backend] loads existing backend config rather than just overwriting it
Diffstat (limited to 'app/tests/test_tui.py')
| -rw-r--r-- | app/tests/test_tui.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py index ce408af..49960a1 100644 --- a/app/tests/test_tui.py +++ b/app/tests/test_tui.py @@ -857,6 +857,37 @@ class CheckboxTreeTests(TuiTestCase): picked = tui.checkbox_tree(screen, "Pick models", self.FAMILIES) self.assertEqual(picked, [(0, "pkg-a")]) + def test_prechecked_selection_accepted_directly(self): + # checked= seeds the tree (modify flow): Enter alone accepts the + # pre-checked option without any key presses in between. + screen = FakeScreen(keys=[10]) + picked = tui.checkbox_tree( + screen, "Pick models", self.FAMILIES, + checked={(0, "pkg-b"), (1, "pkg-c")}) + self.assertEqual(picked, [(0, "pkg-b"), (1, "pkg-c")]) + + def test_prechecked_options_draw_as_checked(self): + screen = FakeScreen(keys=[10]) + tui.checkbox_tree(screen, "Pick models", self.FAMILIES, + checked={(0, "pkg-b")}) + texts = [text for _, _, text, _ in screen.strings] + # The pre-checked option row (indented) draws its box checked. + self.assertIn("[x] ", texts) + # ...and the family row is expanded (its options are listed). + self.assertIn("- Family one", texts) + + def test_prechecked_family_cursor_starts_on_it(self): + # Only the second family is pre-checked, so the cursor starts on it: + # Space clears then re-checks that family (the cursor never moves). + # If the cursor were still on the first family, the two Spaces would + # check then clear family one and Enter would flash instead of + # accepting anything. + screen = FakeScreen(keys=[ord(" "), ord(" "), 10]) + picked = tui.checkbox_tree( + screen, "Pick models", self.FAMILIES, + checked={(1, "pkg-c")}) + self.assertEqual(picked, [(1, "pkg-c")]) + def test_empty_families_rejected(self): with self.assertRaises(ValueError): tui.checkbox_tree(self.screen, "Pick", []) |
