aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tui.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests/test_tui.py')
-rw-r--r--app/tests/test_tui.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py
index a0e0309..6fc3fd5 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -965,6 +965,27 @@ class FormTests(TuiTestCase):
self.assertEqual(Path(mk_browser.call_args[1]["start"]),
Path("/start"))
+ def test_dir_field_passes_info_and_preview_to_the_browser(self):
+ # A dir field may carry info/preview callbacks (e.g. the .wav
+ # count alerts); the form forwards them to the browser untouched.
+ def info(directory):
+ return ("info text", "ok")
+
+ def preview(directory):
+ return ("preview text", "warn")
+
+ picked = Path("/picked/voices")
+ fields = [{"key": "voices", "label": "Voices directory",
+ "kind": "dir", "value": Path("/start"),
+ "info": info, "preview": preview}]
+ with patch.object(tui, "browse_directory",
+ return_value=picked) as mk_browser:
+ screen = FakeScreen(keys=[10, 10])
+ result = tui.form(screen, "Settings", fields)
+ self.assertEqual(result, {"voices": picked})
+ self.assertIs(mk_browser.call_args[1]["info"], info)
+ self.assertIs(mk_browser.call_args[1]["preview"], preview)
+
def test_dir_pick_moves_focus_to_the_accept_button(self):
# Accepting a directory is a completed choice: focus lands on
# Save, so the very next Enter submits — no Tab hunting.