style: auto-format entire codebase with cargo fmt (stable rustfmt.toml)
Some checks failed
ci/woodpecker/pr/check Pipeline failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
ci/woodpecker/pr/check Pipeline failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
This commit is contained in:
@@ -23,10 +23,7 @@ async fn test_user_journey_app_launch_to_chat_list() {
|
||||
let chat2 = TestChatBuilder::new("Work Group", 102).build();
|
||||
let chat3 = TestChatBuilder::new("Boss", 103).build();
|
||||
|
||||
let client = client
|
||||
.with_chat(chat1)
|
||||
.with_chat(chat2)
|
||||
.with_chat(chat3);
|
||||
let client = client.with_chat(chat1).with_chat(chat2).with_chat(chat3);
|
||||
|
||||
// 4. Симулируем загрузку чатов через load_chats
|
||||
let loaded_chats = client.load_chats(50).await.unwrap();
|
||||
@@ -58,9 +55,7 @@ async fn test_user_journey_open_chat_send_message() {
|
||||
.outgoing()
|
||||
.build();
|
||||
|
||||
let client = client
|
||||
.with_message(123, msg1)
|
||||
.with_message(123, msg2);
|
||||
let client = client.with_message(123, msg1).with_message(123, msg2);
|
||||
|
||||
// 3. Открываем чат
|
||||
client.open_chat(ChatId::new(123)).await.unwrap();
|
||||
@@ -77,12 +72,10 @@ async fn test_user_journey_open_chat_send_message() {
|
||||
assert_eq!(history[1].text(), "I'm good, thanks!");
|
||||
|
||||
// 7. Отправляем новое сообщение
|
||||
let _new_msg = client.send_message(
|
||||
ChatId::new(123),
|
||||
"What's for dinner?".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
let _new_msg = client
|
||||
.send_message(ChatId::new(123), "What's for dinner?".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 8. Проверяем что сообщение отправлено
|
||||
assert_eq!(client.get_sent_messages().len(), 1);
|
||||
@@ -153,34 +146,43 @@ async fn test_user_journey_multi_step_conversation() {
|
||||
client.set_update_channel(tx);
|
||||
|
||||
// 4. Входящее сообщение от Alice
|
||||
client.simulate_incoming_message(ChatId::new(789), "How's the project going?".to_string(), "Alice");
|
||||
client.simulate_incoming_message(
|
||||
ChatId::new(789),
|
||||
"How's the project going?".to_string(),
|
||||
"Alice",
|
||||
);
|
||||
|
||||
// Проверяем update
|
||||
let update = rx.try_recv().ok();
|
||||
assert!(matches!(update, Some(TdUpdate::NewMessage { .. })));
|
||||
|
||||
// 5. Отвечаем
|
||||
client.send_message(
|
||||
ChatId::new(789),
|
||||
"Almost done! Just need to finish tests.".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(
|
||||
ChatId::new(789),
|
||||
"Almost done! Just need to finish tests.".to_string(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 6. Проверяем историю после первого обмена
|
||||
let history1 = client.get_chat_history(ChatId::new(789), 50).await.unwrap();
|
||||
assert_eq!(history1.len(), 2);
|
||||
|
||||
// 7. Еще одно входящее сообщение
|
||||
client.simulate_incoming_message(ChatId::new(789), "Great! Let me know if you need help.".to_string(), "Alice");
|
||||
client.simulate_incoming_message(
|
||||
ChatId::new(789),
|
||||
"Great! Let me know if you need help.".to_string(),
|
||||
"Alice",
|
||||
);
|
||||
|
||||
// 8. Снова отвечаем
|
||||
client.send_message(
|
||||
ChatId::new(789),
|
||||
"Will do, thanks!".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(789), "Will do, thanks!".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 9. Финальная проверка истории
|
||||
let final_history = client.get_chat_history(ChatId::new(789), 50).await.unwrap();
|
||||
@@ -219,24 +221,20 @@ async fn test_user_journey_switch_chats() {
|
||||
assert_eq!(client.get_current_chat_id(), Some(111));
|
||||
|
||||
// 3. Отправляем сообщение в первом чате
|
||||
client.send_message(
|
||||
ChatId::new(111),
|
||||
"Message in chat 1".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(111), "Message in chat 1".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 4. Переключаемся на второй чат
|
||||
client.open_chat(ChatId::new(222)).await.unwrap();
|
||||
assert_eq!(client.get_current_chat_id(), Some(222));
|
||||
|
||||
// 5. Отправляем сообщение во втором чате
|
||||
client.send_message(
|
||||
ChatId::new(222),
|
||||
"Message in chat 2".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(222), "Message in chat 2".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 6. Переключаемся на третий чат
|
||||
client.open_chat(ChatId::new(333)).await.unwrap();
|
||||
@@ -270,12 +268,10 @@ async fn test_user_journey_edit_during_conversation() {
|
||||
client.open_chat(ChatId::new(555)).await.unwrap();
|
||||
|
||||
// 2. Отправляем сообщение с опечаткой
|
||||
let msg = client.send_message(
|
||||
ChatId::new(555),
|
||||
"I'll be there at 5pm tomorow".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
let msg = client
|
||||
.send_message(ChatId::new(555), "I'll be there at 5pm tomorow".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 3. Проверяем что сообщение отправлено
|
||||
let history = client.get_chat_history(ChatId::new(555), 50).await.unwrap();
|
||||
@@ -283,17 +279,19 @@ async fn test_user_journey_edit_during_conversation() {
|
||||
assert_eq!(history[0].text(), "I'll be there at 5pm tomorow");
|
||||
|
||||
// 4. Исправляем опечатку
|
||||
client.edit_message(
|
||||
ChatId::new(555),
|
||||
msg.id(),
|
||||
"I'll be there at 5pm tomorrow".to_string()
|
||||
).await.unwrap();
|
||||
client
|
||||
.edit_message(ChatId::new(555), msg.id(), "I'll be there at 5pm tomorrow".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 5. Проверяем что сообщение отредактировано
|
||||
let edited_history = client.get_chat_history(ChatId::new(555), 50).await.unwrap();
|
||||
assert_eq!(edited_history.len(), 1);
|
||||
assert_eq!(edited_history[0].text(), "I'll be there at 5pm tomorrow");
|
||||
assert!(edited_history[0].metadata.edit_date > 0, "Должна быть установлена дата редактирования");
|
||||
assert!(
|
||||
edited_history[0].metadata.edit_date > 0,
|
||||
"Должна быть установлена дата редактирования"
|
||||
);
|
||||
|
||||
// 6. Проверяем историю редактирований
|
||||
assert_eq!(client.get_edited_messages().len(), 1);
|
||||
@@ -315,7 +313,11 @@ async fn test_user_journey_reply_in_conversation() {
|
||||
client.set_update_channel(tx);
|
||||
|
||||
// 3. Входящее сообщение с вопросом
|
||||
client.simulate_incoming_message(ChatId::new(666), "Can you send me the report?".to_string(), "Charlie");
|
||||
client.simulate_incoming_message(
|
||||
ChatId::new(666),
|
||||
"Can you send me the report?".to_string(),
|
||||
"Charlie",
|
||||
);
|
||||
|
||||
let update = rx.try_recv().ok();
|
||||
assert!(matches!(update, Some(TdUpdate::NewMessage { .. })));
|
||||
@@ -324,12 +326,10 @@ async fn test_user_journey_reply_in_conversation() {
|
||||
let question_msg_id = history[0].id();
|
||||
|
||||
// 4. Отправляем другое сообщение (не связанное)
|
||||
client.send_message(
|
||||
ChatId::new(666),
|
||||
"Working on it now".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(666), "Working on it now".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 5. Отвечаем на конкретный вопрос (reply)
|
||||
let reply_info = Some(tele_tui::tdlib::ReplyInfo {
|
||||
@@ -338,12 +338,15 @@ async fn test_user_journey_reply_in_conversation() {
|
||||
text: "Can you send me the report?".to_string(),
|
||||
});
|
||||
|
||||
client.send_message(
|
||||
ChatId::new(666),
|
||||
"Sure, sending now!".to_string(),
|
||||
Some(question_msg_id),
|
||||
reply_info
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(
|
||||
ChatId::new(666),
|
||||
"Sure, sending now!".to_string(),
|
||||
Some(question_msg_id),
|
||||
reply_info,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 6. Проверяем что reply сохранён
|
||||
let final_history = client.get_chat_history(ChatId::new(666), 50).await.unwrap();
|
||||
@@ -376,12 +379,10 @@ async fn test_user_journey_network_state_changes() {
|
||||
|
||||
// 4. Открываем чат и отправляем сообщение
|
||||
client.open_chat(ChatId::new(888)).await.unwrap();
|
||||
client.send_message(
|
||||
ChatId::new(888),
|
||||
"Test message".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(888), "Test message".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Очищаем канал от update NewMessage
|
||||
let _ = rx.try_recv();
|
||||
@@ -391,8 +392,14 @@ async fn test_user_journey_network_state_changes() {
|
||||
|
||||
// Проверяем update
|
||||
let update = rx.try_recv().ok();
|
||||
assert!(matches!(update, Some(TdUpdate::ConnectionState { state: NetworkState::WaitingForNetwork })),
|
||||
"Expected ConnectionState update, got: {:?}", update);
|
||||
assert!(
|
||||
matches!(
|
||||
update,
|
||||
Some(TdUpdate::ConnectionState { state: NetworkState::WaitingForNetwork })
|
||||
),
|
||||
"Expected ConnectionState update, got: {:?}",
|
||||
update
|
||||
);
|
||||
|
||||
// 6. Проверяем что состояние изменилось
|
||||
assert_eq!(client.get_network_state(), NetworkState::WaitingForNetwork);
|
||||
@@ -405,12 +412,10 @@ async fn test_user_journey_network_state_changes() {
|
||||
assert_eq!(client.get_network_state(), NetworkState::Ready);
|
||||
|
||||
// 8. Отправляем сообщение после восстановления
|
||||
client.send_message(
|
||||
ChatId::new(888),
|
||||
"Connection restored!".to_string(),
|
||||
None,
|
||||
None
|
||||
).await.unwrap();
|
||||
client
|
||||
.send_message(ChatId::new(888), "Connection restored!".to_string(), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 9. Проверяем что оба сообщения в истории
|
||||
let history = client.get_chat_history(ChatId::new(888), 50).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user