mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-09 01:56:08 +00:00

* chore: rename flowy-folder2 to flowy-folder * chore: rename flowy-document2 to flowy-document * chore: fix test * chore: move lib-infra crate * chore: remove shared-lib * chore: fix clippy
62 lines
2.0 KiB
Rust
62 lines
2.0 KiB
Rust
use std::time::Duration;
|
|
|
|
use event_integration::document_event::assert_document_data_equal;
|
|
use flowy_document::entities::DocumentSyncStatePB;
|
|
|
|
use crate::document::supabase_test::helper::FlowySupabaseDocumentTest;
|
|
use crate::util::receive_with_timeout;
|
|
|
|
#[tokio::test]
|
|
async fn supabase_document_edit_sync_test() {
|
|
if let Some(test) = FlowySupabaseDocumentTest::new().await {
|
|
let view = test.create_document().await;
|
|
let document_id = view.id.clone();
|
|
|
|
let cloned_test = test.clone();
|
|
let cloned_document_id = document_id.clone();
|
|
test.appflowy_core.dispatcher().spawn(async move {
|
|
cloned_test
|
|
.insert_document_text(&cloned_document_id, "hello world", 0)
|
|
.await;
|
|
});
|
|
|
|
// wait all update are send to the remote
|
|
let rx = test
|
|
.notification_sender
|
|
.subscribe_with_condition::<DocumentSyncStatePB, _>(&document_id, |pb| !pb.is_syncing);
|
|
receive_with_timeout(rx, Duration::from_secs(30))
|
|
.await
|
|
.unwrap();
|
|
|
|
let document_data = test.get_document_data(&document_id).await;
|
|
let update = test.get_document_doc_state(&document_id).await;
|
|
assert_document_data_equal(&update, &document_id, document_data);
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn supabase_document_edit_sync_test2() {
|
|
if let Some(test) = FlowySupabaseDocumentTest::new().await {
|
|
let view = test.create_document().await;
|
|
let document_id = view.id.clone();
|
|
|
|
for i in 0..10 {
|
|
test
|
|
.insert_document_text(&document_id, "hello world", i)
|
|
.await;
|
|
}
|
|
|
|
// wait all update are send to the remote
|
|
let rx = test
|
|
.notification_sender
|
|
.subscribe_with_condition::<DocumentSyncStatePB, _>(&document_id, |pb| !pb.is_syncing);
|
|
receive_with_timeout(rx, Duration::from_secs(30))
|
|
.await
|
|
.unwrap();
|
|
|
|
let document_data = test.get_document_data(&document_id).await;
|
|
let update = test.get_document_doc_state(&document_id).await;
|
|
assert_document_data_equal(&update, &document_id, document_data);
|
|
}
|
|
}
|