diff options
| author | historia <historiavg@proton.me> | 2026-08-26 19:58:45 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-26 19:58:45 -0400 |
| commit | 975bd960fd07e75799b8e3adc4c0033046b34792 (patch) | |
| tree | 6d5a13c0ad6eb3a6afeb5659bd9e9e21e8c215bc /app/tests/test_tui.py | |
| parent | 5af37bbd575eec89c6ac2fecf2d8c2eda4c1728d (diff) | |
| download | tts-audiobook-generator-975bd960fd07e75799b8e3adc4c0033046b34792.tar.gz | |
feat: language and option fields in tui, context-sensitive voice label
Diffstat (limited to 'app/tests/test_tui.py')
| -rw-r--r-- | app/tests/test_tui.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py index 4ff70fb..cd4e535 100644 --- a/app/tests/test_tui.py +++ b/app/tests/test_tui.py @@ -624,6 +624,44 @@ class FormTests(TuiTestCase): with self.assertRaises(ValueError): tui.form(self.screen, "Settings", []) + def test_dynamic_label_renders_with_column_alignment(self): + # A callable label is resolved against the field list on every + # redraw; static labels pad to the widest resolved label so all + # value columns line up. + fields = [ + {"key": "fmt", "kind": "choice", "value": "mp3", + "label": lambda fs: "Dynamic-" + fs[0]["value"], + "choices": ["mp3", "ogg"]}, + {"key": "chunk", "label": "Chunk", "kind": "text", + "value": "250"}, + ] + screen = FakeScreen(keys=[9, 10]) + result = tui.form(screen, "Settings", fields) + self.assertEqual(result, {"fmt": "mp3", "chunk": "250"}) + rows = [(y, x, text) for y, x, text, _ in screen.strings] + label_row = next(r for r in rows if r[2].startswith("Dynamic-")) + self.assertEqual(label_row[2], "Dynamic-mp3:") + chunk_row = next(r for r in rows if r[2].startswith("Chunk:")) + self.assertEqual(chunk_row[1], label_row[1]) + self.assert_inside_border(screen) + + def test_sub_dialog_title_uses_resolved_label(self): + # The choice menu (and text/directory editors) are titled with the + # resolved label, not the raw callable. + fields = [ + {"key": "model", "label": "Model", "kind": "text", + "value": "base"}, + {"key": "voice", "kind": "text", "value": "", + "label": lambda fs: "Voice of " + fs[0]["value"]}, + ] + # Down to the second field, Enter opens its editor (titled with the + # resolved label), Esc backs out; Tab -> Save, Enter. + screen = FakeScreen(keys=[FakeCurses.KEY_DOWN, 10, 27, 9, 10]) + tui.form(screen, "Settings", fields) + titles = [text for _, _, text, _ in screen.strings + if "Voice of base" in text] + self.assertTrue(titles) + def test_field_note_renders_and_save(self): fields = self._fields() fields[1]["note"] = "A short section note" |
