Hopefully make pty more similar to tested console behavior.

This commit is contained in:
Storm Dragon
2026-05-08 20:10:08 -04:00
parent 90efad362b
commit 114a7b0da7
3 changed files with 114 additions and 34 deletions
+10 -10
View File
@@ -88,8 +88,8 @@ class TestIncomingCommand:
[
"Status old",
"Users old",
"alice: hi",
"bob: hello",
"UserA: hi",
"UserB: hello",
"> ",
]
)
@@ -97,19 +97,19 @@ class TestIncomingCommand:
[
"Status new",
"Users new",
"bob: hello",
"carol: test",
"UserB: hello",
"UserC: test",
"> ",
]
)
env["screen"]["new_delta"] = "\n".join(
["Status new", "Users new", "carol: test"]
["Status new", "Users new", "UserC: test"]
)
command.run()
output_manager.present_text.assert_called_once_with(
"carol: test", interrupt=False, flush=False
"UserC: test", interrupt=False, flush=False
)
def test_keeps_header_update_when_no_lower_screen_insert_exists(
@@ -120,16 +120,16 @@ class TestIncomingCommand:
[
"Status old",
"Users old",
"alice: hi",
"bob: hello",
"UserA: hi",
"UserB: hello",
]
)
env["screen"]["new_content_text"] = "\n".join(
[
"Status new",
"Users new",
"alice: hi",
"bob: hello",
"UserA: hi",
"UserB: hello",
]
)
env["screen"]["new_delta"] = "\n".join(["Status new", "Users new"])
+37
View File
@@ -1,3 +1,4 @@
import time
from unittest.mock import Mock
import pytest
@@ -18,6 +19,7 @@ def _build_screen_manager(old_text, old_cursor):
),
"CursorManager": Mock(is_application_window_set=Mock(return_value=False)),
"DebugManager": Mock(write_debug_out=Mock()),
"InputManager": Mock(get_last_input_time=Mock(return_value=0)),
"ScreenManager": manager,
"SettingsManager": Mock(get_setting_as_bool=Mock(return_value=False)),
},
@@ -61,3 +63,38 @@ def test_prompt_repaint_during_typing_keeps_only_typed_delta():
assert env["screen"]["new_delta"] == "h"
assert env["screen"]["new_delta_is_typing"] is True
@pytest.mark.unit
def test_tui_input_line_append_is_typing_delta():
manager, env = _build_screen_manager(
"\n".join(
[
"<UserA> hi".ljust(20),
"[Username] ".ljust(20),
]
),
{"x": 11, "y": 1},
)
env["runtime"]["InputManager"].get_last_input_time.return_value = time.time()
manager.update(
{
"bytes": b"",
"lines": 2,
"columns": 20,
"textCursor": {"x": 12, "y": 1},
"screen": "pty",
"text": "\n".join(
[
"<UserA> hi".ljust(20),
"[Username] l".ljust(20),
]
),
"attributes": [],
},
"onScreenUpdate",
)
assert env["screen"]["new_delta"] == "l"
assert env["screen"]["new_delta_is_typing"] is True