This commit is contained in:
Mikhail Kilin
2026-02-13 19:52:53 +03:00
parent 6d08300daa
commit 6639dc876c
38 changed files with 961 additions and 123 deletions

View File

@@ -145,6 +145,7 @@ async fn test_cursor_navigation_in_input() {
let mut app = TestAppBuilder::new()
.with_chats(vec![create_test_chat("Chat 1", 101)])
.selected_chat(101)
.insert_mode()
.build();
// Вводим текст "Hello"
@@ -182,6 +183,7 @@ async fn test_home_end_in_input() {
let mut app = TestAppBuilder::new()
.with_chats(vec![create_test_chat("Chat 1", 101)])
.selected_chat(101)
.insert_mode()
.build();
// Вводим текст
@@ -206,6 +208,7 @@ async fn test_backspace_with_cursor() {
let mut app = TestAppBuilder::new()
.with_chats(vec![create_test_chat("Chat 1", 101)])
.selected_chat(101)
.insert_mode()
.build();
// Вводим "Hello"
@@ -238,6 +241,7 @@ async fn test_insert_char_at_cursor_position() {
let mut app = TestAppBuilder::new()
.with_chats(vec![create_test_chat("Chat 1", 101)])
.selected_chat(101)
.insert_mode()
.build();
// Вводим "Hllo"
@@ -259,25 +263,25 @@ async fn test_insert_char_at_cursor_position() {
assert_eq!(app.cursor_position, 2);
}
/// Test: Навигация вверх по сообщениям из пустого инпута
/// Test: Normal mode автоматически входит в MessageSelection
#[tokio::test]
async fn test_up_arrow_selects_last_message_when_input_empty() {
async fn test_normal_mode_auto_enters_message_selection() {
let messages = vec![
TestMessageBuilder::new("Msg 1", 1).outgoing().build(),
TestMessageBuilder::new("Msg 2", 2).outgoing().build(),
TestMessageBuilder::new("Msg 3", 3).outgoing().build(),
];
let mut app = TestAppBuilder::new()
.with_chats(vec![create_test_chat("Chat 1", 101)])
.selected_chat(101)
.with_messages(101, messages)
.build();
// Инпут пустой
// Инпут пустой, Normal mode
assert_eq!(app.message_input, "");
// Up - должен начать выбор сообщения (последнего)
// Любая клавиша в Normal mode — auto-enters MessageSelection
handle_main_input(&mut app, key(KeyCode::Up)).await;
// Проверяем что вошли в режим выбора сообщения