mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
add test for delta sync between client and server
This commit is contained in:
@ -68,6 +68,7 @@ impl ServerEditDoc {
|
||||
if cur_rev_id > rev_id {
|
||||
let doc_delta = self.document.read().delta().clone();
|
||||
let cli_revision = self.mk_revision(rev_id, doc_delta);
|
||||
log::debug!("Server push rev");
|
||||
let ws_cli_revision = mk_push_rev_ws_message(&self.doc_id, cli_revision);
|
||||
user.socket.do_send(ws_cli_revision).map_err(internal_error)?;
|
||||
}
|
||||
@ -98,6 +99,7 @@ impl ServerEditDoc {
|
||||
if cur_rev_id != revision.base_rev_id {
|
||||
// The server document is outdated, try to get the missing revision from the
|
||||
// client.
|
||||
log::debug!("Server push rev");
|
||||
user.socket
|
||||
.do_send(mk_pull_rev_ws_message(&self.doc_id, cur_rev_id, revision.rev_id))
|
||||
.map_err(internal_error)?;
|
||||
|
@ -45,7 +45,7 @@ async fn sync_open_empty_doc_and_sync_from_server_using_ws() {
|
||||
DocScript::OpenDoc,
|
||||
DocScript::SetServerDocument(json, 3),
|
||||
DocScript::ConnectWs,
|
||||
DocScript::AssertClient(r#"[{"insert":"123\n\n"}]"#),
|
||||
DocScript::AssertClient(r#"[{"insert":"\n123\n"}]"#),
|
||||
])
|
||||
.await;
|
||||
}
|
||||
@ -62,8 +62,8 @@ async fn sync_open_non_empty_doc_and_sync_with_sever() {
|
||||
DocScript::SetServerDocument(json, 3),
|
||||
DocScript::SendText(0, "abc"),
|
||||
DocScript::ConnectWs,
|
||||
DocScript::AssertClient(r#"[{"insert":"123\nabc\n"}]"#),
|
||||
// DocScript::AssertServer(r#"[{"insert":"123\nabc\n"}]"#),
|
||||
DocScript::AssertClient(r#"[{"insert":"abc\n123\n"}]"#),
|
||||
DocScript::AssertServer(r#"[{"insert":"abc\n123\n"}]"#),
|
||||
])
|
||||
.await;
|
||||
}
|
||||
|
Reference in New Issue
Block a user