diff options
Diffstat (limited to 'app/tests')
| -rw-r--r-- | app/tests/test_tui.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py index 4c8b431..72465c1 100644 --- a/app/tests/test_tui.py +++ b/app/tests/test_tui.py @@ -1355,6 +1355,58 @@ class FlashTests(TuiTestCase): self.assertIsNone(frame.status) +class FrameStatusTests(TuiTestCase): + """Frame status: a multi-line status stacks above the footer row. + + An embedded "\\n" must never spill onto the footer's row (the + controls line) — the dialog grows and the block is drawn one line + per row, ending just above the footer. + """ + + MESSAGE = "first line\nsecond line\n" # trailing blank separator line + + def _draw(self): + frame = tui.Frame(self.screen, "Generate Speech", + "Up/Down = move Enter = edit") + frame.mark("Model: qwen-tts", selectable=True) + frame.buttons = (["Generate!", "Cancel"], 0) + frame.status = (self.MESSAGE, "err") + frame.draw() + + def _y_of(self, text, exact=True): + matches = self.screen.strings if exact else \ + [(y, x, t, a) for y, x, t, a in self.screen.strings + if t.strip() == text] + return next(y for y, _, t, _ in matches + if (t == text if exact else True)) + + def test_status_lines_stack_above_the_footer_row(self): + self._draw() + first_y = self._y_of("first line", exact=False) + second_y = self._y_of("second line", exact=False) + footer_y = self._y_of("Up/Down = move Enter = edit") + self.assertEqual(second_y, first_y + 1) + # The trailing "\n" separates the error from the controls: the + # footer sits one blank row below the last status line. + self.assertEqual(footer_y, second_y + 2) + self.assert_inside_border(self.screen) + + def test_buttons_clear_the_status_block(self): + self._draw() + buttons_y = self._y_of("[ Generate! ]") + first_y = self._y_of("first line", exact=False) + self.assertLess(buttons_y, first_y) + self.assert_inside_border(self.screen) + + def test_single_line_status_sits_directly_above_the_footer(self): + frame = tui.Frame(self.screen, "Title", "footer") + frame.status = ("only line", "err") + frame.draw() + status_y = self._y_of("only line", exact=False) + footer_y = self._y_of("footer") + self.assertEqual(footer_y, status_y + 1) + + class TextViewerTests(TuiTestCase): """tui.text_viewer: a scrollable read-only dialog; Esc/q/Enter closes.""" |
