Split core and TUI crates

This commit is contained in:
Mikhail Kilin
2026-05-20 00:31:18 +03:00
parent 91a8700b8e
commit eefac431e5
238 changed files with 624 additions and 191 deletions

View File

@@ -0,0 +1,134 @@
// Integration tests for profile flow
mod helpers;
use helpers::fake_tdclient::FakeTdClient;
use helpers::test_data::create_test_chat;
use tele_tui::tdlib::ProfileInfo;
use tele_tui::types::ChatId;
/// Test: Открытие профиля в личном чате (i)
#[tokio::test]
async fn test_open_profile_in_private_chat() {
let client = FakeTdClient::new();
let chat = create_test_chat("Alice", 123);
let _client = client.with_chat(chat);
// Пользователь открыл чат и нажал 'i'
let profile_mode = true;
assert!(profile_mode);
// В реальном App загрузится ProfileInfo для этого чата
}
/// Test: Профиль показывает имя, username, телефон
#[tokio::test]
async fn test_profile_shows_user_info() {
let profile = ProfileInfo {
chat_id: ChatId::new(123),
title: "Alice Johnson".to_string(),
username: Some("alice".to_string()),
phone_number: Some("+1234567890".to_string()),
bio: None,
chat_type: "Личный чат".to_string(),
member_count: None,
description: None,
invite_link: None,
is_group: false,
online_status: Some("Online".to_string()),
};
assert_eq!(profile.title, "Alice Johnson");
assert_eq!(profile.username.as_ref().unwrap(), "alice");
assert_eq!(profile.phone_number.as_ref().unwrap(), "+1234567890");
assert_eq!(profile.chat_type, "Личный чат");
}
/// Test: Профиль в группе показывает количество участников
#[tokio::test]
async fn test_profile_shows_group_member_count() {
let profile = ProfileInfo {
chat_id: ChatId::new(456),
title: "Work Team".to_string(),
username: None,
phone_number: None,
bio: Some("Our work group".to_string()),
chat_type: "Группа".to_string(),
member_count: Some(25),
description: None,
invite_link: None,
is_group: true,
online_status: None,
};
assert_eq!(profile.title, "Work Team");
assert_eq!(profile.chat_type, "Группа");
assert_eq!(profile.member_count, Some(25));
assert_eq!(profile.bio.as_ref().unwrap(), "Our work group");
}
/// Test: Профиль в канале
#[tokio::test]
async fn test_profile_shows_channel_info() {
let profile = ProfileInfo {
chat_id: ChatId::new(789),
title: "News Channel".to_string(),
username: Some("news_channel".to_string()),
phone_number: None,
bio: Some("Latest news updates".to_string()),
chat_type: "Канал".to_string(),
member_count: Some(1000),
description: Some("Latest news updates".to_string()),
invite_link: Some("t.me/news_channel".to_string()),
is_group: false,
online_status: None,
};
assert_eq!(profile.title, "News Channel");
assert_eq!(profile.username.as_ref().unwrap(), "news_channel");
assert_eq!(profile.chat_type, "Канал");
assert_eq!(profile.member_count, Some(1000)); // Subscribers
}
/// Test: Закрытие профиля (Esc)
#[tokio::test]
async fn test_close_profile_with_esc() {
// Профиль открыт
let _profile_mode = true;
// Пользователь нажал Esc
let profile_mode = false;
assert!(!profile_mode);
}
/// Test: Профиль без username и phone
#[tokio::test]
async fn test_profile_without_optional_fields() {
let profile = ProfileInfo {
chat_id: ChatId::new(999),
title: "Anonymous User".to_string(),
username: None,
phone_number: None,
bio: None,
chat_type: "Личный чат".to_string(),
member_count: None,
description: None,
invite_link: None,
is_group: false,
online_status: None,
};
// Обязательные поля заполнены
assert_eq!(profile.title, "Anonymous User");
assert_eq!(profile.chat_type, "Личный чат");
// Опциональные поля None
assert_eq!(profile.username, None);
assert_eq!(profile.phone_number, None);
assert_eq!(profile.bio, None);
// В UI будут отображаться только доступные поля
}