This commit is contained in:
Mikhail Kilin
2026-01-31 23:02:53 +03:00
parent af3c36b9a1
commit c5896b7f14
17 changed files with 1899 additions and 567 deletions

View File

@@ -3,6 +3,7 @@
mod helpers;
use helpers::test_data::{create_test_chat, TestChatBuilder};
use tele_tui::types::{ChatId, MessageId};
use std::collections::HashMap;
/// Простая структура для хранения черновиков (как в реальном App)
@@ -41,8 +42,8 @@ impl DraftManager {
}
/// Test: Переключение между чатами сохраняет текст
#[test]
fn test_switching_chats_saves_draft() {
#[tokio::test]
async fn test_switching_chats_saves_draft() {
let mut drafts = DraftManager::new();
// Пользователь в чате 123, начал печатать
@@ -64,8 +65,8 @@ fn test_switching_chats_saves_draft() {
}
/// Test: Возврат в чат восстанавливает текст
#[test]
fn test_returning_to_chat_restores_draft() {
#[tokio::test]
async fn test_returning_to_chat_restores_draft() {
let mut drafts = DraftManager::new();
// Сохраняем черновик в чате 123
@@ -82,8 +83,8 @@ fn test_returning_to_chat_restores_draft() {
}
/// Test: Отправка сообщения удаляет черновик
#[test]
fn test_sending_message_clears_draft() {
#[tokio::test]
async fn test_sending_message_clears_draft() {
let mut drafts = DraftManager::new();
// Сохранили черновик
@@ -99,8 +100,8 @@ fn test_sending_message_clears_draft() {
}
/// Test: Индикатор черновика в списке чатов
#[test]
fn test_draft_indicator_in_chat_list() {
#[tokio::test]
async fn test_draft_indicator_in_chat_list() {
let mut drafts = DraftManager::new();
// Создаём несколько чатов
@@ -126,8 +127,8 @@ fn test_draft_indicator_in_chat_list() {
}
/// Test: Множественные черновики в разных чатах
#[test]
fn test_multiple_drafts_in_different_chats() {
#[tokio::test]
async fn test_multiple_drafts_in_different_chats() {
let mut drafts = DraftManager::new();
// Создаём черновики в 3 чатах
@@ -150,8 +151,8 @@ fn test_multiple_drafts_in_different_chats() {
}
/// Test: Пустой текст не сохраняется как черновик
#[test]
fn test_empty_text_does_not_save_draft() {
#[tokio::test]
async fn test_empty_text_does_not_save_draft() {
let mut drafts = DraftManager::new();
// Пытаемся сохранить пустой черновик
@@ -172,8 +173,8 @@ fn test_empty_text_does_not_save_draft() {
}
/// Test: Редактирование черновика
#[test]
fn test_editing_draft() {
#[tokio::test]
async fn test_editing_draft() {
let mut drafts = DraftManager::new();
// Сохраняем начальный черновик